Skip to main content

Advancing with the terminal

Advancing with the terminal
In the previous post we discussed about the basics of the terminal. In this post I will tell you about advanced commands that can be used in the terminal.
System Information Commands:
These commands are used to know information about the system. 
  •     df:      The df command displays file system usage for all the mounted partitions.
df –h produces a more readable output in Megabytes (M) and Gigabytes (G). [-h means human-readable].
  • ¨    du :  The ducommand displays the disk usage for a directory. For more readable output you can use du –sh.
  • ¨    free : The  freecommand displays the free and used memory in the system.
Free –m will give the output in Megabytes which is more readable.
  • ¨    top : The topcommand  displays information on your Linux system, running processes and system resources, including CPU, RAM & swap usage and total number of tasks being run. To quit it you can press “q”.
  • ¨    uname –a : The unamecommand prints all system information, including machine name, kernel name and version, and a few other details.
  • ¨    lsb_release –a : The lsb_release command prints version information for the Linux release you're running.


If you tried copying commands and pasting in terminal using ctrl+c and ctrl+vyou might have noticed that pasting won’t work using ctrl+v. To paste into a terminal you can use ctrl+shift+v.
You can also do Middle Button Click on your mouse (both buttons simultaneously on a two-button mouse).
You can also right-click and select paste from the menu.

Up Arrow or CTRL+P
Scrolls through the commands that you've entered previously.
Down Arrow or ctrl+n
Takes you back to a more recent command.
When you have the command you want.
It autocompletes any commands or filenames, if there's only one option, or else gives you a list of options.
Searches for commands you've already typed. When you have entered a very long, complex command and need to repeat it, using this key combination and then typing a portion of the command will search through your command history. When you find it, simply press Enter.
The history command shows a very long list of commands that you have typed previously. Each command is displayed next to a number. You can type !x to execute a previously typed command from the list (replace the X with a number). If you history output is too long, then you can use history | less for a scrollable list.

ctrl+a or Home
Moves the cursor to the start of a line.
ctrl+e or End
Moves the cursor to the end of a line.
Moves to the beginning of the previous or current word.
Deletes from the current cursor position to the end of the line.
Deletes from the start of the line to the current cursor position.
Deletes the word before the cursor.
Goes back one word at a time.
Moves forward one word at a time.
Capitalizes letter where cursor is and moves to end of word.

Incremental history searching

This is a very useful feature. Many agree that this is the most useful terminal tool saves you a lot of typing/memorizing. This tool is like the autocomplete feature for the terminal but this is for only previously entered commands.
To use this tool follow these instructions.
Open a terminal and type:
gedit  ~/.inputrc

Then copy and paste the following:
"\e[A": history-search-backward
"\e[B": history-search-forward
"\e[C": forward-char
"\e[D": backward-char

And save. While entering a command just type the first two or three letters and press up arrow and it will complete the command for you!

Popular posts from this blog


Most of you who have a Huawei USB modem (data card) might have tried to install mobile partner (dash board) in Linux. Here I will show you how to install mobile partner in Linux. First, you have to copy the folder called Linux in the data card. The files in the data card are not accessible from Linux so copy them from Windows. Now right click the file “install” in the “Linux” folder. Go to the permissions tab and select the check box beside Allow executing as a program. Now open a terminal by pressing CTRL + ALT + Tkeys. Change the working directory to the folder “Linux” by using “cd <path to folder>”. Now type ./install. If you had installed this software in your system before, you will get a prompt: "The software is exist, do you want overwrites? ([Y]/[N])", enter "y" to overwrites or "n" to exit. If you do not had installed this software in your system before, you will get a prompt: "Please input the install path[/usr/local/Mobile_Partner]:"…

How to setup a wifi-hotspot in Ubuntu: The terminal way.

Ubuntu has a "Use as hotspot" mode. But it creates a n ad-hoc network only.Wireless hotspots aren't same as ad hoc networks. Significant difference is there. In short, ad hoc networks aren't supported in most Android, Windows Phone and Blackberry devices (and may be iOS devices too) whereas AP mode Wi-Fi hotspots are.

              It is really simple and easy to setup a hotspot in Ubuntu. We use a tool called ap-hotspot. To install it open a terminal and type the following:

sudo add-apt-repository ppa:nilarimogard/webupd8 sudo apt-get update sudo apt-get install ap-hotspot
             Next, to start the hotspot type the following in a terminal:
sudo ap-hotspot start
It asks you which adapter's internet you want to share, name of the network, password, etc. in an interactive manner. To stop the hotspot type the following n the terminal :
sudo ap-hotspot stop
To configure it type the following in the terminal :
sudo ap-hotspot configure

Unable to lock the administration directory (/var/lib/dpkg/) is another process using it?

Some times we get the following error while trying yo install software using apt-get or synaptic packaging manager.
E: Could not get lock /var/lib/dpkg/lock - open (11 Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/) is another process using it?

How can we resolve this?
The problem occurs if we are running another applications like synaptic using the directory. So, if this is the case close the applications and try run the command again.
You will also get this message if you forget to use  sudo  when executing an apt command. You can use sudo lsof /var/lib/dpkg/lock to find the process that owns the lock file Then try to kill the process to remove the lock.
This should be used as last resort. If you use this carelessly you can end up with a broken system.
You can delete the lock file with the following command:
sudo rm /var/lib/apt/lists/lock

You may also need to delete the lock file in the cache directory.
sudo r…