Operations 22 min read

50 Essential Linux Command‑Line Tricks to Boost Your Productivity

This article compiles over fifty practical Linux command‑line techniques—from identifying non‑user processes and batch‑replacing text across files to managing X sessions, optimizing disk performance, and automating monitoring—providing concise commands and explanations that help developers and sysadmins work faster and more efficiently.

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

1. List Processes Not Started by You

Show all processes owned by other users. Running as root reveals most background services. ps aux | grep -v $(whoami) Show the ten most CPU‑intensive processes (excluding your own):

ps aux --sort=-%cpu | grep -m 11 -v $(whoami)

2. Replace Text Across Multiple Files

In‑place replacement with Perl: perl -i -pe 's/Windows/Linux/;' test* Recursively replace in all .txt files:

find . -name '*.txt' -print0 | xargs -0 perl -pi -e 's/Windows/Linux/ig'

3. Reset a Corrupted Terminal

If the terminal display becomes garbled, run the built‑in command:

reset

4. Create a Firefox Keyword Shortcut

Add a bookmark with a keyword (e.g., gg) and URL http://www.google.com/search?q=%s. Typing gg your‑query in the address bar performs a Google search.

5. Run Multiple X Sessions

Start an additional X server on display :1: startx -- :1 Switch between virtual consoles with Ctrl+Alt+F1…F6 and between X sessions with Ctrl+Alt+F7…F12.

6. Speed Up Web Browsing in KDE

Enable pre‑loading of browser instances via KDE System Settings → KDE Performance. This keeps the browser process ready, making startup virtually instantaneous.

7. Simple rsync Backup

Copy only changed files from a remote host to a local backup directory:

rsync -av -e ssh [email protected]:/home/jono/importantfiles/* /home/jono/backup/

8. Keep System Clock Accurate

Synchronize the system clock with an NTP server: ntpdate ntp.blueyonder.co.uk Additional public NTP server lists are available at www.eecis.udel.edu/~mills/ntp/clock1b.html.

9. Find the Largest Files and Directories

List files sorted by size (largest last) with human‑readable units: ls -lSrh Find the biggest MP3/MPEG files: ls -lSrh *.mp* Show the largest directories (by total size):

du -kx | egrep -v "\./.+/" | sort -n

10. Nautilus Keyboard Shortcuts

Ctrl+L

– focus the location bar. Ctrl+Up – go to the parent folder.

Arrow keys – navigate files.

Use Edit → Backgrounds and Emblems to add custom icons.

11. Optimize MySQL Databases

After structural changes or massive deletions, run the optimizer to defragment tables: mysqlcheck -o <database_name> For tables with large VARCHAR columns, periodically execute OPTIMIZE TABLE to prevent fragmentation.

12. Faster Email with KMail

Open a new mail window directly from a browser using a mailto: link, e.g.: mailto:[email protected] The same approach works for URLs (e.g., www.slashdot.org) to launch the default browser.

13. Parallel Builds with GCC/Make

Utilize all CPU cores on SMP systems by adding the -j flag to make:

make -j4
make -j4 modules

14. Save Battery Power with hdparm

Put a hard drive into standby, sleep, or set an automatic spin‑down timeout:

hdparm -y /dev/hdb      # standby
hdparm -Y /dev/hdb      # sleep
hdparm -S 36 /dev/hdb   # auto spin‑down after 5 min (36×5 s)

15. Manage Wireless Speed with iwconfig

Force a specific transmission rate (useful when the signal is weak):

iwconfig eth0 rate 2M               # force 2 Mbps
iwconfig eth0 rate 5.5M auto       # set 5.5 Mbps as upper limit, allow auto‑downgrade
iwconfig eth0 rate auto            # revert to automatic mode

16. List Listening Ports

Show all services that are listening for incoming connections:

netstat -lnp

17. Accelerate Hard‑Drive Performance

Benchmark read speed: hdparm -Tt /dev/hda Display current drive settings: hdparm /dev/hda Enable DMA and 32‑bit I/O for higher throughput:

hdparm -c3 -d1 /dev/hda

18. Show Load Average in the Terminal Title

Save the following Perl script as tl in ~/bin and make it executable ( chmod +x ~/bin/tl). Running it in the background updates the terminal title with the current load average.

#!/usr/bin/perl -w
use strict;
$|++;
my $host = `/bin/hostname`;
chomp $host;
while (1) {
    open my $fh, '/proc/loadavg' or die "Can't open /proc/loadavg: $!";
    my @load = split / /, <$fh>;
    close $fh;
    print "\e]0;$host: $load[0] $load[1] $load[2]\a";
    sleep 2;
}

Start it with tl &.

19. Capture a Screenshot Without X

From a virtual console, switch to the X display, capture the root window with ImageMagick, then return:

chvt 7; sleep 2; import -display :0.0 -window root sshot1.png; chvt 1

20. Remote X Application Access

Enable X11 forwarding in /etc/ssh/sshd_config by setting X11Forwarding yes. Then run a graphical program on a remote host, for example:

ssh -X 192.168.0.2 gimp

21. Using the man Pages

Search for topics containing a keyword: man -k login Within a man page, press / to search for a specific term.

22. Emacs Doctor Mode

Enter a whimsical “doctor” dialogue (a simple text‑based game) by typing:

Esc X tetris

23. Visualize Debian Package Dependencies

Install Graphviz ( apt-get install graphviz) and generate a DOT file of package relationships: apt-cache dotty > debian.dot Render the graph with:

dotty debian.dot

24. Identify Files Preventing Unmount

Find processes that are using a mount point (e.g., /mnt/windows) with: lsof +D /mnt/windows Terminate the offending processes using kill if necessary.

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.

command-lineNetworkingperl
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.