This article will help to for most frequently used commands in Linux operating system, You can bookmark this article for future reference. If you think I miss any of common command please leave a comment so I will add in this list.
ls command display the list of directories and files on terminal.
And if you use some more option with ls command then it will give result with more human readable format, we will see it as below:
This command will be easier to read the format as it will give result with KB or MB
$ ls –lh
You can order files based on last modification (here we can say reverse order) as below :
$ ls –ltr
The full form of pwd is “Print Working Directory” that means it will display the current working directory you are on.
The full form of cd is “Change Directory” that means you can change the working directory using command on terminal.
$ cd /home/ubuntu
free command is used to display total memory, free memory, used memory, shared memory, buffer memory, cached memory and swap member on terminal
If you would like to diplay memry in kb,mb, gb then you can use following command :
For GB :
$ free –g
$ free –m
$ free –k
And if you would like to display total memory including swap memory then use –t.
$ free –t
The full form of df is Display File system. This will display the disk space usage.
To display output in human readable form use –h along with df command.
$ df –h
If you want to see df command display filesystem as well then use –T along –h with it as below:
$ df –hT
This command will help you to copy files/folder to another place
$ cp <source> <Destination>
If you want to copy folder with recursive permission then use –r
cp –r folder1 folder2
mv command is useful for move/rename files or folder
$ mv folder1 folder2
cat commend is helpful to print content of the file
or you can display/print multiple files on screen using below command
$ cat file1 file2
if you want to display file by line number then use below command
$ cat –n files1
This command is useful to create file at the required location.
$ touch /home/ubuntu/folder1/file4.txt
it will create the file4.txt
To change password using command use below method.
Above command will change the password of current logged in user.
If you want to change password of particular user then use below command:
$ passwd <USERNAME>
Remove password for a specific user.
$ passwd –d <USERNAME>
To create directory use mkdir command:
$ mkdir foldername
chmod command is to change the permission of the file or directory.
To give full access to group as well as user (READ, WRITE, EXECUTE) use below command:
$ chmod 777 filename.txt
To apply permission recursively on file use –R.
$ chmod –R 777 folder
chown is command to change owner and group of the file or directory.
For example: chown USERNAME:GROUPNAME FILENAME
$ chown ubuntu:ubuntu file1.txt
You can use –R to change ownership recursively.
$ chown –R ubunut:ubuntu folder
$ whereis top
$ adduser USERNAME
$ usermod -aG sudo USERNAME