Advanced Linux Commands for Power Users
grep
– Search Inside FilesFinds text patterns in files using regex.
grep "error" log.txt # Search for "error" in a file
grep -r "pattern" /folder/ # Recursively search in directories
grep -i "case" file.txt # Case-insensitive search
awk
– Text Processing & Data ExtractionA powerful tool for parsing and manipulating structured text.
awk '{print $1}' file.txt # Print the first column
awk -F':' '{print $1}' /etc/passwd # Print usernames from /etc/passwd
sed
– Stream EditorModifies text in files or streams.
sed 's/old/new/g' file.txt # Replace "old" with "new" globally
sed -i 's/foo/bar/' file.txt # Edit file in-place
sed '/pattern/d' file.txt # Delete lines containing "pattern"
find
– Advanced File SearchLocates files based on name, size, permissions, and more.
find /home -name "*.log" # Find all .log files in /home
find / -size +100M # Find files larger than 100MB
find . -type f -mtime -7 # Find files modified in the last 7 days
dmesg
– Kernel & Hardware LogsDisplays boot and kernel messages.
dmesg | grep "error" # Filter for errors
dmesg --follow # Real-time kernel logs
journalctl
– Systemd Logs (Modern Linux)Views and filters system logs.
journalctl -xe # View recent logs with details
journalctl -u nginx --no-pager # Check logs for a specific service
journalctl --since "1 hour ago" # Show logs from the last hour
iostat
/ vmstat
/ mpstat
– System StatsMonitors CPU, disk, and memory performance.
iostat -x 2 # Disk I/O stats every 2 seconds
vmstat 1 # Memory & CPU usage every second
mpstat -P ALL # Detailed CPU core stats
lsof
– List Open Files & ProcessesShows which files and ports are in use.
lsof -i :80 # Find processes using port 80
lsof -u username # List files opened by a user
lsof +D /var/log # See which processes are accessing /var/log
kill
/ pkill
/ killall
– Terminate ProcessesStops misbehaving applications.
kill 1234 # Kill process with PID 1234
pkill -f "nginx" # Kill by process name
killall firefox # Kill all instances of Firefox
nohup
& disown
– Run Persistent Background JobsKeeps processes running after logout.
nohup ./script.sh & # Run script in background (survives logout)
disown -h %1 # Detach a job from the terminal
bg
& fg
– Manage Background JobsSwitches between foreground and background tasks.
Ctrl+Z # Suspend a running process
bg %1 # Resume in the background
fg %1 # Bring back to foreground
ss
/ netstat
– Network ConnectionsDisplays active connections and ports.
ss -tulnp # Show listening ports & processes
netstat -tuln # Older alternative (deprecated on some systems)
tcpdump
– Network Packet SniffingCaptures and analyzes network traffic.
sudo tcpdump -i eth0 # Monitor traffic on eth0
sudo tcpdump port 80 -w capture.pcap # Save HTTP traffic to a file
ufw
/ iptables
– Firewall ManagementControls network traffic rules.
sudo ufw allow 22/tcp # Allow SSH (UFW – simpler)
sudo iptables -L # List firewall rules (IPTables – advanced)
openssl
– Encryption & CertificatesChecks SSL/TLS certificates and encryption.
openssl s_client -connect example.com:443 # Test SSL connection
openssl rand -hex 16 # Generate a random hex string
du
– Disk Usage by FilesShows file and directory sizes.
du -sh * # Human-readable sizes in current dir
du -h --max-depth=1 / # Check largest directories in root
df
– Filesystem Disk SpaceDisplays mounted filesystem usage.
df -hT # Human-readable + filesystem type
mount
/ umount
– Manage FilesystemsMounts and unmounts disks.
sudo mount /dev/sdb1 /mnt # Mount a disk
sudo umount /mnt # Unmount safely
rsync
– Advanced File SynchronizationEfficiently copies and syncs files.
rsync -avz /source/ user@remote:/dest/ # Sync to remote server
rsync --delete -a backup/ archive/ # Mirror with deletions
cron
/ crontab
– Schedule TasksRuns commands at scheduled times.
crontab -e # Edit user’s cron jobs
* * * * * /path/script # Run every minute
0 3 * * * /backup.sh # Run daily at 3 AM
xargs
– Run Commands on Multiple InputsProcesses lists of files/arguments.
find . -name "*.log" | xargs rm # Delete all .log files
echo {1..5} | xargs -n1 touch # Create files 1 to 5
tar
/ gzip
– Archive & CompressionCombines and compresses files.
tar -czvf archive.tar.gz /folder # Create a compressed tarball
tar -xzvf archive.tar.gz # Extract
Mastering these advanced Linux commands will significantly boost your productivity and troubleshooting skills. Whether you're managing servers, analyzing logs, or automating tasks, these tools are essential for power users.
Want to go even deeper? Stay tuned for our next guide: "Linux Shell Scripting for Automation"!
Did we miss any of your favorite advanced commands? Let us know in the comments!
Found this helpful? Share it with fellow Linux pros!
Happy hacking!