Installing Git on Debian

Git is the most popular version control system nowadays. It helps to share and collaborate on software development projects. Git is mainly used for source code management. In this tutorial, you are going to learn how to install Git on Debian 9.

Prerequisites

Before you start installing Git on Debian 9. You must have the non-root user account on your Server or Desktop with sudo privileges.

1. Install Git on Debian

To install Git in Debian you need to update the apt package manager index then you will install it in Ubuntu. After that, you will confirm installation.

To update apt package manager index type following in the terminal

sudo apt update

Now install Git in Ubuntu by typing

sudo apt install git

Confirm the installation and check the version executing the following command

git --version

The output should be:

Output:
    git version 2.17.1

2. Setting Up Git

To prevent warning every time you should configure it perfectly by using your Git information

First set the global username for Git

git config --global user.name "User Name"

Secondly set global email for Git

git config --global user.email "[email protected]"

You can also change above configuration by editing .gitconfig file. To edit gitconfig file type

nano ~/.gitconfig

Editing Git Configuration File

Edit above file by setting Name and Email.

Conclusion

Here we have successfully learned how to install Git on Debian 9 and you have also learned setting up Git to start working on the system. If You have any queries regarding this please don’t forget to comment below.

Install Let’s Encrypt on Debian

By using Let’s Encrypt you can get a free valid SSL certificate. Let’s Encrypt is the Certificate Authority (CA) which provides free SSL certificate. To get SSL certificate Certbot client is used which fetches and deploys SSL certificate on your server. In this tutorial, you are going to learn how to install Let’s Encrypt SSL on Debian 9.

Before we begin

Let’s Encrypt certificate can only be requested from the server the domain is pointing to. Let’s Encrypt checks if the domain is pointed to the current server and if successful, it issues the certificate.

Prerequisites

1. Before you start to install Let’s Encrypt SSL on Debian 9 using the Certbot client. You must have the non-root user account on your server with sudo privileges.

2. Make it sure your domain is pointing to the current server.

1. Install Certbot Client

To install Certbot client you need to add PPA on the server then you will need to update the package manager index. After that, you will install the Certbot client.

Add PPA by typing following in the terminal

sudo add-apt-repository ppa:certbot/certbot

Update package manager index by typing following

sudo apt update

Now install Certbot client by executing following command

sudo apt install python-certbot-nginx

Confirm the installation by typing

certbot --version

2. Setting Up Firewall

If you have enabled UFW firewall then you need to adjust the settings to allow HTTPS traffic.

To check current status type following command

sudo ufw status
Output
Output
Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere                  
Nginx HTTP                 ALLOW       Anywhere                  
OpenSSH (v6)               ALLOW       Anywhere (v6)             
Nginx HTTP (v6)            ALLOW       Anywhere (v6)

Now to get HTTPS traffic in, you should add ‘WWW Full’ rule and delete ‘WWW’ rule which will become redundant.

sudo ufw allow 'Nginx Full'
sudo ufw delete allow 'Nginx HTTP'

Now the status should be:

Output
Output
Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere                  
Nginx Full                 ALLOW       Anywhere                  
OpenSSH (v6)               ALLOW       Anywhere (v6)             
Nginx Full (v6)            ALLOW       Anywhere (v6)

3. Setting up Let’s Encrypt SSL on Nginx

Let’s Encrypt do a strong domain validation for ownership of the domain. After successful verification, it issues the certificate. In below command replace example with your domain name

sudo certbot --apache -d example.com -d www.example.com

If you are first time installing certificate then Certbot will ask you to enter Email ID and agree terms and conditions.

After above step Certbot will ask you to configure HTTPS settings.

Output
Output
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
-------------------------------------------------------------------------------
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
-------------------------------------------------------------------------------
Select the appropriate number [1-2] then [enter](press 'c' to cancel):

Select your choice and continue to next step. We recommend to choose Redirect Option if you dont want to modify configuration file manually.

5. Autorenewal For SSL Certificates

All of these Let’s Encrypt certificates are short-lived and expires after 90 days. So you will have to update these certificates before they expire by running the following command.

sudo certbot renew

You can automate this process by adding a cronjob. Enter the following command to open crontab

