
Share this post
Linux is a robust and flexible operating system. Mastering advanced commands can greatly enhance system administration, security, and performance optimization. This cheat sheet provides an in-depth guide to advanced Linux commands for power users.
Linux Commands Cheat Sheet for Beginners
1. Advanced File Management
find /path -type f -name "*.log"→ Find all.logfiles in a directoryfind /path -mtime -5→ Find files modified in the last 5 dayslocate filename→ Find a file using a prebuilt indexrsync -av source/ destination/→ Synchronize files between directories or remote systemstar -czvf archive.tar.gz /path→ Create a compressed archivetar -xzvf archive.tar.gz→ Extract a compressed archive
2. Advanced User Management
sudo visudo→ Edit sudoers file securelyusermod -aG groupname username→ Add a user to a groupchage -l username→ View password aging informationpasswd -l username→ Lock a user accountwho -a→ Display detailed user login information
3. Process Management & Monitoring
strace -p PID→ Trace system calls of a processlsof -i :8080→ Find processes using port 8080nice -n 10 command→ Run a process with adjusted priorityrenice -n 5 -p PID→ Change priority of an existing processpkill -u username→ Kill all processes for a usernohup command &→ Run a command immune to hang-ups
4. Networking & Performance Tuning
ss -tulnp→ Show listening ports and processesip route show→ Display current routing tablenmap -A target-ip→ Scan an IP for open ports and servicesethtool eth0→ Get Ethernet device settingsiperf -s→ Run a bandwidth performance serveriperf -c server-ip→ Test network speed to a servernetstat -s→ Display network statistics
5. Security & Encryption
gpg -c file→ Encrypt a file with GPGgpg -d file.gpg→ Decrypt a fileopenssl rand -base64 32→ Generate a random keyfirewalld --list-all→ Show active firewall rulesiptables -L -v -n→ Display iptables firewall rulesauditctl -w /etc/passwd -p wa→ Monitor changes to/etc/passwd
6. Disk & Filesystem Management
fdisk -l→ Show all partitionsmkfs.ext4 /dev/sdb1→ Format a partition with ext4fsck /dev/sdb1→ Check and repair a filesystemtune2fs -l /dev/sda1→ Show filesystem parametersxfs_repair /dev/sdb1→ Repair an XFS filesystemiostat -xz 1 5→ Monitor CPU and disk usage
7. System Performance & Logs
dstat -tcmndryl→ Display CPU, memory, and network usagevmstat 1 5→ Show memory and swap statisticsiotop→ Show disk I/O usage by processesjournalctl -n 50 -u service→ View logs for a specific servicedmesg | tail -20→ View last 20 kernel messagessar -u 5 10→ CPU usage over time
8. Containers & Virtualization
docker ps -a→ List all Docker containersdocker images→ List all Docker imagesdocker exec -it container_id bash→ Access a running containervirt-install --name VM --ram 2048 --vcpus 2 --disk size=20 --os-type linux→ Create a new virtual machinevirsh list --all→ Show all virtual machines
9. Automating Tasks with Scripting
echo "Hello World" > script.sh && chmod +x script.sh && ./script.sh→ Create and run a scriptfor file in *.txt; do mv "$file" "${file%.txt}.bak"; done→ Batch rename fileswhile true; do echo "Running..."; sleep 5; done→ Loop execution every 5 seconds
10. Miscellaneous Advanced Commands
watch -n 2 df -h→ Continuously monitor disk space usagetime command→ Measure execution time of a commandtimeout 30 command→ Run a command for a limited timealias ll='ls -lh'→ Create a shortcut for a commandsed -i 's/oldtext/newtext/g' filename→ Find and replace text in a fileawk '{print $1, $3}' file.txt→ Process text files withawk
Conclusion
This advanced Linux cheat sheet provides powerful commands for system administration, networking, security, and performance monitoring. Continue practicing these commands to improve your Linux skills.
Let us know if you need a specialized cheat sheet (e.g., DevOps, Security, or Containers)!
0% complete
0 claps
