Operations 12 min read

Useful Linux Command‑Line Tips to Boost Productivity

This article presents a collection of practical Linux command‑line shortcuts and techniques—including cursor navigation, history execution, disk and memory inspection, process management, multi‑command chaining, and file handling—that can significantly improve efficiency for developers and system administrators.

Full-Stack Internet Architecture
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Useful Linux Command‑Line Tips to Boost Productivity

Preface

Some handy Linux tricks can greatly increase your work efficiency; this article lists simple yet effective command‑line techniques.

Command Editing and Cursor Movement

Various shortcuts help edit commands. The term “cursor” denotes the current position.

Delete text from the beginning to the cursor

Use Ctrl+U. Example: $ cd /proc/tty; ls -al Pressing Ctrl+U clears the entire line without holding Backspace.

Delete text from the cursor to the end

Use Ctrl+K. Example:

$ cd /proc/tty; ls -al
Ctrl+K

removes everything from the cursor to the end of the line.

Ctrl+A : move cursor to the beginning of the command.

Ctrl+E : move cursor to the end of the command.

Alt+F : move cursor forward one word.

Alt+B : move cursor backward one word.

Ctrl+W : delete the word before the cursor.

Quick Execution of History Commands

The history list stores previous commands; using !<number> re‑executes a specific entry. See the linked article for details. Ctrl+R also searches the history.

Viewing Partial History

history

shows all entries, while fs -l displays a subset.

Real‑Time Log Viewing

$ tail -f filename.log
tail -f

follows a log file; less with Shift+F achieves a similar effect.

Disk or Memory Usage Inspection

How to know if a disk is full

$ df -h
df -h

shows human‑readable usage for each mounted filesystem.

Directory size summary

$ du -h --max-depth=1 /home

Limits recursion depth to list sub‑directory sizes.

Current memory usage

$ free -h

The free -h output displays total, used, and free memory in a readable format.

Purpose of the -h flag

It makes command output human‑readable (e.g., G, M). Without it, raw numbers are shown.

Find Process ID by Name

$ pgrep hello
$ pidof hello

Both return the PID of the process named hello.

Kill Process by Name

$ killall hello
$ pkill hello

These commands terminate all processes matching the name.

Check Process Runtime

$ ps -p 24525 -o lstart,etime

Shows the start time and elapsed time for PID 24525.

Quick Directory Switching

cd - : return to the previous directory.

cd : go to the home directory.

Executing Multiple Commands

Separate commands with a semicolon ( ;) to run them sequentially, regardless of success. $ cd /temp/log; rm -rf * If the first command fails, the second still runs. Use && to ensure the second runs only on success:

$ cd /temp/log && rm -rf *

Viewing Compressed Log Files

$ zcat test.gz
$ zless test.gz

Both display compressed logs without explicit decompression.

Delete Files with Garbled Names

Refer to the linked article for various methods to remove files with unusual or corrupted filenames.

Empty a File

> filename

Redirects nothing into the file, truncating its contents.

Log to File and Console Simultaneously

$ ./test.sh | tee test.log
tee

writes output to both a file and the terminal.

Pause and Resume a Process

Press Ctrl+Z to suspend a process, then use fg to resume in the foreground or bg to continue in the background.

Measure Program Execution Time

$ time ./fibo 30

The time command reports real, user, and system durations.

Show Top 10 Memory‑Consuming Processes

$ ps -aux | sort -k4nr | head -n 10

Combines ps, sort, and head to list the heaviest processes.

Quickly Find a Command

$ man -k "copy files"

Searches manual pages for keywords related to copying files.

Copy‑Paste in the Terminal

Ctrl+Insert

Shift+Insert

Search Files Containing a String

$ grep -rn "test"

Finds files and line numbers where the string appears.

Freeze Terminal Output

Press Ctrl+S to pause scrolling; press Ctrl+Q to resume.

Edit a Text File Without an Editor

$ cat >file.txt
some words
(ctrl+d)

Ends input with Ctrl+D to save.

Inspect ELF Files

View ELF header

$ readelf -h filename

Check for a specific symbol

$ nm filename | grep interface

Shows whether the binary contains the given interface symbol.

Conclusion

Try these Linux tricks on your own machine to experience the benefits. Share any additional tips you know in the comments.

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.

OperationsproductivityShellBash
Full-Stack Internet Architecture
Written by

Full-Stack Internet Architecture

Introducing full-stack Internet architecture technologies centered on Java

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.