Home Linux 17 Linux Basic Commands with Examples

17 Linux Basic Commands with Examples

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.
Firstly, I will explain to you the commands which won’t affect the Linux server. These commands are performed to check the information on the server.

Commands To Display Information on Terminal

1. ifconfig –  To check the IP address of the Linux system.

[arun@localhost ~]$ ifconfig
ifconfig command in Linux
ifconfig command in Linux

2. pwd – To check the present working directory.

[arun@localhost ~]$ pwd
pwd command
pwd command

3. free – Memory utilization checked by this command.

[arun@localhost ~]$ free                //by default output in kilobytes
 [arun@localhost ~]$ free -m          //shows output in megabytes 
Check Memory utilization on linux
Check Memory utilization on Linux

4. ls –  shows the files and directories of the present directory.

[arun@localhost ~]$ ls
ls output
ls output

5.  ll Command – This output shows the file permission, owner, group, size of the directory and the file.

[arun@localhost ~]$ ll
ll command output
ll command output

6. who – This command is used to check the currently logged user into the system.

[arun@localhost ~]$ who
who command
who command

7. df – Shows the used & available hard disk space.

[arun@localhost~]$  df 

To check hard disk space in gigabytes or megabytes use the -h option with df command.

[arun@localhost~]$  df  -h
df command output
df command output

8. top – This displays the currently running processes on the system.

[arun@localhost ~]$  top
top command result
top command result

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/ 
cd command
cd command 

10. cat – Very helpful command to view the content of the file. Here, want to see the content of the file.text file.

Syntax is:    cat [file name]

[arun@localhost ~]$  cat file.text 
cat command output

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  
history command result
history command result

12. clear – It is used to clear the terminal screen. Two screenshots are uploaded before and after executing the clear command.

[arun@localhost ~]$  clear
clear command in Linux
clear command in Linux
clear command output
After clear command output

Now will share the commands which affect the system, please be careful with these commands.

Linux Commands which Affects System

13. touch – This command is to create new files. Here creating a file with the name “myfile”.

[arun@localhost ~]$  touch myfile
touch command output
touch command output

14. mkdir – Creates a new directory using this command. For example, we are going to create a directory with the name “linux”.

[arun@localhost ~]$  mkdir linux
Create directory with mkdir command
Create directory with mkdir command

15. rmdir – This commands only removes an empty directory. For example, remove empty directory “linux” from the system.

[arun@localhost ~]$  rmdir linux/
rmdir command in Linux
rmdir command in Linux

16. rm – To remove a directory which contains data, use this command. For example, directory “centos” which contains files and directory.

[arun@localhost ~]$  rmdir linux
rmdir command
rmdir command

17. mv – mv is the multi-purpose command, can move and also used to rename files or directory.Here linux directory moving to /home/arun/Desktop/.
                              
Syntax is:   mv   [source file]  [destination path]

[arun@localhost ~]$  mv    linux/     /home/arun/Desktop/     
mv command to move files or directory
mv command to move files or directory

To rename files or directory, remain in the same directory. For example, here we are renaming linux directory to centos.

[arun@localhost ~]$ mv  linux/  centos
mv command used to rename a file
mv command used to rename a file



Congratulations !!! you have learned the 17 Linux Basic Commands with Examples.

LEAVE A REPLY

Please enter your comment!
Please enter your name here