Linux Command Line Reference Guide
Ad Space
File System Operations
Navigation
pwd # Print working directory cd /path/to/dir # Change directory cd ~ # Go to home directory cd - # Go to previous directory cd .. # Go up one levelListing Files
ls # List files ls -l # Long format ls -a # Show hidden files ls -lh # Human-readable sizes ls -lt # Sort by timeFile Operations
cp file1 file2 # Copy file cp -r dir1 dir2 # Copy directory mv file1 file2 # Move/rename rm file # Remove file rm -rf dir # Remove directory (careful!) mkdir dir # Create directory rmdir dir # Remove empty directory touch file # Create empty fileViewing Files
cat file # Display file content less file # Page through file head file # First 10 lines tail file # Last 10 lines tail -f file # Follow file (logs)Ad Space
File Permissions
chmod 755 file # Set permissions chmod +x file # Make executable chown user:group file # Change ownership chgrp group file # Change group ls -l # View permissionsProcess Management
ps # List processes ps aux # Detailed process list top # Interactive process viewer htop # Enhanced top (if installed) kill PID # Kill process killall process # Kill all instances jobs # List background jobs fg %1 # Bring job to foreground bg %1 # Send job to backgroundSystem Information
uname -a # System information hostname # Hostname uptime # System uptime free -h # Memory usage df -h # Disk space du -sh dir # Directory size lscpu # CPU informationNetwork Commands
ip addr show # Show IP addresses ip route show # Show routing table ping host # Test connectivity curl url # Download/request wget url # Download file netstat -tulpn # Network connections ss -tulpn # Modern netstatPackage Management
Debian/Ubuntu (apt)
apt update # Update package list apt upgrade # Upgrade packages apt install package # Install package apt remove package # Remove package apt search keyword # Search packages apt list --installed # List installedRed Hat/CentOS (yum/dnf)
yum update # Update packages yum install package # Install package yum remove package # Remove package yum search keyword # Search packagesAd Space
Text Processing
grep pattern file # Search text
grep -r pattern dir # Recursive search
sed 's/old/new/g' file # Replace text
awk '{print $1}' file # Process columns
sort file # Sort lines
uniq file # Remove duplicates
wc -l file # Count linesCompression
tar -czf archive.tar.gz dir # Create tar.gz tar -xzf archive.tar.gz # Extract tar.gz zip -r archive.zip dir # Create zip unzip archive.zip # Extract zip gzip file # Compress file gunzip file.gz # DecompressUseful Shortcuts
Ctrl+C # Cancel command Ctrl+D # Exit shell Ctrl+L # Clear screen Ctrl+R # Search history !! # Repeat last command !n # Execute command n from history