Basic Linux
operations
Basic Linux Operations
#sudo –i
To gain root access of the server.
#pwd
To know the “present working directory”
#ls –ltr
To have a long list of the contents in reverse time order
#ls –la
To show the hidden files or folders
Basic Linux Operations
Understanding the listed contents:-
drwx------ 2 root root 23 Jul 20 01:22 audit
-rw------- 1 root root 15936 Jul 23 18:32 [Link]
-rw------- 1 root utmp 59520 Jul 23 19:37 btmp
lrw------- 1 root root 5 Jun 30 21:21 nmtui-connect -> nmtui
File perm, Owner, Group, Size(bytes), Date, Time, filename
Interpretation of permission:-
→The first letter denotes if it is a ‘d’ for directory, ‘l’ for link, ‘-‘ for file.
→The next set of three letters rwx denotes the read, write, and execute permission for the owner of the file
→The next set of three letters rwx denotes the read, write, and execute permission for the group
→The next set of three letters r-x denotes the read and execute permission for other (everyone else) who is not the owner of
the file and nor in the group
- (hypen) in the r-x permission set
means, that specific permission is not
applicable
Basic Linux Operations
→Three different permissions r Read 4
w Write 2
» r is for read permission
X Execute 1
» w is for write permission
» x is for execute permission
Understanding permissions
→Three different roles Directory File
Permission 755 644
» u is for user
drwxr-xr-x -rw-r--r--
» g is for group Symbolic UGO UGO
» and o is for others
#chmod 644 <filename>
To change the permissions of the file/directory
#chown <new-user> <filename>
To change the ownership of the file.
Basic Linux Operations
#cd
Change directory – basically to browse within the folders
/
#cd /etc #cd /usr #cd /var/log
#pwd #pwd #pwd etc usr var
/etc /usr /var/log
#cd ssh
#pwd [Link] bin tmp
/etc/ssh
[Link] lib log
ssh [Link] adm
Basic Linux Operations
#cat <filename>
To show the contents of the file
#more <filename>
To get the contents – one page at a time (spacebar for next page)
#grep
To search a keyword (-i ignore case, -v omit string)
#ls –ltr | grep <string>
Here | is used for combining the two commands
#free -h
To check memory (RAM) status
#df –kh
To check the disk (HDD) status
Basic Linux Operations
VI/VIM editor in Linux:-
#vi/vim <filename>
To create a new file OR to edit an existing file
Press “a” →to append i.e. to start adding your text. When you’re done then
Press “Esc” →to come out of the append mode
Shift+; →to come to the end of the file
wq! →to save & quit the file
q! →Do not save, just quit the file
/<string> →to search a string within the file using vi editor
n →next result of the search
#touch <filename> → to create an empty file
Basic Linux Operations
#cp <source> <destination>
To copy the file
#cp –r <source> <destination> r=recursive
To copy all the contents of a directory
#mv <source> <destination>
To move the file
#rm <filename>
To remove/delete the file
#mkdir <directory name>
To create a new directory
#rmdir <directory name>
To remove/delete a directory