100+ Linux Commands: A Complete Guide for Beginners and Professionals

10000coders10000coders
16 min read

Bhargav

100+ Linux Commands: A Complete Guide for Beginners and Professionals

Master the essential Linux commands that every developer, system administrator, and IT professional should know. This comprehensive guide covers file management, system monitoring, networking, and much more.

Table of Contents

  1. File & Directory Management

  2. File Content Manipulation

  3. System Monitoring & Information

  4. Compression & Archiving

  5. Networking

  6. User & Group Management

  7. Package & Process Control

  8. Disk & Filesystem

  9. Text Editors

  10. Scripting & Environment

  11. Miscellaneous Tools

File & Directory Management

1. ls - List Directory Contents

ls                    # List files and directories
ls -la               # List all files (including hidden) with details
ls -lh               # List with human-readable file sizes
ls -lt               # List sorted by modification time
ls -R                # List recursively (subdirectories)
ls *.txt             # List only .txt files

2. cd - Change Directory

cd                   # Go to home directory
cd /path/to/dir      # Go to specific directory
cd ..                # Go to parent directory
cd -                 # Go to previous directory
cd ~                 # Go to home directory

3. pwd - Print Working Directory

pwd                  # Show current directory path

4. mkdir - Make Directory

mkdir dirname        # Create a directory
mkdir -p dir1/dir2   # Create nested directories
mkdir -m 755 dirname # Create with specific permissions

5. touch - Create Empty File

touch filename       # Create empty file
touch file1 file2    # Create multiple files
touch -a filename    # Update access time only
touch -m filename    # Update modification time only

6. cp - Copy Files and Directories

cp file1 file2       # Copy file1 to file2
cp -r dir1 dir2      # Copy directory recursively
cp -v file1 file2    # Copy with verbose output
cp -p file1 file2    # Preserve permissions and timestamps
cp -i file1 file2    # Interactive copy (prompt before overwrite)

7. mv - Move/Rename Files

mv file1 file2       # Rename file1 to file2
mv file1 /path/dir   # Move file1 to directory
mv -i file1 file2    # Interactive move
mv -v file1 file2    # Verbose move

8. rm - Remove Files

rm filename          # Remove file
rm -r dirname        # Remove directory recursively
rm -f filename       # Force remove (no confirmation)
rm -i filename       # Interactive remove
rm -v filename       # Verbose remove

9. find - Find Files

find . -name "*.txt"           # Find .txt files in current directory
find /home -user username      # Find files owned by user
find . -size +100M             # Find files larger than 100MB
find . -mtime -7               # Find files modified in last 7 days
find . -type f -exec rm {} \;  # Find and remove files

10. rmdir - Remove Directory

rmdir dirname        # Remove empty directory
rmdir -p dir1/dir2   # Remove directory and parent if empty

File Content Manipulation

11. cat - Concatenate and Display Files

cat filename         # Display file content
cat file1 file2      # Display multiple files
cat > filename       # Create file with input
cat >> filename      # Append to file
cat -n filename      # Display with line numbers

12. tac - Reverse Cat

tac filename         # Display file content in reverse order

13. head - Display Beginning of File

head filename        # Display first 10 lines
head -n 20 filename  # Display first 20 lines
head -c 100 filename # Display first 100 characters

14. tail - Display End of File

tail filename        # Display last 10 lines
tail -n 20 filename  # Display last 20 lines
tail -f filename     # Follow file (real-time updates)
tail -c 100 filename # Display last 100 characters

15. more - Page Through File

more filename        # Display file page by page
more -p "pattern" filename  # Start at pattern

16. less - Advanced File Viewer

less filename        # Display file with navigation
less -N filename     # Display with line numbers
less -R filename     # Display with color support

17. cut - Extract Sections from Lines

cut -d: -f1 /etc/passwd    # Extract first field (username)
cut -c1-10 filename        # Extract first 10 characters
cut -f2,4 filename         # Extract 2nd and 4th fields

18. split - Split Files

