File and Directory Management
1. ls - Lists directory contents.
o ls - Basic list.
o ls -l - List with details.
o Example: ls -la Directory
2. cd - Change the current directory.
o cd Directory - Changes to "Directory".
o Example: cd /home
3. pwd - Print the current directory path.
o pwd - Outputs the current directory.
o Example: pwd
4. mkdir - Create a new directory.
o mkdir Directory - Creates "Directory".
o Example: mkdir /home/Directory
5. rmdir - Remove an empty directory.
o rmdir Directory - Deletes "Directory".
o Example: rmdir /home/Directory
6. rm - Delete files and directories.
o rm file - Deletes "file".
o rm -r Directory - Deletes "Directory"
recursively.
o Example: rm -rf /home/Directory
7. cp - Copy files or directories.
o cp file new_file - Copies "file" to "new_file".
o cp -r Directory new_directory - Copies
"Directory" recursively.
o Example: cp -r Directory /backup/
8. mv - Move or rename files and directories.
o mv file new_file - Renames "file" to
"new_file".
o Example: mv file /home/Directory/
9. touch - Create an empty file.
o touch file - Creates "file".
o Example: touch /home/Directory/newfile
10. cat - Concatenate and display file contents.
o cat file - Shows contents of "file".
o Example: cat file
11. less - View file content interac vely.
o less file - Opens "file" in viewer.
o Example: less file
12. more - View file content page-by-page.
o more file - Views file with paging.
o Example: more file
13. head - Show the first few lines of a file.
o head -n 5 file - Shows first 5 lines.
o Example: head file
14. tail - Show the last few lines of a file.
o tail -n 5 file - Shows last 5 lines.
o tail -f file - Shows last lines with live updates.
o Example: tail -f /var/log/syslog
15. find - Search for files and directories.
o find Directory -name "*.txt" - Searches for .txt
files.
o Example: find /home -type f -name "*.sh"
16. locate - Find files by name (needs mlocate
package).
o locate file - Searches for "file".
o Example: locate file
17. du - Disk usage of files and directories.
o du -sh Directory - Shows size of "Directory".
o Example: du -h Directory
18. df - Display disk space usage.
o df -h - Disk usage in human-readable format.
o Example: df -h
19. stat - Display detailed file or directory status.
o stat file - Shows stats of "file".
o Example: stat file
20. tree - Show directory structure in tree format.
o tree Directory - Displays "Directory" structure.
o Example: tree /home
File Permissions and Ownership
21. chmod - Change file permissions.
o chmod 755 file - Sets permissions for "file".
o Example: chmod +x script.sh
22. chown - Change file ownership.
o chown user file - Changes owner to "user".
o Example: chown root file
23. chgrp - Change group ownership.
o chgrp group file - Changes group to "group".
o Example: chgrp admin file
24. umask - Set default permissions for new files.
o umask 022 - Default file permissions.
o Example: umask
Process Management
25. ps - Show ac ve processes.
o ps aux - Shows all processes.
o Example: ps aux | grep nginx
26. top - Monitor system processes in real me.
o top - Live view of processes.
o Example: top
27. htop - Enhanced process viewer (requires
htop).
o htop - Interac ve process viewer.
o Example: htop
28. kill - Terminate a process by ID.
o kill 1234 - Ends process with PID 1234.
o Example: kill 1234
29. killall - Kill processes by name.
o killall firefox - Kills all "firefox" processes.
o Example: killall nginx
30. pkill - Kill processes by pa ern.
o pkill -u user - Kills all processes for "user".
o Example: pkill -u john
Networking
31. ping - Check network connec vity.
o ping google.com - Sends ping requests.
o Example: ping -c 4 google.com
32. ifconfig - Display network configura on
(deprecated).
o ifconfig - Shows network interfaces.
o Example: ifconfig
33. traceroute - Track packet route to des na on.
o traceroute google.com - Shows route to
"google.com".
o Example: traceroute google.com
34. nslookup - Query DNS records.
o nslookup google.com - DNS lookup for
"google.com".
o Example: nslookup example.com
35. netstat - Network connec ons, rou ng tables.
o netstat -tuln - Lists open ports.
o Example: netstat -an
Compression and Archiving
37. tar - Archive mul ple files.
o tar -cvf archive.tar Directory - Creates a tar
archive.
o Example: tar -xvf archive.tar
38. zip - Compress files into a zip archive.
o zip archive.zip file1 file2 - Creates
"archive.zip".
o Example: zip -r archive.zip Directory
39. unzip - Extract files from a zip archive.
o unzip archive.zip - Extracts "archive.zip".
o Example: unzip archive.zip
40. gzip - Compress a file.
o gzip file - Compresses "file" as "file.gz".
o Example: gzip -d file.gz
41. bzip2 - Compress with bzip2.
o bzip2 file - Compresses "file".
o Example: bzip2 -d file.bz2
System Informa on
42. uname - Display system informa on.
o uname -a - Full system details.
o Example: uname -r
43. up me - Show system up me.
o up me - Outputs how long system has been
up.
o Example: up me
44. free - Memory usage.
o free -h - Shows memory in human-readable
form.
o Example: free
45. dmesg - Print or control kernel messages.
o dmesg | less - Shows boot logs.
o Example: dmesg | grep error
46. df - Disk space usage of filesystems.
o df -h - Human-readable format.
o Example: df /home
User Management
47. useradd - Create a new user.
o useradd username - Adds "username".
o Example: useradd admin
48. usermod - Modify user accounts.
o usermod -aG sudo user - Adds "user" to
"sudo" group.
o Example: usermod -aG docker user
49. passwd - Change user password.
o passwd user - Changes password for "user".
o Example: passwd root
50. whoami - Display the current logged-in user.
o whoami - Shows username.
o Example: whoami
Data Manipula on
51. awk - Pa ern scanning and processing.
o awk '{print $1}' file - Prints first column.
o Example: awk '{print $2}' file
52. sed - Stream editor for modifying files.
o sed 's/old/new/' file - Replace text.
o Example: sed -i 's/foo/bar/g' file
53. sort - Sort file content.
o sort file - Sorts file lines.
o Example: sort file
54. uniq - Report or omit repeated lines.
o uniq file - Removes duplicates.
o Example: uniq -c file
55. grep - Search within files.
o grep "pa ern" file - Searches for "pa ern".
o Example: grep -i error file
File and Directory Management (Con nued)
56. wc - Count lines, words, and characters in a
file.
Usage: wc file - Displays line, word, and character
counts for "file".
Example: wc -l file - Counts lines in "file".
57. ln - Create links between files.
Usage: ln file link_name - Creates a hard link.
ln -s file link_name - Creates a symbolic (so ) link.
Example: ln -s /path/to/file symlink_name
58. alias - Create command shortcuts.
Usage: alias ll='ls -la' - Creates an alias for ls -la.
Example: alias dir='ls -d */'
59. unalias - Remove an alias.
Usage: unalias ll - Removes the alias "ll".
Example: unalias dir
60. rename - Rename mul ple files.
Usage: rename 's/old/new/' *.txt - Renames files
by replacing "old" with "new" in .txt files.
Example: rename 's/2023/2024/' *.log
Process Management (Con nued)
61. bg - Run a job in the background.
Usage: bg - Resumes a paused job in the
background.
Example: bg %1 - Backgrounds job number 1.
62. fg - Bring a job to the foreground.
Usage: fg %1 - Brings job number 1 to the
foreground.
Example: fg %2
63. jobs - List all ac ve jobs.
Usage: jobs - Displays ac ve jobs with their
statuses.
Example: jobs -l
64. nice - Run a command with adjusted priority.
Usage: nice -n 10 command - Runs a command
with priority 10.
Example: nice -n 15 ./script.sh
65. renice - Change the priority of a running
process.
Usage: renice -n 5 -p PID - Changes the priority of
process "PID".
Example: renice -n 10 -p 1234
66. nohup - Run a command immune to hangups.
Usage: nohup command & - Executes command,
ignoring hangups.
Example: nohup ./script.sh &
67. pgrep - Find processes by name.
Usage: pgrep process_name - Finds process IDs
with the specified name.
Example: pgrep nginx
68. pmap - Display memory map of a process.
Usage: pmap PID - Shows memory details of
process "PID".
Example: pmap 1234
69. up me - Display system up me and load.
Usage: up me - Shows system up me and average
load.
Example: up me
Networking (Con nued)
70. curl - Transfer data to/from a server.
Usage: curl URL - Fetches data from URL.
Example: curl -O h ps://example.com/file.txt
71. wget - Download files from the internet.
Usage: wget URL - Downloads file from the
specified URL.
Example: wget h ps://example.com/file.zip
72. scp - Securely copy files between hosts.
Usage: scp source_file user@remote:/path -
Copies file to a remote server.
Example: scp file.txt user@remote-
server:/home/user
73. rsync - Synchronize files and directories.
Usage: rsync -av source/ des na on/ - Syncs
source to des na on.
Example: rsync -avz Directory
user@remote:/backup/
74. telnet - Connect to remote servers (insecure).
Usage: telnet host port - Connects to a specified
host and port.
Example: telnet localhost 80
75. netcat (nc) - Network u lity for debugging.
Usage: nc -zv host port - Checks if port is open on
the host.
Example: nc -zv google.com 443
76. ip route - Display or manipulate IP rou ng
table.
Usage: ip route show - Shows the rou ng table.
Example: ip route add 192.168.1.0/24 dev eth0
77. dig - DNS lookup tool.
Usage: dig domain.com - Fetches DNS records for a
domain.
Example: dig +short google.com
78. arp - Display or manipulate ARP cache.
Usage: arp -a - Lists the ARP table.
Example: arp -d IP_ADDRESS
Text Processing
79. echo - Display a line of text.
Usage: echo "Hello World" - Outputs text to the
screen.
Example: echo $PATH
80. tr - Translate characters.
Usage: echo "text" | tr 'a-z' 'A-Z' - Converts
lowercase to uppercase.
Example: echo "hello" | tr 'a-z' 'A-Z'
81. cut - Remove sec ons from lines.
Usage: cut -d ' ' -f 1 file - Displays the first field
from each line.
Example: cut -d: -f1 /etc/passwd
82. paste - Merge lines of files.
Usage: paste file1 file2 - Joins lines from two files.
Example: paste file1 file2
83. xargs - Execute commands from standard
input.
Usage: cat file | xargs echo - Passes arguments to
echo.
Example: find . -name "*.log" | xargs rm
84. nl - Number lines in a file.
Usage: nl file - Numbers each line.
Example: nl file
85. sort - Sort lines in a file.
Usage: sort file - Sorts lines alphabe cally.
Example: sort -n file (numerical sort)
86. uniq - Filter out repeated lines.
Usage: uniq file - Removes duplicate lines.
Example: sort file | uniq
87. tee - Read from input and write to files.
Usage: command | tee file - Writes output to file
and displays it.
Example: ls | tee file
Scheduling and Automa on
88. cron - Schedule regular tasks.
Usage: crontab -e - Opens the cron editor.
Example: 0 5 * * * /path/to/script.sh (Runs script
daily at 5 AM)
89. at - Schedule one- me tasks.
Usage: echo "command" | at me - Executes
command at specified me.
Example: echo "backup.sh" | at 2:00 AM
System Monitoring and Informa on
90. vmstat - Reports virtual memory sta s cs.
Usage: vmstat - Shows memory usage.
Example: vmstat 5 (updates every 5 seconds)
91. iostat - Reports CPU and I/O sta s cs.
Usage: iostat - Shows CPU and disk I/O stats.
Example: iostat -d 2
92. lsof - List open files.
Usage: lsof - Shows open files and processes.
Example: lsof | grep file
93. ss - Display socket sta s cs.
Usage: ss -tuln - Shows listening ports and
connec ons.
Example: ss -s
94. free - Show memory usage.
Usage: free -h - Memory stats in human-readable
format.
Example: free
95. mpstat - Display CPU usage.
Usage: mpstat - Shows per-processor CPU usage.
Example: mpstat -P ALL 1
96. sar - Collect and report system ac vity.
Usage: sar -u 1 5 - CPU usage every second for 5
mes.
Example: sar -r (memory stats)
Security and Access Control
97. iptables - Set up firewall rules.
Usage: iptables -L - Lists rules.
Example: iptables -A INPUT -p tcp --dport 22 -j
ACCEPT
98. chmod - Change file permissions.
Usage: chmod 755 file - Sets permissions.
Example: chmod +x script.sh
99. chown - Change file ownership.
Usage: chown user:group file - Changes ownership.
Example: chown user file
100. passwd - Change user password. - Usage:
passwd user - Sets a password for "user". -
Example: passwd (for current user)
Happy Learning