Fundamentals 7 min read

15 Essential Linux Command Line Tricks You Might Have Forgotten

This article presents a collection of fifteen practical Linux command‑line techniques—including table‑style output, looping until success, sorting processes, architecture checks, multitail monitoring, directory navigation shortcuts, interactive shell tweaks, watch usage, nohup persistence, yes/no automation, file creation with dd, sudo shortcuts, session recording, character replacement, case conversion, and advanced xargs pipelines—aimed at boosting productivity for everyday terminal users.

Architecture Digest
Architecture Digest
Architecture Digest
15 Essential Linux Command Line Tricks You Might Have Forgotten

1. Display output as a table – Use column‑formatting options (e.g., -s to specify a delimiter) to render command output like mount or /etc/passwd in neatly aligned columns.

2. Run until success – Wrap a command in a while true loop and redirect both stdout and stderr to /dev/null with > /dev/null 2>&1 to repeat it until it succeeds.

3. Sort processes by memory or CPU usage – Use appropriate options (e.g., ps aux --sort=-%mem or ps aux --sort=-%cpu) and display the results as illustrated in the accompanying screenshots.

4. Check your architecture (32‑bit or 64‑bit) – Run uname -m or examine /proc/cpuinfo to determine the system’s bitness.

5. Monitor multiple log files simultaneously – Install and use multitail, which can tail several files with highlighting and filtering.

6. Return to the previous directory – Simply type cd - to jump back to the last visited directory.

7. Turn a non‑interactive shell into an interactive session – Add the necessary initialization lines from ~/.bashrc into ~/.bash_profile.

8. Observe command output continuously – Use watch to run any command repeatedly (e.g., watch df -h) and watch its output change over time.

9. Keep a program running after closing the session – Prefix the command with nohup (e.g., nohup myscript.sh &) to prevent it from being killed when the shell exits; output is saved to nohup.out.

10. Yes/No answer bot – Automate affirmative responses with yes and negative responses with yes | head -n 1 | tr 'y' 'n' (illustrated in the screenshots).

11. Create a file of a specific size – Use dd if=/dev/zero of=sample.bin bs=1M count=10 to generate a 10 MB zero‑filled file.

12. Run the previous command as root – After forgetting to prepend sudo, simply type sudo !! to re‑execute the last command with root privileges.

13. Record your command‑line session – Start script to capture all keystrokes into a typescript file; exit the shell to finish recording.

14. Replace spaces with tabs – Employ tr ' ' '\t' to convert spaces to tab characters in a stream or file.

15. Change case – Use tr 'a‑z' 'A‑Z' to convert text to uppercase.

16. Powerful xargs usage – Pipe lists of arguments (e.g., filenames or URLs) to xargs for batch processing; combine with -i and placeholders ( {}) for more complex commands.

The article concludes by encouraging readers to share additional geeky commands and promises future posts on Linux command‑line tricks.

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.

LinuxproductivityShellcommand-lineUnixScripting
Architecture Digest
Written by

Architecture Digest

Focusing on Java backend development, covering application architecture from top-tier internet companies (high availability, high performance, high stability), big data, machine learning, Java architecture, and other popular fields.

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.