Basic Linux Commands

– Getting to know about the basic Linux commands is a good start to learn it.

– As Linux is preferably administered by the “command line” mode, to know about its commands is the necessity to master it.

– In Linux there are thousands of commands available, we will look into few of the basic commands.

– We have categorized the commands into following sections for better understanding. It will not be difficult to grasp them if you are aware of MS-DOS commands.

– We have covered nearly 60 commands below.



Basic File/Directory Commands
______________________________________________

– We have covered few file & directory related commands, so as to make you aware of basic file and directory management things, so that you can do simple stuff efficiently.


1. dir – Used to list directory contents

              e.g. # dir (it will list the directory contents) 


2. touch – To create an empty file or to update the access time for file.

              e.g.  # touch file1
                     # touch 

  


3. mkdir -To make the directory

              e.g. # mkdir /mike 

  


4. cat – To view the file contents or to concatenate files and print.

              e.g.  # cat file1
                     # cat file1 file2 


5. cp – To copy the file

              e.g.  # cp /tmp/file1 /root/file1 


6. mv – To move file from one place to another

              e.g. # mv /tmp/file1 /root/file1 

  


7. rm – To remove/delete the files

              e.g.  # rm file1
                     # rm file1 file2 

  


8. rmdir – To remove the directory

              e.g.  # rmdir 

  


9. more – To view file in page wise in forward direction

              e.g.  # more file1 

  


10. less – To list the contents of file page wise

              e.g.  # less file1 

   


11. head – Show selected starting lines from file

              e.g.  # head file1
                     # head -n 20 file1  

  


12. tail – To show selected lines from end of the file

              e.g. # tail file1 

  


13. rename – To rename a file

              e.g.  # rename file1 file2 

  


14. vi -vi editor, to edit files

              e.g. # vi file1 

  


15. wc – To get the content statistics about file, like no. of lines, no of bytes etc

              e.g.  # wc -l file1
                     # wc -c file1 

   


16. zip – To compress a file

              e.g.  # zip file 

   


17. cd – To change the current working directory

              e.g.  # cd
                     # cd /root 

  

Getting to know


18. logname – Print users login name.

              e.g.  # logname 


19. cal – Calendar

              e.g.  # cal
                     # cal 2001
                     # cal 5 


20. date – Date of the system

              e.g.  # date 


21. ddate – To converts Gregorian dates to Discordian dates

              e.g.  # ddate 


22. id – print real and effective user and group IDs

              e.g.  # id root
                     # id -a root 


23. finger – Its user information lookup program

              e.g.  # finger root
                     # finger mike


24. w – Show who is logged on and what they are doing.

              e.g.  # w
                     # w -h
                     # w -u 


25. who – show who is logged on.

              e.g.  # who
                     # who -all 

  


26. whoami – Print effective userid.

              e.g.  # whoami 

   


27. last – Show listing of last logged in users.

              e.g.  # last 

  


28. lastlog – reports the most recent login of all users or of a given user

              e.g.  # lastlog 

   


29. file – Determine File type

              e.g.  # file file1.txt 

  


30. hostname – Show or set the system host name

              e.g.  # hostname 

   


31. mail – Send and receive Internet mails.

              e.g.  # mail
                     # mail -u root 

   


32. uptime – Tell how long the system has been running.

              e.g.  # uptime 

   


33. ls – To list the present directory

              e.g. # ls
                     # ls -l
                     # ls -lh 

   


34. df – Report file system disk space usage

              e.g.  # df
                     # df -h 

   


35. logname – print user’s login name

              e.g.  # logname 

   


36. free – Display amount of free and used memory in the system

              e.g.  # free
                     # free -m -t 

   


37. pinky – Its a lightweight finger

              e.g.  # pinky root
                     # pinky -l root 

  


38. stat – Display file or file system status

              e.g.  # stat file1 

  

To Get Help – Commands


39. –help  – To display helpful info about commands

              e.g.  # ifconfig –help
                     # ls –help
                     # w –help 


40. info – Read info doc

              e.g.  # info ls
                     # info who
                     # info ifconfig 


41. man – To format and display the on-line manual pages

              e.g.  # man ls
                     # man w
                     # man ifconfig 


42. whatis – search the whatis database for complete words

              e.g.  # whatis ls
                     # whatis w
                     # whatis who 


43. whereis – locate the binary, source, and manual page files for a command

              e.g.  # whereis who
                     # whereis ls
                     # whereis uptime 

  


44. which – shows the full path of (shell) commands

              e.g.  # which ls
                     # which who
                     # which uptime 

  

Miscellaneous Commands


45. history – Display users command history

              e.g. # history
                     # history -c (To clear the history) 


46. find – search for files in a directory hierarchy

              e.g.  # find / -name santosh 

  


47. locate – Find the files

              e.g. # locate santosh

  


48. poweroff – To stop the system

              e.g.  # poweroff
                     # poweroff -f (Forcefully) 


49. shutdown – To bring the system down

              e.g.  # shutdown
                     # shutdown -r (reboot) 

  


50. halt – To bring system down

              e.g.  # halt 

   


51. reboot – To reboto the system

              e.g.  # reboot 

   


52. logout – To logout from the current session

              e.g.  # logout 

   


53. exit – To close the current session

              e.g.  # exit 

   


54. lpq – show printer queue status

              e.g.  # lpq  (Should have defaulf printer configured) 

   


55. cancel – Cancel print jobs

              e.g.  # cancel 1
                     # cancel -U root 1 

  


56. passwd – To change user password

              e.g.  # passwd (To change self password)
                     # passwd mike (To change santosh’s passwd) 

  


57. ping – send ICMP ECHO_REQUEST to network hosts, to see other host responding or not

              e.g.  # ping 192.168.222.111 

   


58. runlevel – To see the cureent runlevel

              e.g.  # runlevel 

   


59. sort – To sort the command outputs

              e.g.  # cat file1 | sort
                     # ls -l | sort 

   


60. su – To switch to another user

              e.g.  # su –  (To switch to root)
                     # su – mike (To switch to mike) 

  


– Now you will feel somewhat comfortable after logging into Linux machine. 

Leave a Reply

Your email address will not be published. Required fields are marked *