Most used and handy Linux commands (part_2)

Longtime ago in a post I introduced 10 first basic Linux command and there I mentioned that the tutorial would be published in series. Now this post is the second part of that series which is named “Most used and handy Linux commands part_2”. In this post I introduced ten more Linux commands here. The list of commands which are covered here are as following:

  1. whoami
  2. !!
  3. uname
  4. history
  5. less
  6. more
  7. ping
  8. df
  9. mkdir
  10. rmdir

WHOAMI

In order to know that name of the current user just you need to type the following command.

$ whoami

The output of the command should be something like below,

Kasra

This command has no further option and it is usage is very simple. It just returns the current name of the logged (active) user.

!!

The usage of this command is really simple. Actually, with running this command, the latest command before “!!” will be executed again. In order word “!!” command just runs the last command of the history.

UNAME

Simple this command gives some information about the system and Linux version based on the set arguments. Running “uname” command without any parameter just returns “Linux”.

For instance, for knowing the current version of the kernel type the following line,

$ uname -r

Sample output,

3.2.0-43-generic

In order to know about the architecture of your system or in other word architecture of your Linux distribution types the following command,

$ uname -m

Example output

x86_64

For getting all information about your Linux distribution and your device type,

$ uname -a

Output should be like this

Linux ubuntu 3.2.0-43-generic #68-Ubuntu SMP Wed May 15 03:33:33 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Uname command has many parameters and those parameters can be found in its man page.

HISTORY

This command shows the history of the XX number recent commands which you have run them. XX could be 100, 200, etc. based on your bash setting that for example saves just recent 100 commands.

In order to getting for example just 10 recent commands type the following line,

$ history 10

LESS

The use of “less” command is simple. Many times happens when you get the list of something or see the output of a command it cannot be fitted into one page. It means that the output is more than a page and you just can see the last page because the previous page is already scrolled. Therefore, for making output going further when display is fulled with output you can use less alongside with your command. This task is known as pipelining in Linux which needs separate post to explain about it. But now just you need that pipelining is used to feed the output of a command as input to another command. The sign of pipelining is ‘|’. Take a look at the following example for pipelining the output of “ls” command to “less” command in order to avoid page auto scrolling.

$ ls | less

Now with pressing enter you can scroll line by line until you reach to the end. For quiting scrolling just press ‘q’.

MORE

In simple manner the usage of more is like “less” as well.

Note: up to now that I worked with Linux I did not find the significance difference between “less” and “more” commands.

PING

The usage of this command is the same as Windows ping which means that it is utilized mostly for networking tasks. One simple usage of ping is to know that do you have access to the internet with pinging a website such as follow

$ ping http://www.google.com

For more information about ping please refer to its man page.

DF

This command is used to show available free size of mounted disk(s).

As you can see the first column shows filesystem names and the second capacity in Kilobytes and so on. The point here is that the capacity shows in Kilobytes which for todays usage is too low. Therefore, it is better to show the disk(s) capacity, used space, and available space in other form like Gigabytes. So you can add ‘-h’ option to “df” command like below,

$ df -h

MKDIR

This command is used to make directory(folder). The usage of the command is like following,

$ mkdir testFolder

RMDIR

In order to remove a directory, you can use “rmdir”. Bear in mind that the directory must be empty otherwise, the system prompts error regarding that.

More information can be found in this website.

send your idea and information to kasra.madadipouya@geeksweb.tk

Leave a Reply