50 Essential Linux Commands Every User Should Know in 2025
Whether you are a Linux beginner or a seasoned administrator, mastering essential Linux commands is crucial for productivity. This comprehensive guide covers the 50 most important commands you will use daily, from basic file operations to advanced system administration.
📑 Table of Contents
- File and Directory Commands
- 1. ls – List Directory Contents
- 2. cd – Change Directory
- 3. pwd – Print Working Directory
- 4. mkdir – Make Directory
- 5. rm – Remove Files and Directories
- 6. cp – Copy Files and Directories
- 7. mv – Move or Rename Files
- File Viewing and Editing
- 8. cat – Display File Contents
- 9. less – View Files Page by Page
- 10. head and tail – View Beginning or End of Files
- 11. nano – Simple Text Editor
- 12. vim – Advanced Text Editor
- File Permissions and Ownership
- 13. chmod – Change File Permissions
- 14. chown – Change File Ownership
- Search Commands
- 15. find – Search for Files
- 16. grep – Search Text in Files
- 17. locate – Fast File Search
- System Information Commands
- 18. uname – System Information
- 19. df – Disk Space Usage
- 20. du – Directory Space Usage
- 21. free – Memory Usage
- 22. top – Real-time Process Monitoring
- 23. htop – Enhanced Process Viewer
- Process Management
- 24. ps – Process Status
- 25. kill – Terminate Processes
- 26. systemctl – Service Management
- Network Commands
- 27. ip – Network Configuration
- 28. ping – Test Network Connectivity
- 29. curl – Transfer Data from URLs
- 30. wget – Download Files
- 31. ss – Socket Statistics
- User Management
- 32. useradd – Create User
- 33. passwd – Change Password
- 34. usermod – Modify User
- 35. su and sudo – Switch User / Superuser
- Archive and Compression
- 36. tar – Archive Files
- 37. zip and unzip
- Package Management
- 38. apt – Debian/Ubuntu Package Manager
- 39. dnf/yum – RHEL/Fedora Package Manager
- Advanced Commands
- 40. awk – Text Processing
- 41. sed – Stream Editor
- 42. xargs – Build Command Lines
- 43. tee – Read from Input and Write to Output
- 44. history – Command History
- 45. alias – Create Command Shortcuts
- Pipe and Redirection
- 46. Pipe (|) – Chain Commands
- 47. Redirection (>, >>,
- SSH and Remote Access
- 48. ssh – Secure Shell
- 49. scp – Secure Copy
- 50. rsync – Advanced File Sync
- Quick Reference Cheat Sheet
- Conclusion
File and Directory Commands
1. ls – List Directory Contents
The ls command lists files and directories in the current location.
# Basic listing
ls
# Long format with details
ls -la
# Human-readable file sizes
ls -lh
# Sort by modification time
ls -lt
2. cd – Change Directory
Navigate between directories with the cd command.
# Go to home directory
cd ~
# Go to previous directory
cd -
# Go up one level
cd ..
# Go to specific path
cd /var/log
3. pwd – Print Working Directory
Display your current directory location.
pwd
# Output: /home/username
4. mkdir – Make Directory
Create new directories.
# Create single directory
mkdir projects
# Create nested directories
mkdir -p projects/linux/scripts
# Create with specific permissions
mkdir -m 755 secure_folder
5. rm – Remove Files and Directories
Delete files and directories. Use with caution!
# Remove file
rm filename.txt
# Remove directory and contents
rm -r directory_name
# Force remove without prompts
rm -rf directory_name
# Interactive mode (safer)
rm -i filename.txt
6. cp – Copy Files and Directories
# Copy file
cp source.txt destination.txt
# Copy directory recursively
cp -r source_dir/ destination_dir/
# Preserve attributes
cp -p file.txt backup/
# Interactive (prompt before overwrite)
cp -i file.txt /backup/
7. mv – Move or Rename Files
# Rename file
mv oldname.txt newname.txt
# Move file to directory
mv file.txt /home/user/documents/
# Move multiple files
mv *.txt /backup/
File Viewing and Editing
8. cat – Display File Contents
# Display file
cat filename.txt
# Display with line numbers
cat -n filename.txt
# Concatenate multiple files
cat file1.txt file2.txt > combined.txt
9. less – View Files Page by Page
# View file with scrolling
less /var/log/syslog
# Navigation: Space=next page, b=back, q=quit, /=search
10. head and tail – View Beginning or End of Files
# First 10 lines
head filename.txt
# First 20 lines
head -n 20 filename.txt
# Last 10 lines
tail filename.txt
# Follow file in real-time (great for logs)
tail -f /var/log/syslog
11. nano – Simple Text Editor
# Edit file
nano filename.txt
# Shortcuts: Ctrl+O=Save, Ctrl+X=Exit, Ctrl+K=Cut line
12. vim – Advanced Text Editor
# Edit file
vim filename.txt
# Modes: i=Insert, Esc=Normal, :wq=Save and quit, :q!=Quit without saving
File Permissions and Ownership
13. chmod – Change File Permissions
# Make file executable
chmod +x script.sh
# Set specific permissions (rwxr-xr-x)
chmod 755 script.sh
# Remove write permission for others
chmod o-w filename.txt
# Recursive permission change
chmod -R 644 /var/www/html/
14. chown – Change File Ownership
# Change owner
sudo chown username filename.txt
# Change owner and group
sudo chown username:groupname filename.txt
# Recursive ownership change
sudo chown -R www-data:www-data /var/www/
Search Commands
15. find – Search for Files
# Find by name
find /home -name "*.txt"
# Find by type (f=file, d=directory)
find /var -type f -name "*.log"
# Find files modified in last 7 days
find /home -mtime -7
# Find and delete
find /tmp -name "*.tmp" -delete
# Find large files (>100MB)
find / -size +100M
16. grep – Search Text in Files
# Search for pattern
grep "error" /var/log/syslog
# Case-insensitive search
grep -i "error" logfile.txt
# Recursive search in directory
grep -r "function" /home/user/scripts/
# Show line numbers
grep -n "pattern" filename.txt
# Invert match (lines NOT containing pattern)
grep -v "debug" logfile.txt
17. locate – Fast File Search
# Search file database
locate filename.txt
# Update database first
sudo updatedb
System Information Commands
18. uname – System Information
# All system info
uname -a
# Kernel version
uname -r
# Operating system
uname -o
19. df – Disk Space Usage
# Human-readable format
df -h
# Show filesystem type
df -T
# Show specific filesystem
df -h /home
20. du – Directory Space Usage
# Directory size
du -sh /var/log
# Show subdirectory sizes
du -h --max-depth=1 /home
# Sort by size
du -h /home | sort -hr | head -10
21. free – Memory Usage
# Human-readable format
free -h
# Show in megabytes
free -m
22. top – Real-time Process Monitoring
# Start top
top
# Shortcuts: q=quit, k=kill process, M=sort by memory, P=sort by CPU
23. htop – Enhanced Process Viewer
# Install if not available
sudo apt install htop
# Run htop
htop
Process Management
24. ps – Process Status
# All processes
ps aux
# Process tree
ps auxf
# Find specific process
ps aux | grep nginx
25. kill – Terminate Processes
# Kill by PID
kill 1234
# Force kill
kill -9 1234
# Kill by name
pkill firefox
killall firefox
26. systemctl – Service Management
# Start service
sudo systemctl start nginx
# Stop service
sudo systemctl stop nginx
# Restart service
sudo systemctl restart nginx
# Check status
sudo systemctl status nginx
# Enable at boot
sudo systemctl enable nginx
# Disable at boot
sudo systemctl disable nginx
Network Commands
27. ip – Network Configuration
# Show IP addresses
ip addr show
# Show routing table
ip route show
# Show network interfaces
ip link show
28. ping – Test Network Connectivity
# Ping host
ping google.com
# Ping with count
ping -c 4 google.com
29. curl – Transfer Data from URLs
# Fetch webpage
curl https://example.com
# Download file
curl -O https://example.com/file.zip
# Follow redirects
curl -L https://example.com
# Show headers
curl -I https://example.com
30. wget – Download Files
# Download file
wget https://example.com/file.zip
# Download to specific location
wget -P /downloads/ https://example.com/file.zip
# Continue interrupted download
wget -c https://example.com/largefile.iso
31. ss – Socket Statistics
# Show all connections
ss -a
# Show listening ports
ss -l
# Show TCP connections
ss -t
# Show process using ports
ss -tulpn
User Management
32. useradd – Create User
# Create user
sudo useradd username
# Create with home directory
sudo useradd -m username
# Create with specific shell
sudo useradd -m -s /bin/bash username
33. passwd – Change Password
# Change your password
passwd
# Change another users password (as root)
sudo passwd username
34. usermod – Modify User
# Add user to group
sudo usermod -aG sudo username
# Change users shell
sudo usermod -s /bin/zsh username
35. su and sudo – Switch User / Superuser
# Switch to root
su -
# Run command as root
sudo command
# Switch to another user
su - username
Archive and Compression
36. tar – Archive Files
# Create tar archive
tar -cvf archive.tar directory/
# Create compressed tar.gz
tar -czvf archive.tar.gz directory/
# Extract tar archive
tar -xvf archive.tar
# Extract tar.gz
tar -xzvf archive.tar.gz
# List contents
tar -tvf archive.tar
37. zip and unzip
# Create zip
zip -r archive.zip directory/
# Extract zip
unzip archive.zip
# List zip contents
unzip -l archive.zip
Package Management
debian-ubuntu-package-manager">38. apt – Debian/Ubuntu Package Manager
# Update package list
sudo apt update
# Upgrade all packages
sudo apt upgrade
# Install package
sudo apt install package_name
# Remove package
sudo apt remove package_name
# Search for package
apt search keyword
rhel-fedora-package-manager">39. dnf/yum – RHEL/Fedora Package Manager
# Update all packages
sudo dnf update
# Install package
sudo dnf install package_name
# Remove package
sudo dnf remove package_name
# Search for package
dnf search keyword
Advanced Commands
40. awk – Text Processing
# Print specific column
awk "{print \$1}" filename.txt
# Print lines matching pattern
awk "/error/" logfile.txt
# Field separator
awk -F":" "{print \$1}" /etc/passwd
41. sed – Stream Editor
# Replace text
sed "s/old/new/g" filename.txt
# Replace in file
sed -i "s/old/new/g" filename.txt
# Delete lines containing pattern
sed "/pattern/d" filename.txt
42. xargs – Build Command Lines
# Delete files from find
find /tmp -name "*.tmp" | xargs rm
# Run command on each line
cat urls.txt | xargs wget
43. tee – Read from Input and Write to Output
# Save output and display
ls -la | tee output.txt
# Append instead of overwrite
echo "new line" | tee -a logfile.txt
44. history – Command History
# Show command history
history
# Run command by number
!123
# Run last command
!!
# Search history
history | grep "keyword"
# Or press Ctrl+R for reverse search
45. alias – Create Command Shortcuts
# Create alias
alias ll="ls -la"
alias update="sudo apt update && sudo apt upgrade"
# Make permanent (add to ~/.bashrc)
echo "alias ll=\"ls -la\"" >> ~/.bashrc
Pipe and Redirection
46. Pipe (|) – Chain Commands
# Send output to another command
ls -la | grep ".txt"
cat logfile.txt | grep "error" | wc -l
47. Redirection (>, >>, <)
# Redirect output to file (overwrite)
ls > filelist.txt
# Append to file
echo "new line" >> logfile.txt
# Redirect errors
command 2> errors.txt
# Redirect both output and errors
command > output.txt 2>&1
SSH and Remote Access
48. ssh – Secure Shell
# Connect to remote server
ssh username@hostname
# Connect on specific port
ssh -p 2222 username@hostname
# Use SSH key
ssh -i ~/.ssh/mykey.pem username@hostname
49. scp – Secure Copy
# Copy to remote
scp file.txt username@hostname:/remote/path/
# Copy from remote
scp username@hostname:/remote/file.txt /local/path/
# Copy directory
scp -r directory/ username@hostname:/remote/path/
50. rsync – Advanced File Sync
# Sync local directories
rsync -avh source/ destination/
# Sync to remote server
rsync -avz -e ssh source/ username@hostname:/destination/
# Delete files not in source
rsync -avh --delete source/ destination/
Quick Reference Cheat Sheet
| Command | Purpose | Example |
|---|---|---|
| ls | List files | ls -la |
| cd | Change directory | cd /home |
| cp | Copy files | cp -r src/ dest/ |
| mv | Move/rename | mv old.txt new.txt |
| rm | Remove files | rm -rf dir/ |
| grep | Search text | grep “error” log.txt |
| find | Find files | find / -name “*.txt” |
| chmod | Change permissions | chmod 755 script.sh |
| tar | Archive files | tar -czvf arch.tar.gz dir/ |
| ssh | Remote access | ssh user@host |
Conclusion
Mastering these 50 essential Linux commands will significantly boost your productivity and confidence when working with Linux systems. Start with the basic file and directory commands, then gradually move to more advanced topics like process management, networking, and text processing.
Pro Tips:
- Use
man command_nameto read the manual for any command - Use
command --helpfor quick help - Practice in a safe environment before running commands on production systems
- Create aliases for frequently used commands
- Use tab completion to speed up typing
Bookmark this guide and refer back to it whenever you need a quick refresher. Happy Linux learning!
Was this article helpful?
About Ramesh Sundararamaiah
Red Hat Certified Architect
Expert in Linux system administration, DevOps automation, and cloud infrastructure. Specializing in Red Hat Enterprise Linux, CentOS, Ubuntu, Docker, Ansible, and enterprise IT solutions.