10 Essential Linux Command-Line Tricks to Boost Your Productivity
This article compiles ten practical Linux command-line shortcuts—from cursor navigation and Vim editing tricks to quick directory switching, file transfer, process lookup, and output logging—each explained with usage scenarios, recommended rating, and exact commands to help developers and operators work faster and more efficiently.
As online systems become more complex, mastering common Linux commands can dramatically improve daily efficiency for developers and operations engineers.
TOP-1: Fast Cursor Movement Shortcuts
Recommendation: ★★★★★
Scenario: Editing long commands where quick navigation is needed.
Methods:
<code>Ctrl + a // Move cursor to the beginning of the line
Ctrl + e // Move cursor to the end of the line
Ctrl + w // Delete the word before the cursor
Esc + b // Move left one word
Esc + f // Move right one word</code>TOP-2: Vim Quick Operations
Recommendation: ★★★★★
Scenario: Editing configuration files.
All actions are performed in Vim's command mode (press
Escfirst if unsure).
<code>:set nu // Show line numbers
:20 // Jump to line 20
:%s/aaa/bbb/g // Replace all "aaa" with "bbb"
ddp // Swap current line with the next line
ci" // Delete content inside double quotes (use ci' for single quotes)</code>TOP-3: Return to Previous Directory
Recommendation: ★★★★★
Scenario: Quickly toggle between two directories.
Command:
cd -Running this command swaps the current directory with the last one you visited.
TOP-4: Cross‑Server File Transfer Without Password
Recommendation: ★★★☆☆
Scenario: Copy files between servers when you cannot use
scpdue to missing passwords.
Method 1 – Using
nc:
<code># On source machine
nc -l 10017 < abc.sh
# On target machine
nc 1.1.1.1 10017 > abc.sh</code>Method 2 – Using a simple Python HTTP server:
<code># On source machine
python -m SimpleHTTPServer 10010
# On target machine
wget http://1.1.1.1:10010/abc.sh</code>TOP-5: Simplify Commands
Recommendation: ★★★★★
Scenario: Quickly clear a file or create an empty one.
Command:
> a.logWhen
a.logexists, this truncates the file; when it does not exist, it creates an empty file.
Quickly repeat the last command’s final argument (space‑separated) by pressing
Escfollowed by
..
TOP-6: Query Local Intranet IP
Recommendation: ★★★★☆
Scenario: Retrieve the machine’s internal IP address.
Command:
hostname -iNote: Works only on machines with DNS resolution;
hostnamechanges the host name, while
hostqueries DNS records.
TOP-7: Quick Redis Connection via Telnet
Recommendation: ★★★★☆
Scenario: When no Redis client is installed.
Command:
telnet 127.0.0.1 6379Use
telnet <redis_host> <port>to connect, but for production prefer a proper Redis client such as
redis-cli.
TOP-8: Send Current Task to Background
Recommendation: ★★★★★
Scenario: Temporarily suspend a foreground process (e.g., editing in Vim) to run another command.
Press
Ctrl+Zto suspend, then run your command (e.g.,
python aaa.py), and return with
fg.
TOP-9: Locate Process Working Directory
Recommendation: ★★★★★
Scenario: Find the directory of a running process.
Command (replace
pidwith the actual process ID):
pwdx pidUseful for identifying where a script like
python test.pyis executing from.
TOP-10: Save Command Output While Viewing It
Recommendation: ★★★★★
Scenario: Log script output and monitor it in real time.
Command:
python test.py | tee a.logThis streams output to the terminal and simultaneously writes it to
a.log, eliminating the need for separate
tail -fsessions.
These tips aim to make your Linux workflow smoother and more efficient.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.