sudo crontab -e

Add following lines to end of the file. It will run the command twice a day and renews if the certificate is about to expire.

0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(43200))' && certbot -q renew

4. Installing Let’s Encrypt Wildcard Certificates

Let’s Encrypt now supports wildcard certificate using new ACME2 protocol. By using wildcard certificate \*.example.com like this, you can use one certificate for multiple sub-domains like site1.example.com, site2.example.com, site3.example.com etc. To install the wildcard certificate type following command.

sudo certbot certonly --manual -d *.example.com --agree-tos --no-bootstrap --manual-public-ip-logging-ok --preferred-challenges dns-01 --server https://acme-v02.api.letsencrypt.org/directory

NOTE: Now you will see the message at center in output to add TXT record. So make DNS changes to your domain and add specific TXT record with given value inside output of above command

Conclusion

You have learned how to install Let’s Encrypt SSL on Debian 9 by using Certbot. If you have any queries regarding this please don’t forget to comment below.

Install Node.js with npm on Debian 9

In this tutorial, we are going to learn how to install Node.js with npm on Debian 9. Node.js is the opensource JavaScript Run-time environment for server-side execution of JavaScript code. Node.js built on Chrome’s V8 JavaScript engine so it can be used to build different types of server-side application.

Where npm stands for Node Package Manager which is the default package manager for Node.js. npm is the worlds largest software registry for Node.js packages with thousands of packages available.

In this tutorial we will install Node.js in following two ways:

  1. Install Node.js and npm using Ubuntu repository
  2. Install Node.js and npm using nvm
  3. Install Node.js from NodeSource repository.

1. Install Node.js and npm using Ubuntu repository

First, Update Ubuntu apt package manager index by running following command.

sudo apt update

Install Node.js from Ubuntu global repository by typing

sudo apt install node

Confirm the installation of Node.js by typing

node --version

Install npm by running following command

sudo apt install npm

Confirm the installation of npm by typing

npm --version

2. Install Node.js and npm using nvm

NVM stands for Node Version Manager which is used to manage multiple Node.js versions. If you want to install or uninstall different versions of Node.js then NVM is there for you.

First, we will install NVM (Node Package Manager) on your system. So download NVM installation script running the following command.

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
How to install Node.js and npm using nvm on Debian 9
How to install Node.js and npm using nvm on Debian 9

Check nvm version and confirm installation typing

node --version

Now install Node.js by using the following command.

nvm install node

Verify Node.js installation by typing

node --version

The output should be:

Output
v10.14.0

You can install multiple versions of Node.js. To do so type following:

nvm install 8.14
nvm install --lts
nvm install 11.3

To list all the versions installed run following command.

nvm ls

You can change the current default version of Node.js by using the following command.

nvm use 8.14

To uninstall a Node.js version type following command

nvm uninstall 11.14

Install Node.js from NodeSource Repository

NodeSource company provides enterprise grade node support also maintains repository containing latest version of Node.js.

To enable NodeSource repository on your system run following command.

curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -

NOTE : The latest LTS version of Node.js is 10.x if you want to install 8.x version then just replace setup_10.x with setup_8.x

Now install Node.js and npm package typing.

sudo apt install nodejs

Verify installtion of Node.js and npm running following command

node --version
npm --version

Install Development Tools

Now install some packages needed for development by running following command

sudo apt install gcc g++ make

Uninstall Node.js and npm

Uninstall Node.js use following command

sudo apt remove nodejs npm
sudo apt autoremove

To uninstall node.js version using nvm type following command

nvm uninstall 10.14

Conclusion

You have successfully learned how to install Node.js with npm on Debian 9. If you have any queries don’t forget to comment below.

Install Let’s Encrypt on Debian

By using Let’s Encrypt you can get a free valid SSL certificate. Let’s Encrypt is the Certificate Authority (CA) which provides free SSL certificate. To get SSL certificate Certbot client is used which fetches and deploys SSL certificate on your server. In this tutorial, you are going to learn how to install Let’s Encrypt SSL on Debian 9.

Before we begin

Let’s Encrypt certificate can only be requested from the server the domain is pointing to. Let’s Encrypt checks if the domain is pointed to the current server and if successful, it issues the certificate.

