30 Most Frequently Used Linux Commands With Examples

This blogpost gives a list of 30 Most Frequently Used Linux/Unix Commands With Examples. I tried to list out the most frequent commands, which will be useful for any Linux user in day to day life. I have also given examples with each command so that it will be easy for you to understand.

30 Most Useful Linux Commands

 

1. ls Command Examples : 

This is the most frequently used linux command and it list the the current directory.

ls without any option list the current working directory

By default ls without option won’t show the hidden files, to view the hidden files type

to list files in Human Readable Format use the option -lh

to list files ordered by Last Modified Time use option -ltr

2. cd Command Examples

to change the directory in linux  we use cd command

to goto one level up use cd .. command

3. man Command Examples

sometimes you remember the command but forgot the options available with it, man command helps you here. It will show the manual of the command and list out all the options available with that command. Lets check ls command manual

it will show you all the options and their uses, to exit from man press q.

4. cp Command Examples

The cp command is  used to copy one file to other

using cp with -p option will preserve the mode, ownership and time. using cp with -i option will prompt for overwriting the file.

5. mv Command Example

The mv command is used for move operation from one location to other.

to move the file from one location to other use command

it also acts as a rename command and to do that type

above command will rename the file1 to file2

6. mkdir Command Example

In Linux/Unix we use mkdir command to create new directory, but to do that you must have write permission.

if you need to create nested directory then you can use mkdir -p command

 7. chmod Command Example

chmod command is used to set the permission on files or directory or alter previously set permission. Permission can be set using symbolic or octal codes.

to add read, write and execute permission for file we can do this by

to add read and write permission to any directory we can do this by

 8. date Command Example

date returns the current date and time of the system

We can also format the output of date command like this

 9. file Command Example

Some times you need to know the type of any file or what type of data it contains then you can use file command.

 10. tar Command Example

To compress a file you can use tar command.

above command will create a archive demo.tar with contents of temp directory. To see the content of tar archive use this  option

to extract the content of archived file use xf option. Here x means extract and f means file. It will copy the content of archive in current directory.

 11. grep Command Example

Some time you need to search with a pattern because you forgot the file name but partially you remember, in that case you can use grep command.

In above example output will come with is highlighted in red. With grep you can search in multiple file for the same pattern

Also if you need to search for word codingbyte in all the available files which name is starting with a and are present in current directory type this.

 12. ssh Command Example

ssh command is used to login to remote host securely. It provides encrypted communication between client and host.

 13. rmdir Command Example

To remove a directory you can use rmdir command. The directory you are removing must be empty.

If you need to deleted a directory which is not empty you can use option -r with rmdir

 14. rm Command Example

rm Command is used to remove a file or directory. To remove a file you must have write permission on the directory where file reside.

Before deleting if you want a confirmation then you can use -i option

to remove a directory and all the contents of it, you can use -r option

Above command will first recursively delete the all the files from directory and sub directory and then delete the temp directory itself.

15.pwd Command Example

pwd command will show the current working directory of logged in user

 16. ps Command Example

ps command is used to check the current running processes on the system. It will list out the process id and other detail of the process.

To see the full detail of processes use the option fu with ps

17. passwd Command Example

If you need to change the password then you can use passwd command.

 18. more Command Example

Suppose you want to open a big file and read it page by page, this you cannot do with cat command. more command allow you to read a big file one page at a time. To quit before reaching end of file press q

19. kill Command Example

To kill a running process you can use kill command, this command requires process id and that you can get from ps command.

 20. lpr Command Example

To send the content of a file to print use lpr command.

Here printer1 is the name of printer and file1 is the file you are going to print.

21. gzip Command Example

gzip command is used to create .gzip compressed file.

To uncompress the above file use below command

 22. unzip Command Example

To uncompress the .zip file use unzip command

It is also possible to see the content of zip file without uncompressing the file

 23. shutdown Command Example

To turn off your system of schedule the turnoff you can use shutdown command

Above command will turn of the system instantly. To schedule the turnoff after 20 minutes use below command

to reboot the system you can use below command

 24. free Command Example

To check the usage of memory you can use free command. It will show the free memory, used memory and swap memory .

You can format the memory display using  -b, -k, -m and -g .

 25. top Command Example

To see the top processes from the system use top command. It will show the list sorted by cpu usage

 26. df Command Example

df command is used to see the disk usage of filesystem.

We can format the output  using -h option, it will show the output in human readable format.

 27. whereis Command Example

To search the location of a specific linux command or a specific name  you can use whereis command.

 28. whatis Command Example

As name suggest whatis command will show one line description of any command .

 29. tail Command Example

Suppose you want to see the last few lines of the file then you can use tail command. By default it will show 10 lines.

you can also define how many lines you want to see by using -n option. In below command it will show the N lines from the tail of the file1.

 30. wget Command Example

wget is used to download the software and other files from the internet. In my last post How To Install WordPress on Ubuntu VPS i have used this command to download the wordpress setup file from wordpress server.

I have tried my best to list out the 30 Most Frequently Used Linux Commands and given their example. Please give your suggestion in the comment and also share the post.

10
SHARES

Related Post

5 Comments


  1. This is good for basics can you made a video tutorial for it

    Reply

    1. These are very basic commands which you will find in your day to day life, anyway i will try to make a video tutorial also

      Reply

  2. Is is fine. But I didn’t get the details of “cp” command. Can you elaborate it ?

    Reply

    1. cp command is used to copy a file to another file, one or more files to a directory, or for copy entire directories to another directory. let me know if you need more detail.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *