DevOps Blog

Advanced Linux Commands for Power Users

1. Advanced File & Text Processing

grep – Search Inside Files

Finds 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 Extraction

A 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 Editor

Modifies 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 Search

Locates 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

2. System Monitoring & Performance

dmesg – Kernel & Hardware Logs

Displays 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 Stats

Monitors 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 & Processes

Shows 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

3. Process & Job Management

kill / pkill / killall – Terminate Processes

Stops 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 Jobs

Keeps 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 Jobs

Switches between foreground and background tasks.

Ctrl+Z # Suspend a running process bg %1 # Resume in the background fg %1 # Bring back to foreground

4. Networking & Security

ss / netstat – Network Connections

Displays active connections and ports.

ss -tulnp # Show listening ports & processes netstat -tuln # Older alternative (deprecated on some systems)

tcpdump – Network Packet Sniffing

Captures 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 Management

Controls network traffic rules.

sudo ufw allow 22/tcp # Allow SSH (UFW – simpler) sudo iptables -L # List firewall rules (IPTables – advanced)

openssl – Encryption & Certificates

Checks SSL/TLS certificates and encryption.

openssl s_client -connect example.com:443 # Test SSL connection openssl rand -hex 16 # Generate a random hex string

5. Disk & Filesystem Management

du – Disk Usage by Files

Shows 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 Space

Displays mounted filesystem usage.

df -hT # Human-readable + filesystem type

mount / umount – Manage Filesystems

Mounts and unmounts disks.

sudo mount /dev/sdb1 /mnt # Mount a disk sudo umount /mnt # Unmount safely

rsync – Advanced File Synchronization

Efficiently copies and syncs files.

rsync -avz /source/ user@remote:/dest/ # Sync to remote server rsync --delete -a backup/ archive/ # Mirror with deletions

6. Automation & Scripting

cron / crontab – Schedule Tasks

Runs 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 Inputs

Processes 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 & Compression

Combines and compresses files.

tar -czvf archive.tar.gz /folder # Create a compressed tarball tar -xzvf archive.tar.gz # Extract

Final Thoughts

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!