Docs / Linux Basics / Essential Linux Command Line Reference

Essential Linux Command Line Reference

By Admin · Feb 6, 2026 · Updated Apr 25, 2026 · 218 views · 2 min read

File Operations

Command Description Example
ls List files ls -la (all files, long format)
cp Copy cp file.txt backup/
mv Move/rename mv old.txt new.txt
rm Remove rm -rf directory/
mkdir Create directory mkdir -p path/to/dir
touch Create/update file touch newfile.txt
find Search files find / -name "*.log" -mtime +7
locate Fast file search locate nginx.conf

Text Processing

# View file contents
cat file.txt          # Entire file
head -20 file.txt     # First 20 lines
tail -f /var/log/syslog  # Follow file (live)
less file.txt         # Scrollable viewer

# Search in files
grep "error" /var/log/*.log
grep -r "TODO" /var/www/    # Recursive
grep -i "warning" file.txt  # Case-insensitive
grep -c "error" access.log  # Count matches

# Text manipulation
sed 's/old/new/g' file.txt         # Replace text
awk '{print $1, $4}' access.log   # Extract columns
sort file.txt | uniq               # Sort and deduplicate
wc -l file.txt                     # Count lines

System Information

uname -a          # Kernel version
hostname          # Server name
uptime            # Uptime and load
whoami            # Current user
id                # User ID and groups
lsb_release -a    # OS version
nproc             # CPU count
free -h           # Memory usage
df -h             # Disk usage
du -sh /var/*     # Directory sizes

Process Management

ps aux                    # All processes
top / htop               # Interactive process viewer
kill PID                 # Graceful stop
kill -9 PID              # Force kill
pkill -f "process name"  # Kill by name
jobs                     # Background jobs
bg / fg                  # Background/foreground
nohup command &          # Run after logout

Networking

ip addr                  # IP addresses
ss -tlnp                 # Listening ports
curl -I example.com      # HTTP headers
wget file-url            # Download file
ping host                # Connectivity test
dig domain               # DNS lookup
traceroute host          # Network path
nc -zv host port         # Port check

Piping and Redirection

# Pipe output to next command
ps aux | grep nginx | wc -l

# Redirect output
command > file.txt        # Overwrite
command >> file.txt       # Append
command 2> errors.txt     # Stderr only
command &> all.txt        # Both stdout and stderr
command 2>/dev/null       # Discard errors

Useful Shortcuts

Shortcut Action
Ctrl+C Cancel current command
Ctrl+Z Suspend to background
Ctrl+D Exit shell / EOF
Ctrl+R Search command history
Ctrl+A Jump to line start
Ctrl+E Jump to line end
!! Repeat last command
!$ Last argument of previous command

Tip Use history | grep "keyword" or Ctrl+R to search through your command history. It's faster than retyping commands.

Was this article helpful?