Linux Commands
Linux 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
4. hostname : Shows system host name. With -i switch you can view the ip address of
the machine and with -d you can view the domain name
6. date : Shows the current date and time. You can specify the format you want to
view the date as well. As an example, by using 'date +%D' you can view the date in 'MM/DD/YY'
format
7. cal : Shows the calendar of the current month. With -y switch you can view the
calendar of the whole current year
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
16. cat /proc/interrupts : Lists the number of interrupts per CPU per I/O device
17. lshw : Displays information on hardware configuration of the system. But this
command must be run as super user or it will only report partial information
18. lsblk : Displays block device related information of the machine. With -a you can
view all block devices
19. free -m : Shows used and free memory (-m for MB)
22. dmidecode : Shows hardware info from the BIOS (vendor details)
These set of commands are used to view various kinds of stats of the Linux system
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
User-Related Commands
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
37. useradd -c "Sam Tomshi" -g admin -m sam : Creates user "sam" and adds to group "admin"
47. mv file1 file2 : Moves files from one place to another/renames file1 to file2
tail -f file : Outputs the contents of file as it grows starting with the last 10 lines
56. diff file1 file2 : View the differences between contents of file1 and file2
59. uniq : Compares adjacent lines in a file and removes/reports any duplicate
lines
ps aux | grep 'telnet' : Displays all process ids related to telnet process
69. pkill processname : Sends kill signal to a process with its name
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
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
These commands are used to view and edit network configurations related aspects of the system
76. ifconfig eth0 : Displays eth0 ethernet port ip address and details
78. ip address add 192.168.0.1 dev eth0 : Sets ip address of eth0 device
81. ping host : Sends echo requests to the host to test ipv4 connection
89. tar cf home.tar home : Creates a tar named home.tar containing home/
96. find /home/tom -name 'index*' : Finds file names that start with "index" inside /home/tom
directory
find /home -size +10000k : Finds files larger than 10000k in /home
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 -r nixsavy@server2:/www /www/tmp : Copies all files and folders recursively from
remote server to the current system /www/tmp folder