๐ง Expand Your Linux Skills with These 5 Advanced Commands and Examples๐ฅ๏ธ๐ง


Mastering these Linux commands can make you feel like a real power user ๐ช. Letโs explore top 5 advanced commands, what they do, and how they help in real-world situations.
1. ๐ strace
โ Trace System Calls and Signals
๐ฆ What it does:strace
helps you see what a program is doing in the background, like reading files, writing data, or making system calls.
๐ ๏ธ Real-life Example:
Your program is crashing, and you donโt know why. Use strace
to trace whatโs going on behind the scenes.
strace ./my_app
๐ Youโll find out:
Which files are opened
Missing libraries
Permission errors
๐ Pro Tip:
Want to trace a running process?
strace -p 1234
Where 1234
is your process ID (PID).
2. ๐งช lsof
โ List Open Files
๐ฆ What it does:
Shows all open files by processes. In Linux, everything is a file โ ports, devices, logs!
๐ ๏ธ Real-life Example:
You canโt start your server on port 8080. Something is already using it?
lsof -i :8080
๐ Youโll find out:
Which process is using that port
The PID so you can kill it
Whether the port is TCP/UDP
๐ Pro Tip:
Find open files in a folder:
lsof +D /var/log
3. ๐ htop
โ Interactive Process Viewer
๐ฆ What it does:
An advanced, colorful and interactive version of top
. Monitor system performance and manage processes in real-time.
๐ ๏ธ Real-life Example:
Your server is slow. Use htop
to quickly check which process is eating all the CPU or RAM.
htop
๐ You can:
Sort processes by memory, CPU
Kill tasks with one key
Monitor load, uptime, cores
๐ Pro Tip:
Use arrow keys to navigate, F9
to kill a process.
4. ๐งฌ awk
โ Pattern Scanning & Text Processing
๐ฆ What it does:awk
is like a mini-programming language for manipulating text โ great for log files and reports.
๐ ๏ธ Real-life Example:
You want to analyze Apache logs and get a list of all IPs.
awk '{print $1}' access.log
๐ You can also:
Do calculations:
awk '{sum+=$2} END {print sum}' file.txt
Filter text:
awk '$3 > 100' file.txt
๐ Pro Tip:
Combine with ps
to extract useful data:
ps aux | awk '{print $1, $3, $11}'
Shows: user, CPU usage, and command.
5. ๐ก๏ธ iptables
โ Manage Firewall Rules
๐ฆ What it does:
Controls the incoming and outgoing network traffic using rules.
๐ ๏ธ Real-life Example:
You want to allow SSH (port 22) but block everything else.
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
sudo iptables -P INPUT DROP
๐ Youโll be able to:
Open/close ports
Block IPs
Protect your server
๐ Pro Tip:
Check all rules with:
sudo iptables -L
โ Summary Table
๐ง Command | ๐ก Purpose | ๐ Use Case Example |
strace | Debug system calls | Debug why an app crashes |
lsof | Show open files/ports | Find which app uses port 8080 |
htop | Monitor performance | Kill high CPU usage processes interactively |
awk | Text processing | Extract IPs from logs or filter large files |
iptables | Manage network/firewall rules | Allow SSH, block everything else |
๐ Conclusion
Learning and using these advanced Linux commands can supercharge your productivity, help you troubleshoot faster, and give you greater control over your system. Whether youโre managing a live server, analyzing logs, or debugging a stubborn error โ these tools are must-haves in your Linux toolbox. ๐งฐ๐ง
โจ Keep practicing and try combining commands in shell scripts to automate your tasks. The more you explore, the more powerful Linux becomes! ๐ป๐
Subscribe to my newsletter
Read articles from Danish Tamboli directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