split -l 1000 file.txt     # Split into 1000-line chunks
split -b 1M file.txt       # Split into 1MB chunks
split -n 5 file.txt        # Split into 5 equal parts

19. nl - Number Lines

nl filename          # Number all lines
nl -b a filename     # Number non-empty lines
nl -s ":" filename   # Use colon as separator

20. tr - Translate Characters

tr 'a-z' 'A-Z' < file      # Convert to uppercase
tr -d '0-9' < file         # Delete digits
tr -s ' ' < file           # Squeeze multiple spaces

System Monitoring & Information

21. top - Process Monitor

top                   # Interactive process viewer
top -p PID            # Monitor specific process
top -u username       # Monitor specific user's processes
top -n 5              # Update 5 times then exit

22. htop - Enhanced Process Viewer

htop                  # Interactive process viewer (if installed)
htop -u username      # Monitor specific user
htop -p PID1,PID2     # Monitor specific processes

23. uptime - System Uptime

uptime                # Show system uptime and load average

24. lscpu - CPU Information

lscpu                 # Display CPU architecture information
lscpu -x              # Display in hex format

25. free - Memory Usage

free                  # Display memory usage
free -h               # Human-readable format
free -s 5             # Update every 5 seconds
free -t               # Show total line

26. df - Disk Space

df                    # Display disk space usage
df -h                 # Human-readable format
df -i                 # Show inode information
df -T                 # Show filesystem type

27. du - Disk Usage

du                    # Show directory sizes
du -h                 # Human-readable format
du -s dirname         # Show total size of directory
du -a                 # Show sizes of all files
du --max-depth=2      # Limit depth to 2 levels

28. ps - Process Status

ps aux                # Show all processes
ps -ef                # Show all processes (alternative format)
ps -p PID             # Show specific process
ps -u username        # Show user's processes
ps aux | grep process # Find specific process

29. whoami - Current User

whoami                # Display current username

Compression & Archiving

30. tar - Tape Archive

tar -cvf archive.tar files/    # Create archive
tar -xvf archive.tar           # Extract archive
tar -czvf archive.tar.gz files/ # Create compressed archive
tar -xzvf archive.tar.gz       # Extract compressed archive
tar -tvf archive.tar           # List archive contents

31. gzip - Compress Files

gzip filename         # Compress file (creates filename.gz)
gzip -d filename.gz   # Decompress file
gzip -l filename.gz   # List compression info
gzip -9 filename      # Maximum compression

33. zip - Create ZIP Archive

zip archive.zip file1 file2    # Create ZIP archive
zip -r archive.zip directory/  # Create recursive ZIP
zip -e archive.zip files/      # Create encrypted ZIP
zip -l archive.zip             # List archive contents

34. unzip - Extract ZIP Archive

unzip archive.zip              # Extract ZIP archive
unzip -l archive.zip           # List archive contents
unzip -d directory archive.zip # Extract to specific directory

35. bzip2 - Block-Sorting Compressor

bzip2 filename         # Compress file (creates filename.bz2)
bzip2 -d filename.bz2  # Decompress file
bzip2 -t filename.bz2  # Test compressed file

Networking

36. ping - Test Network Connectivity

ping google.com        # Ping host
ping -c 4 google.com   # Ping 4 times
ping -i 2 google.com   # Ping every 2 seconds
ping -s 1000 google.com # Ping with 1000-byte packets

37. ifconfig - Network Interface Configuration

ifconfig              # Show all interfaces
ifconfig eth0         # Show specific interface
ifconfig eth0 up      # Enable interface
ifconfig eth0 down    # Disable interface

38. ip - IP Command (Modern)

ip addr               # Show IP addresses
ip link               # Show network interfaces
ip route              # Show routing table
ip addr add 192.168.1.100/24 dev eth0  # Add IP address

39. hostname - Show/Set Hostname

hostname              # Show current hostname
hostname -f           # Show fully qualified hostname
hostname -i           # Show IP address

40. netstat - Network Statistics

netstat -tuln         # Show listening ports
netstat -an           # Show all connections
netstat -i            # Show interface statistics
netstat -r            # Show routing table

