Operations 9 min read

15 Essential Linux Command-Line Tricks to Boost Your Productivity

This article presents fifteen practical Linux command-line techniques—from quickly emptying files and generating large test files to securely erasing disks, monitoring logs, converting timestamps, measuring execution time, handling garbled filenames, retrieving public IPs, batch downloading, and mastering history shortcuts—designed to dramatically improve everyday productivity.

Efficient Ops
Efficient Ops
Efficient Ops
15 Essential Linux Command-Line Tricks to Boost Your Productivity

Hello, I'm XiaoBang, this is my 14th original article.

Linux's power lies in the command line; by combining simple commands you can automate tasks and boost efficiency.

1. Quick ways to empty a file

The shortest method 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 : is a shell builtin representing a no‑op, effectively writing nothing to the file.

2. Generate a large file quickly

Use dd to create a 1 GB file:

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

3. Securely erase a disk

Overwrite the whole disk with random data:

$ dd if=/dev/urandom of=/dev/sda

4. Create a bootable system disk

Write an ISO image directly to a USB drive or disk:

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

5. Show a process’s elapsed time

Use ps -p PID -o etimes,etime to display the running time, or ps -p PID -o rss for memory usage.

$ ps -p 10167 -o etimes,etime

6. Monitor logs in real time

Tail a log file and stop when a pattern appears:

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

7. Convert timestamps

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

$ date +%s

8. Measure program execution time

Use time to get real, user, and sys times: $ time ./test Explanation of the three fields is provided.

9. View ASCII table

$ man ascii

10. Delete files with garbled names

Find the inode and remove the file:

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

11. Get your public IP address

$ curl ip.sb
$ curl ifconfig.me

12. Batch download resources

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

13. History command shortcuts

!!

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

14. Quickly search command history

Press Ctrl+R and type a keyword to search and execute a previous command.

15. Hide sensitive commands from history

Prefix a command with a space so it is not recorded, or clear the history with history -c.

These tips aim to make daily Linux work more efficient.

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.

linuxShellcommand-line
Efficient Ops
Written by

Efficient Ops

This public account is maintained by Xiaotianguo and friends, regularly publishing widely-read original technical articles. We focus on operations transformation and accompany you throughout your operations career, growing together happily.

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.