Back to all posts
Linux

10 Advanced Linux Commands You Should Know

By Huzi

If you've moved beyond ls, cd, and grep, you're ready to add some more powerful tools to your Linux command-line arsenal. These advanced commands offer deeper insights into your system's operations, streamline complex tasks, and provide sophisticated ways to manage processes, networks, and files. Here are 10 advanced Linux commands that every developer and system administrator should master.

1. htop - The Interactive Process Viewer

While top is useful, htop is its more intuitive and interactive successor. It provides a real-time, color-coded view of your system's processes, CPU usage, memory, and swap.

Why it's better:

  • Visual Interface: Easy-to-read layout with bar graphs for CPU and memory.
  • Interactive Commands: You can scroll through processes, kill them with a keypress (F9), change their priority (F7/F8), and filter by user.
  • No sudo needed for basic viewing.

How to install and run:

sudo apt-get install htop  # Debian/Ubuntu
sudo dnf install htop     # Fedora/CentOS
htop

2. ss - The Modern Netstat

ss (socket statistics) is the modern replacement for the classic netstat command. It's faster and provides more detailed information about network connections.

Why it's better:

  • Performance: ss gets its information directly from the kernel space, making it much faster than netstat, which parses /proc/net/tcp.
  • Detailed Output: It can show you which process is using a particular socket.

Common Usage:

# List all listening TCP ports and the processes using them
sudo ss -ltp

# List all established connections to port 443 (HTTPS)
ss -o state established '( dport = :443 or sport = :443 )'

3. find - The Ultimate File Searcher

The find command is incredibly powerful for locating files and directories based on a wide range of criteria.

Key Features:

  • Search by name, type, size, modification time, permissions, and owner.
  • Execute commands on found files.

Practical Examples:

# Find all .log files in /var/log modified in the last 7 days
find /var/log -name "*.log" -mtime -7

# Find all files larger than 100MB in your home directory
find ~ -size +100M

# Find all directories with permission 777 (a security risk) and print them
find / -type d -perm 777 -print

# Find all files ending in .tmp and delete them
find . -name "*.tmp" -delete

4. awk - The Data-Wrangling Powerhouse

awk is a versatile programming language for pattern scanning and processing. It's perfect for manipulating text files and producing formatted reports.

Core Concept: awk processes a file line by line, splitting each line into fields. You provide it with a pattern to match and an action to perform.

Example: Find the total size of files listed by ls -l. The 5th column of ls -l is the file size. awk can sum this column.

ls -l | awk '{sum += $5} END {print sum}'

This command tells awk to add the value of the 5th field ($5) to the sum variable for every line. After processing all lines (END), it prints the final sum.

5. tmux - The Terminal Multiplexer

tmux (Terminal Multiplexer) lets you manage multiple terminal sessions within a single window. It's a lifesaver for remote work.

Killer Features:

  • Persistent Sessions: Detach from a session and your processes (like a long-running script or server) keep running. Reattach later from any machine.
  • Panes and Windows: Split your terminal into multiple vertical or horizontal panes. Organize related tasks into different windows.

Basic Commands (run inside a tmux session):

  • tmux new -s my_session - Start a new named session.
  • Ctrl+b, d - Detach from the current session.
  • tmux attach -t my_session - Reattach to a session.
  • Ctrl+b, % - Split pane horizontally.
  • Ctrl+b, " - Split pane vertically.
  • Ctrl+b, c - Create a new window.

6. rsync - The Smarter cp

rsync is a fast and versatile tool for copying and synchronizing files and directories, either locally or remotely.

Why it's better than scp or cp:

  • Delta-Transfer Algorithm: It only copies the differences between the source and destination files, making subsequent syncs incredibly fast.
  • Resumes Transfers: If a transfer is interrupted, it can resume from where it left off.
  • Preserves Permissions: It can preserve permissions, timestamps, and ownership.

Common Usage:

# Sync a local directory to a remote server
rsync -avz /local/path/ user@remote_host:/remote/path/

# The -a flag is for "archive" mode (preserves permissions, etc.)
# The -v flag is for "verbose"
# The -z flag is for "compress"

7. nc - The Network Swiss Army Knife

nc (netcat) is a powerful utility for reading from and writing to network connections using TCP or UDP.

