In this Blog we are going to discuss all the necessary and basic commands which every IT professional working on linux platform should know.
Computer-savvy individuals consider Linux as the best operating system owing its feature of getting customized more easily than its popular counterparts.
To learn better there are screenshot attached with every commands to practice and refer for understanding.
All the files present in the current directory are shown once the ls command was typed in the terminal.
b) Syntax :- ls -ltr filename
command is used to list one file with name mentioned in command.
Here you can see the command gives full detail about the file acadgild.
c)Syntax: – ls –ltr
-l long listing
Command is used to lists in the order of their creation time . list of files and directories contains permissions, links, ownership, group, date, time and file-name .
Snapshot:-Here you can see the list of all files present in the directory arranged in order of creation . Different columns indicate permissions, links, ownership, group, date, time and file-name. For every file all these content are stored in computer by default .
d) Syntax:- ls –lc filename
Here you can see the listing of file in alphabetical order.
e)Syntax:– ls -la
To display all hidden files. All Hidden files are start with DOT(.)
Here you can see all the hidden files present in the current directory. We can notice all file is prefixed with .(dot) which indicates all file are system files, hidden from users.
a)Syntax:- touch <filename>
To create an empty file. Size of file is 0 bytes.
Here file will be generated with name acadgild and will be present in same location until user modifies/deletes it.
b)Syntax: touch f1 f2 f3 f4
Here the command will create 4 files named f1,f2,f3 and f4 at same location in the system.
a)Syntax:- mkdir directoryname
To create a new directory
Here you can see a directory named acadgild is created by the user.
b)Syntax:- mkdir -p d1/d2/d3/d4/…………
-p parent directory
To create a directories & subdirectories recursively
Here you can see several directories and subdirectories are created and given parent permission at a time.
a)Syntax:- rm filename
It is used for to remove a file/files
Here you can see the file f1 is being deleted.
b)Syntax:- rm -rf < filename/directoryname >
To remove files, directories and subdirectories Recursively or Forcefully
Here you can see the the directory which contain data inside will also get deleted by using this -rf along with rm.
c)Syntax:– rmdir < directoryname >
To remove an empty directory
Here you can see directory named sasi is being deleted.
It reflects back the content ,whatever written after echo command.
Here you can see the comment written just after the command echo is printed again i.e anything following the echo command is displayed on the terminal.
b)Syntax:- echo “some content” > filename
To insert text inside a file and will delete all previous data of the file.
Here you can see the statement is redirected to the file acadgild as content and later the content can be printed by cat command.
c)Syntax:- echo “some content” >> filename
Here you can see the statement is redirected to the file acadgild along with the previous data as content and later the content is printed by cat command.
Syntax:- cat filename
To read a file
Here you can see the cat command is used to through all the contents of file to the terminal.
Syntax:- more filename
To read a file page-by-page,
use SPACE-BAR to move for NEXT PAGE
Here you can see the data of /etc/profile is shown page by page. It is used to read long file, with lots of data.
Syntax:- ls –i filename
Each inode stores the attributes and disk block location(s) of the filesystem object’s data
Here you can see for a file(acadgild) one inode will be created and that inode will be associated to file(acadgild).
It shows the information about the users who are logged into the system currently.
Here you can see two user logged in named root and pranu with detail of what date, time and IP they used to log IN.
b)Syntax: who –b
-b indicates the time and date of the last reboot.
To see when the server/system was started.
Here you can see the last time when system started/booted was 29/12 at 12.06 pm.
c)Syntax:- who -r
-r indicates the current run level of the init process
A run level is a state of init and the whole system that defines what system services are operating.
Here you can see the run level is 3
d)Syntax:- who -a
-a lists processes, variables, users, run-levels
Here you can see all the who commands summary at glance.
Can be used in two ways, either way will result change in directory
a)Syntax:- cd <directory name>
Here you can see we entered inside acadgild directory.
b)Syntax:- cd ..
This command is used to exit from a directory.
Here you can see the command brings us one directory prior to where we was.
To display the present Working Directry
Here you can see the path of the current working directory. It is very useful while working on terminal.
To display the current date and time of the system.
Here you can see the current day,month,date and time followed by timing zone and year.
It shows the present month calendar
Here you can see directories named big data, frontend and hadoop is copied when the parent directory is copied
c) Syntax:-cp -f :
-f Unlink. If a file descriptor for a destination file
cannot be obtained, this option attempts to unlink the
destination file and proceed.
d)Syntax:-cp -i :
-i Interactive. cp prompts for confirmation whenever the
copy would overwrite an existing target.
e) Syntax:-cp -p :
it is use to (keep the same detail record of original file)preserve the permission, time, date of source file to target file
f)Syntax:- cp –rpfi <sourcefile> <destinationfile>
Here you can see the the contents of p1 is forcefully pushed into p2 by deleting all the previous data of p2.
a)Syntax:- df -k
-k prints the allocation in Kilobytes
To display/read the free DISK FILES.
It lists file system name, allocated size, used size, available size, used size in %, mounted on.
Here you can see list of all the mounted disk path with actual disk utilization status in detail.
b)Syntax: df -h
-h prints the allocation in human readable format. scaling is done by repetitively dividing by 1024.
To display/read the DISK FILES in format
Here you can see the output is same as previous command but with only one difference the size are displayed in GB and MB which is more comfortable for humans to understand, as storage constraint is negligible in today’s era.
Syntax:- man <command-name>
It displays the full information about the command. Any command detail can be found inside man.
Here you can see the description of a command cat.
Syntax:- which <command-name>
It display where the command is residing
Here you can see cat location is shown as output i.e, cat is being used from /usr/bin/cat .
To find out since how long the server is up & running
Here you can see the server is in running state science 2:14pm for 2 hours and 8 minutes.
To display the present logged in user-id and group-id with username and groupname.
Here you can see the root user is sitting idle for 2 hours and 7 minutes.
The write utility reads lines from the user’s standard input and writes them to the terminal of another user. When first invoked, it writes the message:
Message from sender-login-id (sending-terminal) [date]…
to user. When it has successfully completed the connection,
the sender’s terminal will be alerted twice to indicate that
what the sender is typing is being written to the
To send a message to the user who is using the same system
To see which username you logged in
Here you can see the IP of the server is 192.168.56.24
In windows we use the command in cmd prompt for the same.
The full permission of a file/directory is 7 -7 -7 = rwx -rwx -rwx = ownership -group -other group
x-Execution = 1
so total rwx =7
The maximum permissions for a file is 6 -6 -6 = -rw- -rw- -rw-(- prefixed in owner represents the type; file)
When we create a file the default permissions will 6 – 4 – 4. it Is obtained by reducing umask value to maximum permissions . i.e 666 – 022 = 644 (d prefixed in owner represent the type; directory)
Note: the umask value is 022 by using the below command we can see the command Syntax:- cat /etc/profile
The maximum permissions for a directory is 7 – 7 -7. it is obtained by reducing umask value to maximum permissions. i.e 777-022 = 755.