Linux Commands HandBook

Kawshik Kumar Paul
8 min readMay 4, 2021

--

A handbook on basic linux commands for day to day usage.

Index

  1. Install an apt Package
  2. Install Manually Downloaded Debian (.deb) Package
  3. Install a snap/snapd Package
  4. Remove a Debian (.deb) / apt Package
  5. Remove a snap/snapd Package
  6. Install ProtonVPN
  7. Remove ProtonVPN
  8. Manage FireWall
  9. Write Bengali (Avro Alternative)
  10. CodeBlocks Auto-Indentation
  11. Vim Editor Install and CheatSheet
  12. Configure Vim Editor
  13. Bash Terminal Configuration

Install an apt Package

Step 1:

sudo apt update

Step 2:

sudo apt install <package_name>

Example: sudo apt install bison

Step 3:

Find the package

dpkg -l | grep bison Or, dpkg -l | grep biso*

Install a Manually Downloaded .deb Package

Step 1:

Download .deb file from trusted sources.

Step 2:

Right Click on it and Open with QApt package installer Or,

write in terminal sudo dpkg -i jdk-11.0.10_linux-x64_bin.deb

Done…

Install a snap / snapd Package

Step 1:

Install snap (If your OS doesn’t have preinstalled)

sudo apt update

sudo apt install snapd

Step 2:

Visit https://snapcraft.io/ and search your desired package.

Step 3:

See info about the package.

snap info <Package-Name>

snap info intellij-idea-ultimate

Step 4:

Click on Install and run the command in terminal which is given here.

sudo snap install intellij-idea-ultimate --classic

Done.

Uninstall / Remove a Debian Package Properly

Uninstalling or removing a debian (.deb) package properly means we will remove the package as well as the configuration and log files. Packages installed by sudo apt pkg_name are also .deb packages.

Step 1: See all the dpkg packages installed in OS

Debian packages are installed as dpkg packages.

dpkg -l

Use down arrow of keyboard to see the rest packages. Mouse may not work here. Press q to exit from this list.

Step 2: Find the package we want to remove

Suppose we want to remove deskreen from OS. Lets find it (See it exists or not).

dpkg -l | grep deskreen

Step 3: Remove the package (Without config files)

dpkg -r deskreen (if root user)

sudo dpkg -r deskreen (if not root user)

We aren’t done yet. We just removed the packages but configuration and log files still exists. See here.

Step 4: Remove With Configuration and Log files (this is called Purge)

dpkg -P deskreen (if root user)

sudo dpkg -P deskreen (if not root user)

Now see if it exists anymore.

We can skip Step 3 and directly can run Step 4.

(Alternative) Do using apt or apt-get

If you used apt or apt-get to install a package, you can uninstall/remove it by the following commands. (Step 5 is necessary in this case also).

sudo apt-get remove <application_name> (without config and log files)

sudo apt-get purge <package-name> (with config and log files)

Step 5: apt cleaning and updating

sudo apt autoclean

sudo apt autoremove

sudo apt update

Done.

Uninstall/Remove snap or snapd Package

Step 1: Get the packages in snap

snap list

Here we will remove riseup-vpn

Step 2:

sudo snap remove riseup-vpn

Or,

sudo snap remove --purge riseup-vpn (better)

Step 3:

Remove the rise-vpn folder from Home/snap/ folder.

Done. No more thing to do.

But some log files still exists. It doesn’t matter you delete/keep these files. Run locate riseup-vpn to look these.

Installing ProtonVPN (free)

ProtonVPN is an OpenSource Free unlimited VPN… Here are the steps for debian installation.

Step 1: SignUp

https://protonvpn.com/

Click on GET FREE, then SignUp.

Step 2: Open Terminal/Console

sudo apt update

sudo apt upgrade

Step 3:

wget -q -O — https://repo.protonvpn.com/debian/public_key.asc | sudo apt-key add -

Step 4:

sudo add-apt-repository ‘deb https://repo.protonvpn.com/debian unstable main’

Step 5:

sudo apt-get update && sudo apt-get install protonvpn

If update doesn’t return properly, then run the second command separately.

sudo apt-get install protonvpn

Step 6: LogIn into ProtonVPN account from terminal

protonvpn-cli login [ProtonVPN username]

Step 7: Check Status

protonvpn-cli status

Step 8: Connect VPN

protonvpn-cli connect

Step 9: Check Status and DNS

Step 10: Disconnect VPN

protonvpn-cli disconnect

Removing ProtonVPN from Linux

References: https://protonvpn.com/support/official-linux-client/

Manage FireWall

Install FireWall

sudo apt update

sudo apt install ufw

Check Status

sudo ufw status

Enable FireWall

sudo ufw enable

Disable FireWall

sudo ufw disable

References: https://linuxize.com/post/how-to-setup-a-firewall-with-ufw-on-ubuntu-20-04/

Write Bengali (Avro Alternative)

Avro has a problem. It crashes sometimes after writing a few words.

Alternative 1:

OpenBangla Keyboard offered a much much better experience. It doen’t crash and writes very smoothly. A great alternative to Avro Keyboard.

Visit openbangla.github.io

Alternative 2:

Use Google Input Tools extension in Google Chrome.

CodeBlocks Auto-Indentation

Sometimes in Linux, codeblocks indentation and auto bracket completeness don’t work well like the following picture.

It can be solved. If you have installed codeblocks already, follow from Step 3.

Step 1:

sudo apt update

Step 2:

sudo apt install codeblocks

Step 3:

sudo apt install codeblocks-contrib

Done …

Vim Editor Install and CheatSheet

Install Vim

sudo apt update

sudo apt install vim

Vim Cheatsheet

View Cheatsheet from vim.rtorr.com

Configure Vim Editor

Vim can be configured both globally and locally. Globally means for all users (Done using root access). Locally means for current user. Locally configuring is more safe than Globally.

Step 1 :

Go to /home/your_username/ Directory

pwd (To know current directory path)

cd ~/ (To go to /home/your_username/)

Step 2 :

Browse .vim files

ls -a | grep .vim

Step 3 :

Create a file named .vimrc

vim ~/.vimrc Or, vim .vimrc

Step 4 :

Write Configuration in .vimrc file and save it.

To write : ESC -> i

To save : ESC -> :wq

Step 5 :

If .vimrc is written successfully, then you are done.

ls -a | grep .vim Run this to see.

Done. This is how configuration can be added. It can be changed as necessary. My final one (for now) is this:

My Latest Configuration: https://github.com/kawshikbuet17/My-Configuration

To make more configuration go to this link https://dougblack.io/words/a-good-vimrc.html

References : https://linuxhint.com/configure_vim_vimrc/

Bash Terminal Configuration

Bash terminal configuration is stored in .bashrc file located in /home/username/

Add your configurations into this file.

If you accidentally messed with the .bashrc file, you will wish to get the default .bashrc file back. To get back, open your terminal and run the following script.

cp /etc/skel/.bashrc ~/.bashrc

This is not the old .bashrc. This is the default bash file.

/home/usename/.bashrc will only configure user’s configuration. If you want your root user configuration to be the same, add this .bashrc to /root/.bashrc

My Latest Configuration : https://github.com/kawshikbuet17/My-Configuration

--

--