Fundamentals 9 min read

15 Essential Linux Command‑Line Tricks to Boost Your Productivity

This article presents a collection of fifteen practical Linux command‑line techniques—including fast file clearing, large file generation, secure disk wiping, process timing, log monitoring, timestamp conversion, and history shortcuts—to help users automate tasks and work more efficiently.

Liangxu Linux
Liangxu Linux
Liangxu Linux
15 Essential Linux Command‑Line Tricks to Boost Your Productivity

Linux users know that the command line is a powerful tool for automating repetitive tasks and increasing efficiency. The following fifteen tips demonstrate concise commands and shortcuts that can be immediately applied in everyday workflows.

1. Quickly empty a file

The shortest way to truncate a file is: $ > access.log Other common methods include:

: > access.log
true > access.log
cat /dev/null > access.log
echo -n "" > access.log
echo > access.log
truncate -s 0 access.log

The built‑in : command is a no‑op; it writes nothing, effectively overwriting the file with empty content.

2. Generate a large file quickly

Use dd to create a test file of a specific size, e.g., 1 GB:

$ dd if=/dev/zero of=file.img bs=1M count=1024

3. Securely erase a disk

Overwrite a whole disk with random data using dd and /dev/urandom: $ dd if=/dev/urandom of=/dev/sda This method provides a simple way to securely delete all data on the target drive.

4. Create a bootable system USB

Write an ISO image directly to a USB device (or any block device) with a single command:

$ dd if=ubuntu-server-amd64.iso of=/dev/sdb

5. Show a process’s elapsed time

Instead of the generic ps aux, specify the -o option to display only the desired fields: $ ps -p 10167 -o etimes,etime Use etime to see that the process has been running for 19 days.

6. Monitor logs in real time

Tail a log file continuously: $ tail -f test.log Stop automatically when a line containing "Failed" appears:

$ tail -f test.log | sed '/Failed/ q'

7. Convert timestamps

Convert a Unix timestamp to a readable date: $ date -d@1234567890 +"%Y-%m-%d %H:%M:%S" Show the current timestamp:

$ date +%s

8. Measure program execution time

Use the time command: $ time ./test The output shows real (wall‑clock time), user (CPU time in user space), and sys (CPU time in kernel space). Differences arise when the program blocks (e.g., sleep, I/O) or runs on multiple CPUs.

9. View ASCII table

Display the ASCII reference directly in the terminal:

$ man ascii

10. Delete files with garbled names

Find a file by its inode number and remove it:

$ ls -i
$ find . -inum 132395 -exec rm {} \;

11. Get your public IP address

Query an external service with curl:

$ curl ip.sb
$ curl ifconfig.me

12. Batch download web resources

Recursively download all PDF files from a site using wget:

$ wget -r -nd -np --accept=pdf http://fast.dpdk.org/doc/pdf-guides/

13. History command shortcuts

!!

– repeat the previous command. !N – repeat command number N from history. !pw – repeat the most recent command starting with pw. !$ – expand to the last argument of the previous command.

14. Quickly search command history

Press Ctrl+r and type a keyword to perform an incremental reverse search through the history.

15. Prevent a command from being saved in history

Prefix the command with a space; Bash will skip recording it, which is useful for commands containing sensitive information.

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.

Shellcommand-lineUnix tools
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

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.