41. nc - Netcat

nc -l 8080            # Listen on port 8080
nc hostname 80        # Connect to hostname on port 80
nc -z hostname 20-30  # Scan ports 20-30
nc -v hostname 80     # Verbose connection

42. nslookup - Name Server Lookup

nslookup google.com   # Lookup domain
nslookup 8.8.8.8     # Reverse lookup
nslookup -type=mx google.com  # Lookup MX records

User & Group Management

43. who - Show Logged-in Users

who                   # Show logged-in users
who -H                # Show with headers
who -q                # Show user count only

44. groups - Show User Groups

groups                # Show current user's groups
groups username       # Show specific user's groups

45. passwd - Change Password

passwd                # Change current user's password
passwd username       # Change specific user's password
passwd -l username    # Lock user account
passwd -u username    # Unlock user account

46. finger - User Information

finger                # Show current user info
finger username       # Show specific user info

47. id - User/Group IDs

id                    # Show current user's IDs
id username           # Show specific user's IDs
id -g                 # Show group ID only
id -u                 # Show user ID only

Package & Process Control

48. kill - Terminate Processes

kill PID              # Send SIGTERM to process
kill -9 PID           # Force kill process (SIGKILL)
kill -l               # List all signals
kill -HUP PID         # Send SIGHUP signal

49. killall - Kill by Name

killall processname   # Kill all processes by name
killall -9 processname # Force kill by name
killall -u username processname # Kill user's processes

50. nice - Set Process Priority

nice -n 10 command    # Run command with nice value 10
nice command          # Run command with nice value 10

51. renice - Change Process Priority

renice 10 PID         # Change process priority to 10
renice -n 5 -p PID    # Change process priority by -5

52. jobs - List Background Jobs

jobs                  # List background jobs
jobs -l               # List with process IDs
jobs -r               # List running jobs only

53. bg - Background Job

bg                    # Continue stopped job in background
bg %1                 # Continue job number 1 in background

54. fg - Foreground Job

fg                    # Bring background job to foreground
fg %1                 # Bring job number 1 to foreground

Disk & Filesystem

55. mount - Mount Filesystems

mount                 # Show mounted filesystems
mount /dev/sda1 /mnt  # Mount device to directory
mount -t nfs server:/share /mnt  # Mount NFS share

56. umount - Unmount Filesystems

umount /mnt           # Unmount directory
umount /dev/sda1      # Unmount device
umount -f /mnt        # Force unmount

57. lsblk - List Block Devices

lsblk                 # List all block devices
lsblk -f              # Show filesystem information
lsblk -o NAME,SIZE,TYPE  # Show specific columns

58. fdisk - Partition Table Manipulator

fdisk -l              # List all partitions
fdisk /dev/sda        # Edit partition table

Text Editors

59. nano - Simple Text Editor

nano filename         # Edit file
nano -w filename      # Disable word wrapping
nano -c filename      # Show cursor position

60. vim - Advanced Text Editor

vim filename          # Edit file
vim -R filename       # Read-only mode
vim +10 filename      # Open at line 10
vim -c "set number" filename  # Open with line numbers

Scripting & Environment

61. echo - Display Text

echo "Hello World"    # Display text
echo $PATH            # Display environment variable
echo -e "Line1\nLine2" # Interpret escape sequences
echo -n "No newline"  # Suppress newline

62. printenv - Print Environment Variables

printenv              # Print all environment variables
printenv PATH         # Print specific variable

63. export - Set Environment Variables

export VAR=value      # Set environment variable
export PATH=$PATH:/new/path  # Add to PATH
export -p             # List all exported variables

64. env - Run Command with Environment

env                   # Print environment
env VAR=value command # Run command with variable
env -i command        # Run with clean environment

65. alias - Create Command Aliases

alias ll='ls -la'     # Create alias
alias                 # List all aliases
unalias ll            # Remove alias

66. history - Command History

history               # Show command history
history 10            # Show last 10 commands
history -c            # Clear history
!n                    # Execute command number n

