Chapter 1 Linux Commands Review
Chapter 1 Linux Commands Review
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 spe-cify 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
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)
1
20. lspci -tv : Shows information on PCI buses devices
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
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
2
36. groupadd admin : Adds the group "admin"
37. useradd -c "Sam Tomshi" -g admin -m sam : Creates user "sam" and adds to group "admin"
42. ls -al : Displays all information about files/directories. This includes displaying
all hidden files as well
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
3
57. ln -s link file : Create a soft link named link to the file
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
4
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
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
IX Compression commands
89. tar cf home.tar home : Creates a tar named home.tar containing home/
5
Search Related Commands
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
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
6
102. fdisk -l : Shows disks partitions sizes and types