Linux Commands Cheat Sheet

⚙️ System Monitoring
uptime → Check system uptime
free -h → View memory usage
df -h → Check disk space
top → Real-time process monitoring
journalctl -xe → View detailed system logs

🔁 Service Management
sudo systemctl status nginx → Check NGINX service status
sudo systemctl restart nginx → Restart NGINX

📂 File & Directory Operations
cd /var/log → Navigate to log directory
cd .. → Move up a directory
ls -lart → List all files (sorted, detailed)
mkdir new_folder → Create a directory
cp /etc/nginx/nginx.conf backup/ → Backup NGINX config
rm -rf temp/ → Delete folder/files recursively
du -sh * → Show size of directories

✍️ Text Editing
vi filename → Open file in Vi
nano filename → Open file in Nano (beginner-friendly)

🔍 Search & Filter
grep ‘ERROR’ /var/log/syslog → Search error logs
ps aux | grep nginx → Check if NGINX is running
find / -name “nginx.conf” → Find nginx config
find . -type f -name “*.log” → Find log files

👥 User & Permission Management
whoami → Display current user
sudo adduser support_user → Add new user
sudo usermod -aG sudo support_user → Grant sudo rights
chmod +x deploy.sh → Make script executable
chown root:root secure.log → Change file ownership
chmod o+rx filepath → Grant read/execute to others

📦 Package Installation (Ubuntu)
sudo apt update && sudo apt upgrade -y → Update system
sudo apt install curl net-tools -y → Install common tools

🌐 Network & Remote Access
ping googlecom → Test internet connectivity
ip a → Show IP addresses
netstat -tuln → View listening ports
ssh ubuntu@3.81.127.103 -i project.pem → Connect to EC2
telnet host port → Test port connectivity

🛠️ Handy Shortcuts
history | tail -n 10 → View last 10 commands
tail -f /logfilepath → Live log monitoring
tail -n 1000 /logfilepath → View last 1000 log lines

🔽 Whether you’re starting out or deep into DevOps, mastering these commands is necessary!

pwd, ls, cd, mkdir, rmdir, cp, mv, rm, cat, man, whoami, hostname, uname, chmod, chown, ps, kill, ifconfig, scp, curl, tar

🔧 System Information
uname -a # Kernel name, version, architecture
hostname # Show system hostname
uptime # Show how long the system has been running
top / htop # Real-time system processes

📁 File and Directory Management

ls -lah # List with details, human-readable
cd /path/to/dir # Change directory
pwd # Show current directory
mkdir new_dir # Create a directory
rm -rf /path/to/dir # Remove directory/file recursively

🔍 Disk Usage & Space

df -h # Disk space in human-readable format
du -sh * # Size of each file/folder in current dir
mount | column -t # Mounted filesystems
lsblk # Block devices

🔑 User Management

whoami # Current user
id # Show UID, GID
useradd / userdel # Add/delete user
usermod # Modify user
passwd # Set/change password
su – username # Switch user
sudo <command> # Run as superuser

📡 Networking

ip a / ifconfig # Show IP addresses
ip r / route # Show routes
ping google.com # Test connectivity
netstat -tulpn # Listening ports & services
ss -tuln # Faster netstat alternative
curl -I URL # HTTP headers
wget URL # Download file
scp src dest # Secure copy
rsync -avz src dest # Sync files/directories

🔥 Process Management

ps aux # List all processes
top / htop # Monitor processes
kill PID # Kill by PID
killall <proc> # Kill by name
nice / renice # Set process priority
📝 Logs & Monitoring
tail -f /var/log/syslog # Follow log
journalctl -xe # Systemd logs
grep “ERROR” file.log # Search logs
watch -n 1 df -h # Run command repeatedly

📦 Package Management

Debian/Ubuntu:
apt update && apt upgrade # Update packages
apt install <pkg>
apt remove <pkg>
RHEL/CentOS:
yum install <pkg>

⚙️ Permissions & Ownership

chmod 755 file # Set permissions
chown user:group file # Change ownership
ls -l # View permissions
umask

🔐 SSH & Keys
ssh user@host # Connect to server
ssh-keygen # Generate SSH keys
ssh-copy-id user@host # Copy public key to server

🧪 Testing Tools
nc -zv host port # Test port
telnet host port # Test connection
dig domain # DNS lookup
traceroute host # Route tracing

#Linux_Commands:-
1. Check server uptime: “uptime”
2. Check disk usage: `df -h`
3. Check memory usage: `free -m`
4. Check CPU usage: `top` or `htop`
5. Check logs: `tail -f /var/log/syslog`
6. Check network connections: `netstat -tlnp`
7. Check running processes: `ps aux`
8. Kill a process: `kill <pid>`
9. Check file permissions: `ls -l`
10.Change file permissions: `chmod <permissions> <file>`

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top