67. which - Locate Command

which command         # Show command location
which -a command      # Show all locations

Miscellaneous Tools

68. man - Manual Pages

man command           # Show manual page
man -k keyword        # Search manual pages
man -f command        # Show brief description

69. help - Shell Built-in Help

help                  # Show shell help
help cd               # Show help for specific command

70. cal - Calendar

cal                   # Show current month
cal 2024              # Show year calendar
cal -m                # Monday as first day
cal -3                # Show previous, current, next month

71. bc - Calculator

bc                    # Start calculator
echo "2+2" | bc       # Calculate expression
bc -l                 # Start with math library

72. sl - Steam Locomotive (Fun)

sl                    # Animated steam locomotive (if installed)
sl -a                 # An accident occurs
sl -l                 # Little locomotive

73. cmatrix - Matrix Effect

cmatrix               # Matrix-style display (if installed)
cmatrix -C green      # Green color
cmatrix -s            # Screensaver mode

74. banner - Large Text

banner "Hello"        # Display large text
banner -w 50 "Text"   # Set width to 50

75. date - Display Date/Time

date                  # Show current date/time
date +%Y-%m-%d        # Show date in specific format
date -d "tomorrow"    # Show tomorrow's date
date -s "2024-01-01"  # Set system date

76. shuf - Shuffle Lines

shuf file.txt         # Shuffle lines in file
shuf -i 1-100         # Generate random numbers 1-100
shuf -n 5 file.txt    # Select 5 random lines

77. xeyes - Follow Mouse

xeyes                 # Display eyes following mouse (if installed)

Advanced Commands

78. awk - Text Processing

awk '{print $1}' file.txt     # Print first field
awk -F: '{print $1}' /etc/passwd  # Use colon as delimiter
awk '$3 > 1000' file.txt      # Print lines where field 3 > 1000

79. sed - Stream Editor

sed 's/old/new/g' file.txt    # Replace text
sed -i 's/old/new/g' file.txt # Replace in file
sed -n '5p' file.txt          # Print line 5
sed '1,5d' file.txt           # Delete lines 1-5

80. grep - Search Text

grep "pattern" file.txt       # Search for pattern
grep -i "pattern" file.txt    # Case-insensitive search
grep -r "pattern" directory/  # Recursive search
grep -v "pattern" file.txt    # Invert match
grep -n "pattern" file.txt    # Show line numbers

81. sort - Sort Lines

sort file.txt                 # Sort alphabetically
sort -n file.txt              # Sort numerically
sort -r file.txt              # Reverse sort
sort -u file.txt              # Remove duplicates

82. uniq - Remove Duplicates

uniq file.txt                 # Remove consecutive duplicates
uniq -c file.txt              # Count occurrences
uniq -d file.txt              # Show only duplicates

83. wc - Word Count

wc file.txt                   # Count lines, words, characters
wc -l file.txt                # Count lines only
wc -w file.txt                # Count words only
wc -c file.txt                # Count characters only

84. tee - Read from Stdin, Write to Stdout and Files

echo "text" | tee file.txt    # Write to file and display
echo "text" | tee -a file.txt # Append to file

85. xargs - Execute Commands

find . -name "*.txt" | xargs rm  # Remove all .txt files
echo "1 2 3" | xargs -n 1 echo   # Process each number separately

86. watch - Execute Command Periodically

watch -n 1 'ps aux'           # Watch processes every second
watch -d 'ls -la'             # Highlight differences

87. time - Measure Command Execution Time

time command                  # Measure execution time
time -p command               # POSIX format

88. sleep - Delay Execution

sleep 5                       # Sleep for 5 seconds
sleep 1m                      # Sleep for 1 minute
sleep 1h                      # Sleep for 1 hour

89. wait - Wait for Background Jobs

wait                          # Wait for all background jobs
wait %1                       # Wait for job number 1

90. trap - Handle Signals

trap 'echo "Caught signal"' INT  # Handle Ctrl+C
trap - INT                       # Remove signal handler

91. ulimit - Control Resource Limits

