Download video from YouTube and convert it to mp3 in Linux

To download video from YouTube you can use some site in Internet, but many of them have ads, viruses and don’t do what you need.

But you can use simple program youtube-dl. It is free, open source, work in console and can download video, audio from YouTube in one click.

To install youtube-dl use simple commands:

1. Install python:

sudo apt install python3
sudo ln -s /usr/bin/python3 /usr/local/bin/python

2. Install youtube-dl:

sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl

How to use youtube-dl:

To get all supported formats from YouTube video use command:

youtube-dl -F https://www.youtube.com/watch?v=QpqdtB4ssX0

Thic sommand show you all video formats and id’s

To download some format use flag -f and ID from previous command:

youtube-dl -f 18 https://www.youtube.com/watch?v=QpqdtB4ssX0

That’s all, video starts download. You can use it in terminal and don’t need to open suspicious sites.

You can also download playlists of video from YouTube the same way.

Convert video to mp3 audio.

And you can convert video to mp3 using program ffmpeg. To install ffmpeg use command:

sudo apt install ffmpeg

To convert video to mp3 use command:

ffmpeg -i video.mp4 -acodec libmp3lame audio.mp3

Configure thumbnails for video files in nextcloud

Nextcloud use ffmpeg to generate thumbnails from video files, so you need to install ffmpeg on your server first:

sudo apt install ffmpeg

Now configure nextcloud. Open configuration file /config/config.php and add this lines:

'enable_previews' => true,
'enabledPreviewProviders' => array (
        0 => 'OC\\Preview\\Image',
        1 => 'OC\\Preview\\Movie',
        2 => 'OC\\Preview\\TXT',
),

That’s all, it is very simple 😉

How to Install NGINX and PHP 7.4 on Debian 10

Step 1: Install Nginx

Firstly install the prerequisites:

sudo apt install curl gnupg2 ca-certificates lsb-release

Then we need to add the Nginx mainline package to our repository so that when we run apt install nginx, we will download the mainline version instead of the old stable version.

echo "deb http://nginx.org/packages/mainline/debian `lsb_release -cs` nginx" 
    | sudo tee /etc/apt/sources.list.d/nginx.list

Next we need to download the signing key so that we can verify its authenticity

curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -

If it prints out OK! then you are good to go!

Now update package repositories and install Nginx:

sudo apt update
sudo apt install nginx

That’s it! You have now installed the latest release of Nginx on Debian 10. You should now start it!

sudo systemctl start nginx.service

And Don’t forget to make it automatically start on system boot as well.

sudo systemctl enable nginx.service

Step 2: Install PHP 7.4

To install PHP 7.4 we need to add repository. Since PHP 7.4 didn’t come with Debian 10 it is required to add the following repository. Write this commands:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php

Update package repositories:

sudo apt update

And now install PHP 7.4:

sudo apt install php7.4-fpm php7.4-common php7.4-mysql php7.4-gmp php7.4-curl php7.4-intl php7.4-mbstring php7.4-xmlrpc php7.4-gd php7.4-xml php7.4-cli php7.4-zip php7.4-soap php7.4-imap

It is recommended to raise the memory limit to improve the overall performance. Your PHP configuration is located in /etc/php/7.4/fpm/php.ini.

sudo vim /etc/php/7.4/fpm/php.ini

Replace it with memory_limit = 256 and save document with :wq command. How to edit files in text editor Vim you can read here: How to exit Vim? And other required commands.

Step 3: Configure Nginx

Add nginx to www-data group

sudo usermod -a -G www-data nginx

Change owner of directory to www-data

sudo chown -R www-data /usr/share/nginx/html

Go into your default.conf file

sudo vim /etc/nginx/conf.d/default.conf

Replace your existing configuration file with the one below

