- 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 |
2. mkdir -To make the directory e.g.
# mkdir /mike |
3. cat – To view the file contents or to concatenate files and print. e.g.
# cat file1 # cat file1 file2 |
4. cp – To copy the file e.g.
# cp /tmp/file1 /root/file1 |
5. mv – To move file from one place to another e.g.
# mv /tmp/file1 /root/file1 |
6. rm – To remove/delete the files e.g.
# rm file1 # rm file1 file2 |
7. rmdir – To remove the directory e.g.
# rmdir |
8. more – To view file in page wise in forward direction e.g.
# more file1 |
9. less – To list the contents of file page wise e.g.
# less file1 |
10. head – Show selected starting lines from file e.g.
# head file1 # head -n 20 file1 |
11. tail – To show selected lines from end of the file e.g.
# tail file1 |
12. rename – To rename a file e.g.
# rename file1 file2 |
13. vi -vi editor, to edit files e.g.
# vi file1 |
14. wc – To get the content statistics about file, like no. of lines, no of bytes etc e.g.
# wc -l file1 # wc -c file1 |
15. zip – To compress a file e.g.
# zip file |
16. cd – To change the current working directory e.g.
# cd # cd /root |
Getting to know:
17. logname – Print users login name. e.g.
# logname |
18. cal – Calendar e.g.
# cal # cal 2001 # cal 5 |
19. date – Date of the system e.g.
# date |
20. ddate – To converts Gregorian dates to Discordian dates e.g.
# ddate |
21. id – print real and effective user and group IDs e.g.
# id root # id -a root |
22. finger – Its user information lookup program e.g.
# finger root # finger mike |
23. w – Show who is logged on and what they are doing. e.g.
# w # w -h # w -u |
24. who – show who is logged on. e.g.
# who # who -all |
25. whoami – Print effective userid. e.g.
# whoami |
26. last – Show listing of last logged in users. e.g.
# last |
27. lastlog – reports the most recent login of all users or of a given user e.g.
# lastlog |
28. file – Determine File type e.g.
# file file1.txt |
29. hostname – Show or set the system host name e.g.
# hostname |
30. mail – Send and receive Internet mails. e.g.
# mail # mail -u root |
31. uptime – Tell how long the system has been running. e.g.
# uptime |
32. ls – To list the present directory e.g.
# ls # ls -l # ls -lh |
33. df – Report file system disk space usage e.g.
# df # df -h |
34. logname – print user’s login name e.g.
# logname |
35. free – Display amount of free and used memory in the system e.g.
# free # free -m -t |
36. pinky – Its a lightweight finger e.g.
# pinky root # pinky -l root |
37. stat – Display file or file system status e.g.
# stat file1 |
To Get Help – Commands
38. help – To display helpful info about commands e.g.
# ifconfig --help # ls --help # w --help |
39. info – Read info doc e.g.
# info ls # info who # info ifconfig |
40. man – To format and display the on-line manual pages e.g.
# man ls # man w # man ifconfig |
41. whatis – search the whatis database for complete words e.g.
# whatis ls # whatis w # whatis who |
42. whereis – locate the binary, source, and manual page files for a command e.g.
# whereis who # whereis ls # whereis uptime |
43. which – shows the full path of (shell) commands e.g.
# which ls # which who # which uptime |
Miscellaneous Commands:
44. history – Display users command history e.g.
# history # history -c (To clear the history) |
45. find – search for files in a directory hierarchy e.g.
# find / -name santosh |
46. locate – Find the files e.g.
# locate santosh |
47. poweroff – To stop the system e.g.
# poweroff # poweroff -f (Forcefully) |
48. shutdown – To bring the system down e.g.
# shutdown # shutdown -r (reboot) |
49. halt – To bring system down e.g.
# halt |
50. reboot – To reboto the system e.g.
# reboot |
52. logout – To logout from the current session e.g.
# logout |
52. exit – To close the current session e.g.
# exit |
53. lpq – show printer queue status e.g.
# lpq (Should have default printer configured) |
54. cancel – Cancel print jobs e.g.
# cancel 1 # cancel -U root 1 |
55. passwd – To change user password e.g.
# passwd (To change self password) # passwd mike (To change user mike's passwd) |
56. ping – send ICMP ECHO_REQUEST to network hosts, to see other host responding or not e.g.
# ping 192.168.222.111 |
57. runlevel – To see the cureent runlevel e.g.
# runlevel |
58. sort – To sort the command outputs e.g.
# cat file1 | sort # ls -l | sort |
59. su – To switch to another user e.g.
# su - (To switch to root) # su - mike (To switch to mike) |
- Now you are more acquainted with the basic Linux command, hence you will be comfortable doing basic things after logging into Linux machine.