Basic Commands
The basic commands that any linux user must know
pwd
to view the present working directory
Syntax
[root@bOtskOOl root]#pwd
cd
to change the working/present directory
Syntax
[root@bOtskOOl root]#cd /home/student
where '/home/student' is the desired directory to be change from '/root'
ls -l
for listing the files as well as directories those are kept in the particular working directory
Syntax
[root@bOtskOOl root]#ls -l
ls -la
same as 'ls -l' but by this command we can also see the hidden files.
Syntax
[root@bOtskOOl root]#ls -la
ls -li
same as 'ls -la' but it will also shows us the inode number of
each and every file
Syntax
[root@bOtskOOl root]#ls -li
ls
by this command we can see only file name nothing else
Syntax
[root@bOtskOOl root]#ls
mkdir
to make a new directory
Syntax
[root@bOtskOOl root]#mkdir newdirname
rmdir
to remove a empty directory
Syntax
[root@bOtskOOl root]#rmdir directoryname
rm
to remove a empty file
Syntax
[root@bOtskOOl root]#rm filename
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
Syntax
[root@bOtskOOl root]#rm -i directory/filename
-i stands for interactively
-r stands for recursively
-f stands for forcefully
cp
to copy something in a destination file or directory
Syntax
[root@bOtskOOl root]#cp sourcepath destinationpath
mv
to move one file or directory from one place to another place, it
is also used for renaming a directory or file
Syntax
[root@bOtskOOl root]#mv source destination
[root@bOtskOOl root]#mv oldfilename newfilename [to change the file name]
touch
to create a new empty file
Syntax
[root@bOtskOOl root]#touch
cat
to view the contents of a file and it is also used for creating a
new file with some contents
Syntax
[root@bOtskOOl root]#cat <file name> to view file contents
[root@bOtskOOl root]#cat > newfilename enter,then you can write something in
the file and then to save the file contents press ctrl+d then enter
clear
it will clear the screen(short cut ctrl+l)
Syntax
[root@bOtskOOl root]#clear
exit
to end a current session as well current terminal logging
Syntax
[root@bOtskOOl root]exit
man
to view the manual page of commands for syntax and usage
Syntax
[root@bOtskOOl root]#man commandname
info
to view the information about any command
Syntax
[root@bOtskOOl root]#mkdir info
--help
to view the help documents of a command
Syntax
[root@bOtskOOl root]#commandname --help
find location_to_search_in -name
to find any file or directory in linux file system
Syntax
[root@bOtskOOl root]#find / -name filename
su –
to become a super user
Syntax
[student@bOtskOOl student]$su -
output wil be
[root@bOtskOOl root#]
su username
to switch from one user to another users home directory
Syntax
[root@bOtskOOl root]#su student
output will be
[student@bOtskOOl root]#cd
[student@bOtskOOl student]#
su - username
to switch from one user to another user users home directory directly
Syntax
[root@bOtskOOl root]#su - student
useradd
to create a new user
Syntax
[root@bOtskOOl root]#useradd username
passwd
to give a password of a user
Syntax
[root@bOtskOOl root]#passwd nitesh
output will be
give a password for user nitesh:(here you have to type a password for nitesh user)
confirm password:(again type the same password)
userdel
to remove a user from linux
Syntax
[root@bOtskOOl root]#userdel nitesh
groupadd
to add a new group
Syntax
[root@bOtskOOl root]#groupadd groupname
groupdel
to delete a group
Syntax
[root@bOtskOOl root]#groupdel groupname
chown
to change the ownership of a file or directory
Syntax
[root@bOtskOOl root]#chown ownername filename
example:
[root@bOtskOOl /]#ls -l
output
drwxrw-rw- 2 root root 4096 Mar 11
(permission) (own) (group own)(size) (name)
[root@bOtskOOl root]#chown nitesh /abcd
in this example /abcd directory owner will be change to nitesh user
effect
[root@bOtskOOl /]#ls -l
drwxrw-rw- 2 nitesh root 4096 Mar 11
chgrp
to change the group ownership of a file or directory
Syntax
[root@nettec root]#chgrp newgroupownername filename
example
[root@bOtskOOl /]#ls -l
drwxrw-rw- 2 nitesh root 4096 Mar 11
[root@bOtskOOl root]#chgrp nitesh /abcd
effect
[root@bOtskOOl /]#ls -l
drwxrw-rw- 2 nitesh nitesh 4096 Mar 11
chmod
to change the permission of a file or directory
Syntax
[root@bOtskOOl root]#chmod value fileordirectoryname
example
[root@bOtskOOl /]#ls -l
drwxrw-rw- 2 nitesh root 4096 Mar 11
[root@bOtskOOl /]#chmod 402 /abcd
[root@bOtskOOl /]#ls –l
drw-----w- 2 nitesh nitesh 4096 Mar 11


Recent comments
13 hours 37 min ago
14 hours 4 min ago
14 hours 50 min ago
14 hours 57 min ago
15 hours 5 min ago