ulimit -a                      # Show all limits
ulimit -n 1024                 # Set file descriptor limit
ulimit -u 1000                 # Set process limit

92. strace - Trace System Calls

strace command                 # Trace system calls
strace -p PID                  # Trace running process
strace -e trace=network command # Trace network calls only

93. lsof - List Open Files

lsof                          # List all open files
lsof -p PID                   # List files opened by process
lsof -i :80                   # List processes using port 80

94. netcat - Network Swiss Army Knife

nc -l 8080                    # Listen on port 8080
nc hostname 80                # Connect to hostname:80
nc -z hostname 20-30          # Scan ports 20-30

95. curl - Transfer Data

curl http://example.com       # Download webpage
curl -O http://example.com/file.txt  # Download file
curl -X POST -d "data" http://example.com  # POST data

96. wget - Retrieve Files

wget http://example.com/file.txt  # Download file
wget -c http://example.com/file.txt  # Continue download
wget -r http://example.com      # Recursive download

97. rsync - Remote Sync

rsync -av source/ dest/        # Sync directories
rsync -avz source/ user@host:dest/  # Sync to remote host
rsync -av --delete source/ dest/    # Sync with deletion

98. scp - Secure Copy

scp file.txt user@host:/path/  # Copy file to remote host
scp user@host:/path/file.txt . # Copy file from remote host
scp -r dir/ user@host:/path/   # Copy directory

99. ssh - Secure Shell

ssh user@hostname              # Connect to remote host
ssh -p 2222 user@hostname      # Connect on specific port
ssh -X user@hostname           # Enable X11 forwarding

100. screen - Terminal Multiplexer

screen                        # Start new screen session
screen -S sessionname         # Start named session
screen -r sessionname         # Reattach to session
screen -ls                    # List sessions

Pro Tips for Linux Command Mastery

1. Use Tab Completion

Press Tab to auto-complete commands, filenames, and paths.

2. Command History

  • Use Ctrl+R to search command history

  • Use !$ to reference the last argument of previous command

  • Use !! to repeat the last command

3. Aliases for Efficiency

alias ll='ls -la'
alias grep='grep --color=auto'
alias df='df -h'
alias du='du -h'

4. Redirection and Pipes

command > file.txt     # Redirect output to file
command >> file.txt    # Append output to file
command < file.txt     # Redirect input from file
command1 | command2    # Pipe output to another command

5. Background and Foreground

command &              # Run command in background
Ctrl+Z                 # Suspend current process
Ctrl+C                 # Terminate current process

6. File Permissions

chmod 755 file         # Set permissions (rwxr-xr-x)
chmod +x file          # Make executable
chown user:group file  # Change ownership

7. Process Management

Ctrl+Z                 # Suspend process
bg                     # Continue in background
fg                     # Bring to foreground
jobs                   # List background jobs

Conclusion

Mastering these Linux commands will significantly improve your productivity and system administration skills. Remember to:

  • Practice regularly - Use these commands in your daily workflow

  • Read man pages - Use man command for detailed information

  • Combine commands - Use pipes and redirection for powerful operations

  • Create aliases - Customize your environment for efficiency

  • Stay updated - Learn new commands and features as they become available

๐Ÿ’ก Pro Tip: Create a personal cheat sheet with your most frequently used commands and their options. This will help you remember them and work more efficiently.

The key to mastering Linux commands is consistent practice and understanding the underlying concepts. Start with the basic file management commands and gradually work your way up to more advanced system administration tasks.

๐Ÿš€ Ready to kickstart your tech career?

๐Ÿ‘‰ Apply to 10000Coders
๐ŸŽ“ Learn Web Development for Free
๐ŸŒŸ See how we helped 2500+ students get jobs

0
Subscribe to my newsletter

Read articles from 10000coders directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

10000coders
10000coders

10000coders offers a structured, mentor-guided program designed to transform absolute beginners into confident, job-ready full-stack developers in 7 months. With hands-on projects, mock interviews, and placement support, it bridges the gap between learning and landing a tech job.