Prerequisites

1. Before you start to install Let’s Encrypt SSL on Debian 9 using the Certbot client. You must have the non-root user account on your server with sudo privileges.

2. Make it sure your domain is pointing to the current server.

1. Install Certbot Client

To install Certbot client you need to add PPA on the server then you will need to update the package manager index. After that, you will install the Certbot client.

Add PPA by typing following in the terminal

sudo add-apt-repository ppa:certbot/certbot

Update package manager index by typing following

sudo apt update

Now install Certbot client by executing following command

sudo apt install certbot

Confirm the installation by typing

certbot --version

2. Setting Up Firewall

If you have enabled UFW firewall then you need to adjust the settings to allow HTTPS traffic.

To check current status type following command

sudo ufw status
Output
Output
Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere                  
WWW                        ALLOW       Anywhere                  
OpenSSH (v6)               ALLOW       Anywhere (v6)             
WWW (v6)                   ALLOW       Anywhere (v6)

Now to get HTTPS traffic in, you should add ‘WWW Full’ rule and delete ‘WWW’ rule which will become redundant.

sudo ufw allow 'WWW Full'
sudo ufw delete allow 'WWW'

Now the status should be:

Output
Output
Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere                  
WWW Full                   ALLOW       Anywhere                  
OpenSSH (v6)               ALLOW       Anywhere (v6)             
WWW Full (v6)              ALLOW       Anywhere (v6)

3. Setting up Let’s Encrypt SSL on Apache

To set up on Apache we need to install the Certbot plugin for Apache which makes this process much easier.

sudo apt install python-certbot-apache

Let’s Encrypt do a strong domain validation for ownership of the domain. After successful verification, it issues the certificate. In below command replace example with your domain name

sudo certbot --apache -d example.com -d www.example.com

If you are the first time to install certificate then Certbot will ask you to enter Email ID and agree to terms and conditions.

After the above step, Certbot will ask you to configure HTTPS settings.

Output
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
-------------------------------------------------------------------------------
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
-------------------------------------------------------------------------------
Select the appropriate number [1-2] then [enter](press 'c' to cancel):

Select your choice and continue to next step.

4. Autorenewal For SSL Certificates

All of these Let’s Encrypt certificates are short-lived and expires after 90 days. So you will have to update these certificates before they expire by running the following command.

sudo certbot renew

You can automate this process by adding a cronjob. Enter the following command to open crontab

sudo crontab -e

Add following lines to end of the file. It will run the command twice a day and renews if the certificate is about to expire.

0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(43200))' && certbot -q renew

5. Installing Let’s Encrypt Wildcard Certificates

Let’s Encrypt now supports wildcard certificate using new ACME2 protocol. By using wildcard certificate \*.example.com like this, you can use one certificate for multiple sub-domains like site1.example.com, site2.example.com, site3.example.com etc. To install the wildcard certificate type following command.

sudo certbot certonly --manual -d *.example.com --agree-tos --no-bootstrap --manual-public-ip-logging-ok --preferred-challenges dns-01 --server https://acme-v02.api.letsencrypt.org/directory

NOTE: Now you will see the message at center in output to add TXT record. So make DNS changes to your domain and add specific TXT record with given value inside output of above command

Conclusion

You have learned how to install Let’s Encrypt SSL on Debian 9 by using Certbot. If you have any queries regarding this please don’t forget to comment below.

Install Dropbox on Debian 9 Server and Desktop

Dropbox is the online storage service provides online storage to backup and store data automatically with security. It has both free and paid plan. In the free plan, Dropbox provides 2GB storage and if you want more storage then you can buy paid plans. In this tutorial, you are going to learn how to install Dropbox on Debian 9.

Prerequisites

Before you start to install Dropbox on Debian 9. You must have the non-root user account on your Server/Desktop with sudo privileges.

1. Install Dropbox With GUI

Now, Update package manager index by typing following.

sudo apt update

Install Dropbox by running following command

sudo apt install nautilus-dropbox

After installing Dropbox, launch Dropbox from Activities.

install dropbox on ubuntu activities launch
Install Dropbox on Ubuntu – Activities Launch

