In the previous tutorial, we have learned Installation of CentOS 7 with Screenshots . Now in this tutorial you will learn the 17 linux basic commands with examples, which are very necessary for everyone.
Initially, I will explain you the commands which won’t affect the linux server.These commands are performed to check the information on server.
1. ifconfig – To check the IP address of the system.
[arun@localhost ~]$ ifconfig
2. pwd – To check the present working directory.
[arun@localhost ~]$ pwd
3. free – Memory utilization checked by this command.
[arun@localhost ~]$ free //by default output in kilobytes
[arun@localhost ~]$ free -m //shows output in megabytes
4. ls – shows the files and directories of the present directory.
[arun@localhost ~]$ ls
5. ll – This output shows the file permission, owner, group, size of the directory and the file.
[arun@localhost ~]$ ll
6. who – This command is used to check the currently logged user into the system.
[arun@localhost ~]$ who
7. df – Shows the used & available hard disk space.
To check hard disk space in gigabytes or megabytes use -h with df command.
[arun@localhost~]$ df -h
8. top – This displays the currently running processes on the system.
[arun@localhost ~]$ top
9. cd – To change the current directory, use this before destination directory. Let us suppose want to change directory to Desktop then,
Syntax is: cd [destination path]
[arun@localhost ~]$ cd Desktop/
10. cat – Very helpful command to view the content of the file.Here, want to see the content of file.text file then,
Syntax is: cat [file name]
[arun@localhost ~]$ cat file.text
11. history – As the name suggests, to check the history. Yes, this will display the list of the commands executed by the present user since the session started.
[arun@localhost ~]$ history
12. clear – It is used to clear the terminal screen. Two screenshots are uploaded before and after executing clear command.
[arun@localhost ~]$ clear
Now I will share the commands which affect the system, please be careful with these commands.
13. touch – This command is to create new files.I want to create file with the name “myfile”, then command would be:
[arun@localhost ~]$ touch myfile
14. mkdir – Creates new directory using this command. For example, we are going to create directory with name “linux”, then :
[arun@localhost ~]$ mkdir linux
15. rmdir – Removes only empty directory. Now remove empty directory “linux”.
[arun@localhost ~]$ rmdir linux/
16. rm – To remove directory which contains data, use this command.Now lets assume directory “centos” which contains files and directory.
[arun@localhost ~]$ rmdir linux
17. mv – mv is
Syntax is: mv [source file] [destination path]
[arun@localhost ~]$ mv linux/ /home/arun/Desktop/
To rename files or directory, remain in same directory. For example here we are renaming linux directory to centos.
[arun@localhost ~]$ mv linux/ centos
Congratulations !!! you have learned the 17 linux Basic Commands with Examples.