Operations 9 min read

Essential Linux Command-Line Tricks Every Engineer Should Know

This guide compiles a collection of practical Linux command‑line tricks—from formatting command output into tables and repeatedly executing commands until success, to sorting processes by resource usage, monitoring with watch, automating responses, creating files, and leveraging powerful tools like xargs—helping engineers work more efficiently in a Linux environment.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Essential Linux Command-Line Tricks Every Engineer Should Know

As a daily Linux engineer, I rely heavily on the command line and often forget useful tricks unless I practice them, so I gathered a set of handy tips to avoid future forgetfulness.

Display command output as a clear table

Typical command output can be a tangled mess, e.g., the mount command. Adding column -t formats it into a readable table. mount | column -t You can also change the delimiter, for example using a colon:

cat /etc/passwd | column -t -s:

Repeat a command until it succeeds

Many users search for ways to keep retrying a command until it works. A simple while true loop can achieve this.

The redirection >/dev/null 2>&1 discards both standard output and error.

Sort processes by memory usage

ps aux | sort -rnk 4

Sort processes by CPU usage

ps aux | sort -nk 3

To check your machine architecture, run getconf LONG_BIT.

View multiple log files simultaneously

The multitail command can monitor several logs with highlighting and filtering.

Install it with apt-get install multitail.

Return to the previous directory

Simply use cd - to go back.

Make a non‑interactive shell session interactive

Switch your startup file from ~/.bashrc to ~/.bash_profile.

Periodic monitoring of command output

Use watch (e.g., watch df -h) to repeatedly display any command’s output.

Keep a program running after the session ends

Run commands with nohup to prevent them from being terminated when the shell closes.

nohup wget site.com/file.zip

The output is saved to nohup.out.

Automatically answer Yes or No

Use yes to feed affirmative responses: yes | apt-get update. To answer “No”, pipe yes no into the command.

Create a file of a specific size

Use dd to generate a file of a given size, e.g., a 10 MB zero‑filled file:

dd if=/dev/zero of=out.txt bs=1M count=10

Run the last command as root

If you forget to prepend sudo, simply type sudo !! to re‑execute the previous command with root privileges.

Record a shell session

Use script to capture everything typed in the terminal into a file (e.g., typescriptscript), which is finalized when you exit.

Replace spaces with another delimiter

The tr command can substitute any character. Example:

cat geeks.txt | tr ':' '\t' > out.txt

Convert file content to upper or lower case

Example to convert to uppercase:

cat myfile | tr a-z A-Z > output.txt

Powerful xargs command

xargs

feeds the output of one command as arguments to another. Examples:

find . -name "*.png" -type f -print | xargs tar -cvzf images.tar.gz
cat urls.txt | xargs wget

Use -i with a placeholder to insert each item into a command:

ls /etc/*.conf | xargs -i cp {} /home/likegeeks/Desktop/out

These are just a few of the many Linux command‑line tricks; tools like awk and sed can further extend your capabilities.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxproductivitySysadmincommand-line
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.