It will start automatically downloading main Dropbox binaries. After downloading completes. It will prompt you to enter credentials and login or register with Dropbox. After Successful Sign in you are ready to use Dropbox.

"<yoastmark

Now start using Dropbox by visiting the Dropbox menu on your system.

2.Install Dropbox from Terminal

Enter following command to dowload Dropbox on system. It will create .dropbox-dist in HOME directory.

For 32 bit:

cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86" | tar xzf -

For 64 bit:

cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64 | tar xzf -"

Start Dropbox daemon by typing following

~/.dropbox-dist/dropboxd

Output should be:

This computer isn't linked to any Dropbox account...
Please visit https://www.dropbox.com/cli_link_nonce?nonce=dhjsjchy89ksf5372828c03709 to link this device.

Now open above link in your favorite browser. Note you can also open above link on any other system.

Enter username and password and Sign In to the account. Once the server connects to Dropbox account you can see following output

This computer is now linked to Dropbox. Welcome Smart

Now folder named Dropbox will be created in HOME directory. List files inside folder typing

ls Dropbox

It’s time to install Dropbox CLI (Dropbox Command Line Interface). Dropbox CLI requires Python should be installed. Enter following commands to install Python and Dropbox CLI.

sudo apt install python
sudo wget -O /usr/local/bin/dropbox "https://www.dropbox.com/download?dl=packages/dropbox.py"
sudo chmod +x /usr/local/bin/dropbox

3. Manage Operations with Dropbox CLI

To Manage Dropbox operations on the server side you should use Dropbox CLI (Command Line Interface).

List all commands available with Dropbox CLI by typing:

dropbox

Output should be,

Output:
Dropbox command-line interface
commands:

Note: use dropbox help <command> to view usage for a specific command.

 status       get current status of the dropboxd
 throttle     set bandwidth limits for Dropbox
 help         provide help
 puburl       get public url of a file in your dropbox's public folder
 stop         stop dropboxd
 update       download latest version of dropbox
 running      return whether dropbox is running
 start        start dropboxd
 filestatus   get current sync status of one or more files
 proxy        set proxy settings for Dropbox
 autostart    automatically start dropbox at login
 exclude      ignores/excludes a directory from syncing
 lansync      enables or disables LAN sync
 sharelink    get a shared link for a file in your dropbox
 ls           list directory contents with current sync status

If you want more information about a specific command enter following command

dropbox help sharelink

Above command will provide you more information about sharelink command.

dropbox running

Returns 1 if running 0 if not running.

Check status of dropbox by typing

dropbox status

If Dropbox is not active then start service by running following command

dropbox start

To stop dropbox service enter following command

dropbox stop

Get sync status of Dropbox file by typing

dropbox filestatus Dropbox/test.txt

Generate shareable link for a file by typing

dropbox sharelink Dropbox/test.txt

You can exclude the directory from syncing by using the following command

dropbox exclude add Dropbox/dir1

To list excluded directories type following command

dropbox exclude list

Remove directory from excluded list typing

dropbox exclude remove Dropbox/dir1

4. Start Dropbox After Reboot

To start Dropbox after every reboot you should create systemd service inside your Ubuntu. Create a service by running the following command

sudo nano /etc/systemd/system/dropbox.service

Copy following code inside that file by typing. You should replace User, Group and Dropbox CLI path /usr/local/bin/ with your own paths.

[Unit]
Description=Dropbox Service
After=network.target

[Service]
ExecStart=/bin/sh -c '/usr/local/bin/dropbox start'
ExecStop=/bin/sh -c '/usr/local/bin/dropbox stop'
PIDFile=${HOME}/.dropbox/dropbox.pid
User=smart
Group=smart
Type=forking
Restart=on-failure
RestartSec=5
StartLimitInterval=60s
StartLimitBurst=3

[Install]
WantedBy=multi-user.target

Reload Systemctl daemon typing

sudo systemctl daemon-reload

Now enable Dropbox service by typing following command

sudo systemctl enable dropbox service

Start Dropbox service using

sudo systemctl start dropbox service

Get status of the Dropbox service by

sudo systemctl status dropbox service

Conclusion

You have successfully learned how to install Dropbox on Debian 9. If you have any queries don’t forget to comment below.