Introduction

Linux is renowned for its flexibility and power, offering unmatched tools for managing systems, automating tasks, and handling complex workflows. If you’re a beginner, start with our guide: Introduction to Linux: Master the Basic Commands.

This guide is tailored for users who already understand the basics and are ready to delve into intermediate Linux commands. These commands will empower you to monitor systems, manipulate data, and automate repetitive tasks efficiently. Let’s dive into the depths of Linux!


1. Advanced File and Directory Management

Find files matching specific criteria (find)

find /path/to/directory -name "*.log" -size +10M

Find .log files larger than 10MB in the specified directory.

Quickly locate files (locate)

locate config.yaml

Searches for the file config.yaml using an indexed database.

Check disk usage for directories (du)

du -sh /home/user

Displays the total disk space used by /home/user in a human-readable format.

View disk space usage (df)

df -h

Shows available and used disk space on all mounted filesystems.

Get detailed file information (stat)

stat file.txt

Displays metadata for file.txt, such as size, permissions, and timestamps.

List block devices (lsblk)

lsblk

Displays connected storage devices and their partition structure.


2. System Monitoring and Diagnostics

Monitor system processes interactively (htop)

htop

Provides a colorful and user-friendly display of system processes.

Check disk I/O usage (iotop)

sudo iotop

Monitors processes that are consuming the most disk I/O.

Analyze memory usage (free)

free -h

Displays system memory usage in human-readable format.

View system uptime and load averages (uptime)

uptime

Shows how long the system has been running and its average load.

Examine kernel logs (dmesg)

dmesg | tail -20

Displays the last 20 kernel log messages, useful for troubleshooting hardware issues.


3. Advanced Text and Data Processing

Search for patterns in files (grep)

grep "ERROR" /var/log/syslog

Finds all lines containing the word “ERROR” in the system log file.

Process and extract structured text (awk)

awk '{print $1, $3}' data.txt

Prints the first and third columns from data.txt.

Edit text dynamically (sed)

sed 's/old-text/new-text/g' file.txt

Replaces all instances of “old-text” with “new-text” in file.txt.

Compare files for differences (diff)

diff file1.txt file2.txt

Displays the differences between file1.txt and file2.txt.

Count words, lines, and characters (wc)

wc -l file.txt

Counts the number of lines in file.txt.


4. Networking and Automation

Test network connectivity (ping)

ping google.com

Checks the connection to Google’s servers.

Trace network paths (traceroute)

traceroute google.com

Displays the route packets take to reach Google’s servers.

List active network connections (ss)

ss -tuln

Shows active TCP and UDP connections and listening ports.

Download files from the web (wget and curl)

wget https://example.com/file.zip
curl -O https://example.com/file.zip

Downloads a file from the provided URL using wget or curl.

Schedule recurring tasks (crontab)

crontab -e

Opens the cron table editor to schedule periodic tasks.


5. Automation and Task Scheduling

Create command shortcuts (alias)

alias update="sudo apt update && sudo apt upgrade -y"

Defines an alias update to run system updates with a single command.

Review your command history (history)

history | grep "apt"

Searches your command history for entries containing “apt”.


Conclusion

Intermediate Linux commands bridge the gap between beginner skills and advanced system management. By mastering these tools, you can optimize workflows, diagnose problems, and automate tasks, significantly boosting your productivity.

If you’re new to Linux, revisit our Introduction to Linux: Master the Basic Commands guide. It’s an excellent foundation for exploring the tools discussed here.

For more in-depth content on Linux, Data Engineering, Data Science, and other technologies, visit our YouTube channel: For-Devs.com, where we’re constantly growing and sharing the latest innovations.