577, Gold Plaza, Punjab Jewellers, M.G. Road, Opp. Treasure Island Mall

Linux Commands

Linux Commands

  1. ls -l for listing the files as well as directories those are kept in the particular working directory

[[email protected] ~]# ls –l

  1. ls -la same as ‘ls -l’ but by this command we can also see the hidden files

[[email protected] ~]#ls –la

  1. ls -li same as ‘ls -la’ but it will also shows us the inode number of each and every file

[[email protected] ~]#ls –li

  1. ls by this command we can see only file name nothing else

[[email protected] ~]#ls

  1. clear it will clear the screen ( short cut ctl + l )

[[email protected] ~]#clear

  1. exit to end a current session as well current terminal logging

[[email protected] ~]#exit

  1. touch to create a new empty file

[[email protected] ~]#touch myfile.txt

  1. cd to change the working/present directory

[[email protected] ~]#cd /home/sachin

  1. cat to view the contents of a file and it is also used for creating a new file with some contents

[[email protected] ~]#cat <file name> to view file contents

[[email protected] ~]#cat > newfilename enter, then you can write something in the file and then to save the file contents press clt+d then enter


  1. mkdir to make a new directory

[[email protected] ~]#mkdir newdirname

you can also create a directory at your desired path without changing your present working directory

[[email protected] ~]#mkdir /home/sachin/newdirname

  1. rm to remove a empty file

[[email protected] ~]#rm filename

  1. rmdir to remove a empty directory

[[email protected] ~]#rmdir directoryname

  1. rm [-i/-r/-f] to remove a directory with its subdirectories as well as its

files that is to remove a directory which already contains some files in it

[[email protected] ~]#rm -i directory/filename

-i stands for interactively

-r stands for recursively

-f stands for forcefully

  1. cp to copy something in a destination file or directory

[[email protected] ~]#cp sourcepath destinationpath

[[email protected] ~]#cp /home/sachin/webmin.rpm /root/abcd


in this example the webmin.rpm file will be copied in

/root/abcd directory

  1. mv to move one file or directory from one place to another place, it is also used for renaming adirectory or file

[[email protected] ~]#mv source destination

[[email protected] ~]#mv oldfilename newfilename [to change the file name]


  1. man to view the mannual page of commands for syntax

[[email protected] ~]#man commandname

  1. info to view the information about any command

[[email protected] ~]#mkdir info

  1. –help to view the help doccuments of a command

[[email protected] ~]#commandname –help

  1. dir to view the subdirectories and filesn under the directory

[[email protected] ~]#dir

  1. who by this command you can see the user name and their ip addresses who have loged in on your server

[[email protected] ~]#who

  1. whoami this command shows your current logged in terminal user name

[[email protected] ~]#whoami

  1. who am i this command shows you the logged in terminal number and user name and more detailed information

[[email protected] ~]#who am i

  1. pwd to view the present working directory

[[email protected] ~]#pwd

  1. rpm -ivh to intall a rpm package

[[email protected] ~]#rpm -ivh packagename.rpm

rpm stands for ‘redhat package manager’

-i stands for install

-v stands for verbose mode

-h stands for with hash sign(#)

  1. rpm -q to querry about any rpm package

[[email protected] ~]#rpm -q packagename

  1. rpm -e to uninstall a rpm package

[[email protected] ~]#rpm -e package

  1. find / -name to find any file or directory in linux file system

[[email protected] ~]#find / -name filename

  1. su username to switch from one user to another users home directory

[[email protected] ~]#su sachin

  1. su – username to switch from one user to another user users home directory directly

[[email protected] ~]#su – sachin

  1. useradd to create a new user

[[email protected] ~]#useradd username

  1. passwd to give a password of a user

[[email protected] ~]#passwd sachin

give a password for user sachin:(here you have to type a password for sachin user) Confirm password:(again type the same password)

  1. userdel to remove a user from linux

[[email protected] ~]#userdel sachin

  1. groupadd to add a new group

[[email protected] ~]#groupadd groupname

  1. gruopdel to delete a group

[[email protected] ~]#groupdel groupname

  1. chown to change the ownership of a file or directory

[[email protected] ~]#chown ownername filename

  1. chgrp to change the group ownership of a file or directory

[[email protected] ~]#chgrp newgroupownername filename

  1. usermod to modify the user profile

[[email protected] armourinfosec ~]#usermod -parameter groupname username

Leave a comment

WhatsApp us