Use Cases:

  • Port Scanning: Check if a port is open on a remote host.
    nc -zv google.com 80 443
    
  • Simple Chat: On machine 1, nc -l 1234. On machine 2, nc <machine1_ip> 1234.
  • File Transfer: On the receiving end, nc -l 1234 > received_file. On the sending end, nc <receiver_ip> 1234 < file_to_send.

8. xargs - Building Commands from Input

xargs is used to build and execute command lines from standard input. It breaks up long lists of arguments into smaller chunks that can be processed by other commands.

Example: You have a file with a list of filenames you want to delete. rm might fail if the list is too long. xargs handles this gracefully.

cat file_list.txt | xargs rm

9. strace - The System Call Tracer

strace is an invaluable debugging tool that intercepts and records the system calls made by a process and the signals it receives.

When to use it: If a program is failing and giving cryptic error messages, strace can show you exactly what it was trying to do when it failed (e.g., trying to open a file that doesn't exist).

strace ls /non-existent-directory

The output will show the openat system call failing with ENOENT (No such file or directory).

10. jq - The sed for JSON

jq is a lightweight and flexible command-line JSON processor. It's like sed or awk but specifically for structured JSON data.

Example: You have a JSON file users.json and you want to extract the email of every user.

// users.json
[
  {"name": "Alice", "email": "[email protected]"},
  {"name": "Bob", "email": "[email protected]"}
]
cat users.json | jq '.[].email'
"[email protected]"
"[email protected]"

Mastering these commands will not


You Might Also Like


Related Posts

Linux
Fresh Arch Linux Install? Here Are My Top 10 Cozy Setup Tips
A personal, cozy guide to the top 10 essential things to do after installing Arch Linux, from updating your system and enabling multilib to customizing your UI and optimizing performance. Your friendly first steps into a beautiful, personalized Arch setup.

By Huzi

Read More
Linux
Fix: Wi-Fi Not Working After Arch Linux Installation (2025 Guide)
A complete 2025 guide to fix common Wi-Fi issues on Arch Linux after installation. Learn how to enable NetworkManager, install drivers, and troubleshoot your wireless adapter.

By Huzi

Read More
Linux
How to Install Arch Linux on a PC or Laptop (2025 Edition)
A clear, step-by-step guide for moving from Windows to Arch Linux, covering everything from booting the USB to logging into your new Arch desktop.

By Huzi

Read More
Linux
A Beginner's Guide to the Linux World
New to Linux? This guide will walk you through the basics, from understanding what it is to choosing your first distribution and mastering the command line.

By Huzi

Read More
Linux
Fresh Arch Linux Install? My Top 10 Cozy Setup Tips
A personal, cozy guide to the first 10 things to do after installing Arch Linux. Join Huzi as he walks you through updating, enabling multilib, installing an AUR helper like yay, and customizing your desktop.

By Huzi

Read More
Linux
A Beginner's Daydream: Choosing a Desktop for Arch Linux in 2025
A poetic and personal exploration of Arch Linux's best desktop environments in 2025. Join Huzi as he muses on KDE, XFCE, and GNOME, weaving in performance benchmarks with a touch of chai-fueled wonder.

By Huzi

Read More
Linux
Top Lightweight Linux Distros for Old Laptops (2025 Edition)
Revive your old laptop with the best lightweight Linux distros of 2025. This guide compares Arch Linux, MX Linux, Linux Lite, and Peppermint OS, with performance benchmarks on RAM and CPU usage.

By Huzi

Read More
Linux
Install NVIDIA & Intel Graphics Drivers in Arch Linux (2025 Guide)
Learn to install, configure, and troubleshoot NVIDIA and Intel graphics drivers on Arch Linux. This 2025 guide covers hardware acceleration, hybrid graphics, and common issues.

By Huzi

Read More
Lifestyle
Complete Guide to Applying for a Driving Learner’s Permit Online in Pakistan (2025)
In 2025, your learner’s permit prints faster than a restaurant bill—if you follow the digital roadmap.

By blogs.huzi.pk

Read More
Education
EdTech in Pakistan 2025: How AI-Powered Learning Is Transforming Classrooms
A look into how AI and EdTech platforms like Maqsad and Taleemabad are reshaping classrooms in Pakistan, from personalized learning to teacher support.

By Huzaifa

Read More
Lifestyle
Crispy Chicken Manchurian (Restaurant Style)
Manchurian is the ultimate East-meets-West masquerade – crispy chicken waltzing in a glossy, sweet-chili embrace.

By Huzi

Read More