Hey guys, Today I am here to discuss about some of the 100 Linux Commands that will be handy when you use Linux OS. Similar to the Command Prompt or CMD in Windows, Linux has the Terminal in order to help you configure and interact with your system. For someone to work in the Terminal they need to familiarize themselves with Linux commands. Once you are deeply familiarized into the Terminal then, you will get used to the Terminal.
These commands are divided into 13 sections based on their functionalities.
1. System Related Commands
These commands are used to view and manage Linux system-related information.
1. uname : Displays linux system information. With -a switch you can view all the information, with -r switch you can view kernel release information and with -o you can view OS information 2. cat /etc/redhat_release : Shows which version of redhat installed 3. uptime : Shows how long the system has been running 4. hostname : Shows system host name. With -i you can view the ip addr of the machine and with -d you can view the domain name 5. last reboot : Shows system reboot history 6. date : Shows the current date and time. 7. cal : Shows the calendar of the current month. 8. w : Displays who is logged on and what they are doing 9. whoami : Shows current user id 10. finger user : Displays information about user 11. reboot : Reboots the system 12. shutdown : Shuts down the system
2. Hardware Related Commands
These commands are used to view and manage hardware-related aspects of the Linux machine.
13. dmesg : Displays all the messages from Kernel ring buffer. With -k switch you can view kernel messages and with -u you can view userspace messages 14. cat /proc/cpuinfo : Displays information about processes and CPUs of the system 15. cat /proc/meminfo : Displays details on hardware memory 16. cat /proc/interrupts : Lists the number of interrupts per CPU per I/O device 17. lshw : Displays information on hardware config of the system. 18. lsblk : Displays block device related info of the machine. With -a you can view all block devices 19. free -m : Shows used and free memory (-m for MB) 20. lspci -tv : Shows information on PCI buses devices 21. lsusb -tv : Shows information on USB devices 22. dmidecode : Shows hardware info from the BIOS (vendor details) 23. hdparm -i /dev/sda : Shows info about disk sda hdparm -tT /dev/sda : Performs a read speed test on disk sda 24. badblocks -s /dev/sda : Tests for unreadable blocks on disk sda
3. Statistic Related Commands
These set of commands are used to view various kinds of stats of the Linux system
25. mpstat 1 : Displays processors related statistics 26. vmstat 2 : Displays virtual memory statistics 27. iostat 2 : Displays I/O statistics 28. tail -n 500 /var/log/messages : Displays the last 500 kernel/syslog messages 29. tcpdump -i eth1 : Captures all packets flow on interface eth1. With -w switch you can specify a file where you can direct the output to tcpdump -i eth0 'port 80' : Monitors all traffic on port 80 on interface eth0 30. lsof : Lists all open files belonging to all active processes lsof -u testuser : Lists files opened by a specific user 31. free -m : Shows RAM memory details 32. watch df -h : Watches changeable disk usage continuously
4. User-Related Commands
These commands are used to manage Linux users
33. id : Shows the active user and group information. With -G switch you can view the IDs of groups 34. last : Shows a list of last logins on the system. Using -a switch you can add the hostname to the last column of the output 35. who : Shows who is logged on the system 36. groupadd admin : Adds the group "admin" 37. useradd -c "Kool Arpan" -g admin -m kool: Creates user "kool" and adds to group "admin" 38. userdel kool : Deletes user kool 39. adduser kool : Adds user "kool" 40. usermod : Modifies user information 41. passwd user1 : Changes the password of user1
5. File Related Commands
These commands are used to handle files and directories
42. ls -al : Displays all information about files/directories. This includes displaying all hidden files as well 43. pwd : Shows current directory path 44. mkdir directory-name : Creates a directory 45. rm file-name : Deletes file rm -r directory-name : Deletes directory recursively rm -f file-name : Forcefully removes file rm -rf directory-name : Forcefully removes directory recursively 46. cp file1 file2 : Copies linux files, here file1 to file2 cp -r dir1 dir2 : Copies dir1 to dir2, creates dir2 if it doesn't exist 47. mv file1 file2 : Moves files from one place to another/renames file1 to file2 48. ln -s /path/to/file-name link-name : Creates a symbolic link to file-name 49. touch file : Creates empty file 50. cat file : Prints the file content in terminal 51. more file : Display the contents of file 52. head file : Display the first 10 lines of file 53. tail file : Outputs the last 10 lines of file tail -f file : Outputs the contents of file as it grows starting with the last 10 lines 54. gpg -c file : Encrypts file gpg file.gpg : Decrypts file 55. cksum file : View the checksum of the file 56. diff file1 file2 : View the differences between contents of file1 and file2 57. ln -s link file : Create a soft link named link to the file 58. sort : Sorts files in alphabetical order 59. uniq : Compares adjacent lines in a file and removes/reports any duplicate lines 60. wc : Counts number of words/lines 61. dir : Lists the content of the directory 62. tee : Command for chaining and redirection 63. tr : Command for translating characters
6. Process Related Commands
These commands are used to handle Linux processes
64. ps : Displays your currently active processes ps aux | grep 'telnet' : Displays all process ids related to telnet process 65. pmap : Display Memory map of process 66. top : Display all running processes and cpu/memory usage 67. kill pid : Kills process with mentioned pid 68. killall proc : Kills all processes named proc 69. pkill processname : Sends kill signal to a process with its name 70. bg : Resumes suspended jobs without bringing them to foreground 71. fg : Brings the most recent job to foreground fg n : Brings job n to the foreground
7. File Permission Related Commands
These commands are used to change permissions of the files
72. chmod octal file-name : Changes the permissions of file to octal chmod 777 /data/test.c : Sets rwx permission for owner , group and others chmod 755 /data/test.c : Sets rwx permission for owner and rx for group and others 73. chown owner-user file : Changes owner of the file chown owner-user:owner-group file-name : Changes owner and group owner of the file chown owner-user:owner-group directory : Changes owner and group owner of the directory 74. chgrp group1 file : Changes the group ownership of the file to group1
8. Network Related Commands
These commands are used to view and edit network configurations related aspects of the system
75. ifconfig -a : Displays all network interface and set ip address 76. ifconfig eth0 : Displays eth0 ethernet port ip address and details 77. ip addr show : Display all network interfaces and ip addresses 78. ip address add 192.168.88.1 dev eth0 : Sets ip address of eth0 device 79. ethtool eth0 : Linux tool to show ethernet status 80. mii-tool eth0 : Linux tool to show eth0 status 81. ping host : Sends echo requests to the host to test ipv4 connection 82. whois domain : Gets who is information for domain 83. dig domain : Gets DNS nameserver information for domain dig -x host : Reverse lookup host 84. host google.com : Lookup DNS ip address for the name 85. hostname -i : Lookup local ip address 86. wget file : Downloads file 87. netstat -tupl : Lists all active listening ports 88. nslookup : Resolves domain names to IP addresses
9. Compression / Archive Related Commands
These commands are used to compress and decompress files
89. tar cf home.tar home : Creates a tar named home.tar containing home/ tar xf file.tar : Extracts the files from file.tar tar czf file.tar.gz files : Creates a tar with gzip compression 90. gzip file : Compresses file and renames it to file.gz 91. bzip2 -z file : Compresses file and renames it to file.bz2 bzip2 -d file.bz2 : Decompress the file
10. Package Installation Related Commands
These commands are used to manage Linux packages
92. rpm -i pkgname.rpm : Installs rpm based package rpm -e pkgname : Removes package 93. make : Install from source file
11. Search Related Commands
These commands are used to search for files and patterns
94. grep pattern files : Searches for pattern in files grep -r pattern dir : Searches recursively for pattern in dir 95. locate file : Finds all instances of file 96. find /home/kool -name 'index*' : Finds file names that start with "index" inside /home/kool directory find /home -size +10000k : Finds files larger than 10000k in /home
12. Login Related Commands
These commands are used to log into another host
97. ssh [email protected] : Securely connect to a host as user ssh -p port $ [email protected] : Connects to host using specific port 98. telnet host : Connects to the system using telnet port
13. File Transfer Related Commands
These commands are used to copy files from one system to another system
99. scp file.txt server2:/tmp : Secure copy file.txt to remote host /tmp folder scp [email protected]:/www/*.html /www/tmp : Copies *.html files from remote host to current host /www/tmp folder scp -r [email protected]:/www /www/tmp : Copies all files and folders recursively from remote server to the current system /www/tmp folder 100. rsync -a /home/apps /backup/ : Synchronizes source to destination rsync -avz /home/apps $ [email protected]:/backup : Synchronize files/directories between the local and remote system with compression enabled
Hurray!! Congratulations, These are the 100 Linux Commands – A Brief Outline with Examples. If you have any questions, suggestions, feedback please don’t hesitate to write them in the comment box below because it will help us to improve or correct our contents. Thanks, Happy FOSS Computing.
Automobile Accident Attorney
When you’re injured in an automobile accident, you need a personal injury lawyer who is familiar with Waukesha and will investigate all needed areas.
Attorneys Say About Hiring a Car Accident Attorney We asked 16 attorneys to answer a simple. The auto accident attorneys of William McBride Law Group have successfully helped car crash victims across the country file personal injury lawsuits for their