server {
    listen       80;
    server_name  localhost;

    root   /usr/share/nginx/html;
    index  index.php index.html index.htm;

   location / {
    if ($request_uri ~ ^/(.*)\.html$) {
        return 302 /$1;
        }
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
        location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass   unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

}

Restart Nginx server:

service nginx restart

Now you can cteate test file fith information about PHP version:

nano /usr/share/nginx/html/phpinfo.php
phpinfo();

In Web-browser write IP address of server:
http://192.168.1.1/phpinfo.php

That’s all Nginx Server with PHP 7.4 installed.

Install monit in Debian 10 (buster)

Monit is a free open source utility for managing and monitoring, processes, files, directories and filesystems on a UNIX system. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations.

To install Monit on Debian 10 GNU Linux (Buster) you need to add backports repository:

printf "%s\n" "deb http://ftp.de.debian.org/debian buster-backports main" | \
sudo tee /etc/apt/sources.list.d/buster-backports.list

Then update package list:

sudo apt update

And install buster-backports and monit package:

sudo apt install -t buster-backports monit

To start monit service and show running status use commands:

sudo systemctl start monit
sudo systemctl status monit

If you want to enable auto start monit when system starts use command:

sudo systemctl enable monit

Now let’s configure monit to monitoring Apache2 and Nginx services. Open monit configuration file:

sudo vim /etc/monit/monitrc

To change monitoring interval change option:

set daemon 120

To send email if monitored services is down edit this options:

set mailserver your.mail.server
set alert your.mail.address

You can enable Web-interface where you can view information about monitoring services. By default monit starts on 2812 port. Enable this two lines and change administrator password:

set httpd port 2812 and
allow admin:monit # require user 'admin' with password 'monit'

Don’t forget to open port 2812 in firewall and restart monit service:

sudo systemctl restart monit

Now open http://your-site.com:2812 and see monit web interface:

If you want to monitor some custom services on your server go to /etc/monit/conf-available and copy that configuration files to /etc/monit/conf.d:

Install Skype on Debian 10

Skype is not an open-source application, and it is not included in the default Debian repositories. We’ll install Skype using the Skype deb package.

Download Skype deb package:

wget https://go.skype.com/skypeforlinux-64.deb

When the download is complete, install Skype using command:

sudo apt install ./skypeforlinux-64.deb

Now run Skype and authorize with your login, that’s all

Install Viber on Debian 10

Step 1: install flatpak:

sudo apt install flatpak

Step 2: install Viber:

flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak --user install flathub com.viber.Viber

That’s all, scan QR code with your phone and use Viber on Debian 10!

Debian 10 – install and configure i3wm

i3 is a tiling window manager designed for X11, inspired by wmii and written in C. It supports tiling, stacking, and tabbing layouts, which it handles dynamically.

Configuration is achieved via plain text file and extending i3 is possible using its Unix domain socket and JSON based IPC interface from many programming languages.

Step 1: Install Debian 10.

Download Debian 10 .ISO image from official site: https://www.debian.org/

Step 2: Write ISO image to USB drive using program Etcher:

Step 3: Install Debian 10 on your PC.

Don’t install any other programs and desktop environments, uncheck all check boxes in installation menu. You need clear operating system without any other software.

Installation i3wm and other software:

Now you have clear oerating system with command shell.

First authorize in system with root login, change repositories to testing branch in file /etc/apt/sources.list, it is needed to get latest packages:

Upgrade your system:

apt update
apt upgrade

Install sudo and add sudo privilegies to your username:

apt install sudo
usermod -aG sudo username

Now you can logout from user root and authorize with your username login, Install file manager MC and other additional software:

sudo apt install mc vim htop screenfetch

Install X-Window-Server, I3, and other software for desktop environment:

apt install bash-completion lightdm zenity network-manager-gnome viewnior i3 xserver-xorg xbacklight conky nitrogen compton tilix firefox-esr thunar rofi flameshot

Visual Studio Code first config

Visual Studio Code is a very powerful free and open source text editor, but before start usage it you need to but to use all its features, you need to configure it.

Visual Studio Code

First of all disable telemetry collection in File > Preferences > Settings menu:

Override “Alt” button to toggle menu bar:

"window.titleBarStyle": "custom",
"window.customMenuBarAltFocus": false

Disable file previewing when clicked on at all is by setting:

"workbench.editor.enablePreview": false

Functionality of Visual Studio Code can be extended with plugins and extensions.

To disable Unicode strings highlight use command:

editor.unicodeHighlight.ambiguousCharacters = false

To change tabulation for existing document use command:

indent using tabs

I prefer to install such basic plugins: Project Manager, Ftp-sync, Show Functions, Beautify, and Material Icon Theme, Atom Material Theme:

This is my basic configuration of Visual Studio Code, you can also change other options and config this amazing text editor as you want.

Connect to SSTP server from Linux

SSTP is Microsofts Remote Access Solution (RAS) for PPP over SSL. It can be used instead of PPTP or L2TP, and is only available with Windows Vista/7 connecting to a Windows 2008 Server. The advantage of SSTP compared to PPTP and L2TP is that it cannot be easily blocked by firewalls since the traffic is transmitted over HTTPS on port 443.

In Ubuntu Linux we can connect to SSTP by using SSTP-Client project on SourceForge.

To install SSTP-Client on Ubuntu add PPA repository:

sudo add-apt-repository ppa:eivnaes/network-manager-sstp

Then update package list and install packages sstp-client, network-manager-sstp by commands:

sudo apt update
sudo apt install sstp-client network-manager-sstp

Package network-manager-sstp is used only on Linux with graphic interface, on console Linux You don’t need to install this package.

To convert .CRT certificate to .PEM certificate use command:

openssl x509 -in mycert.crt -out mycert.pem -outform PEM

Install Nextcloud on Ubuntu server

To install Nextcloud on Ubuntu or other Linux use command:

sudo snap install nextcloud

After installation snap package check installation status

sudo snap changes nextcloud

To change default http and https ports use commands:

sudo snap set nextcloud ports.http=81
sudo snap set nextcloud ports.https=444

In Nginx proxy server configuration file change proxy_pass default port to 81:

Nextcloud’s automatic hostname detection can fail when behind a proxy; you might notice it redirecting incorrectly. If this happens, override the automatic detection (including the port if necessary), e.g.:

sudo nextcloud.occ config:system:set overwritehost --value="example.com:81"

Nextcloud and Nginx https proxy

If You use Nginx as https frontend and nextcloud as http backend – You neet co change /var/snap/nextcloud/20498/nextcloud/config.php insert the foloving lines:

  'overwrite.cli.url' => 'https://example.host',
  'overwriteprotocol' => 'https',

In Nginx http config file insert 301 redirect to https:

return 301 https://example.host$request_uri;

By default, PHP will use 128M as the memory limit. If you notice images not getting previews generated, or errors about memory exhaustion in your Nextcloud log, you may need to set this to a higher value.

If you’d like to set the memory limit to a higher value (say, 512M), run:

sudo snap set nextcloud php.memory-limit=512M

To set it to be unlimited (not recommended), use -1:

sudo snap set nextcloud php.memory-limit=-1

By default the cronjob interval is 15 minutes. To adjust it (say, 10 minutes) simply run:

sudo snap set nextcloud nextcloud.cron-interval=10m

Rescan all files for all users with occ console command:

sudo -u username php occ files:scan --all