top of page
Recent Posts

Linux basic commands

Updated: Oct 3, 2021

Document Id: RHEL002


In my previous post, I've shown how to install Red Hat Enterprise Linux, in this post I'll explain some basic commands every Linux administrator should know to operate Linux operating system.


Previous post: How to Install RedHat Enterprise Linux 8.2


hostname command, to check server hostname

[root@RHEL82 html]# hostname

RHEL82.localdomain


whoami command, to check login user

[root@RHEL82 html]# whoami

root


uname –a command, to get system identification, mainly kernel version

[root@RHEL82 html]# uname -a

Linux RHEL82.localdomain 4.18.0-193.el8.x86_64 #1 SMP Fri Mar 27 14:35:58 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux


To get installed Red Hat Linux version details

[root@RHEL82 html]# cat /etc/redhat-release

Red Hat Enterprise Linux release 8.2 (Ootpa)


ifconfig command, to check server network interface details

[root@RHEL82 html]# ifconfig


ping command, to check connectivity to the server

[root@RHEL82 ~]# ping 192.168.10.10

PING 192.168.10.10 (192.168.10.10) 56(84) bytes of data.

64 bytes from 192.168.10.10: icmp_seq=1 ttl=128 time=20.8 ms


pwd command

Present working directory, when we first login to terminal we are in user home directory, pwd command shows absolute path of the current directory

[root@RHEL82 ~]# pwd


mkdir command

To create an empty directory

[root@RHEL82 ~]# mkdir newfolder

Output: It will create a directory with name newfolder in the current working directory


To create a directory in the specified location

[root@RHEL82 ~]# mkdir /tmp/newfolder

Output: It will create a directory with name newfolder in the /tmp directory


ls command

List of files and directory

[root@RHEL82 ~]# ls

Output: anaconda-ks.cfginitial-setup-ks.cfgnewfolder


To check list of files and directory in the specified location

[root@RHEL82 ~]# ls /tmp/


To check hidden files and folders

[root@RHEL82 ~]# ls –a


To check all files and folder with associated permission

[root@RHEL82 ~]# ls –la


cd command

Change directory- we use this command to change the working directory location.

Example:

[root@RHEL82 ~]# pwd

/root

[root@RHEL82 ~]# ls

anaconda-ks.cfg initial-setup-ks.cfg newfolder

[root@RHEL82 ~]# cd newfolder/

[root@RHEL82 newfolder]# pwd

/root/newfolder


cd.. (double dot) to go parent directory

Example:

[root@RHEL82 html]# pwd

/var/www/html

[root@RHEL82 html]# cd ..

[root@RHEL82 www]# pwd

/var/www


cd (only cd or cd~) to go home directory from anywhere

Example:

[root@RHEL82 ~]# cd /var/www/html/

[root@RHEL82 html]# pwd

/var/www/html

[root@RHEL82 html]# cd

[root@RHEL82 ~]# pwd

/root


cd – (hyphen) to come back previous working directory

Example:

[root@RHEL82 html]# pwd

/var/www/html

[root@RHEL82 html]# cd

[root@RHEL82 ~]# pwd

/root

[root@RHEL82 ~]# cd -

/var/www/html

[root@RHEL82 html]# pwd

/var/www/html