Operations 9 min read

7 Hidden Linux Tricks Every Sysadmin Should Know

Discover seven lesser‑known Linux tricks—from interactive history search with Ctrl + R and one‑off task scheduling using at, to powerful man page regex searches, alternative binary management, secure file shredding, automatic path correction, and quick directory return—each boosting productivity and deepening command‑line mastery.

ITPUB
ITPUB
ITPUB
7 Hidden Linux Tricks Every Sysadmin Should Know

1. Interactive History Search

While most users know the history command, searching for a specific URL among many curl entries can be cumbersome. Linux provides an interactive reverse‑search mode: press Ctrl+R, type part of the command, and the shell cycles through matching entries. Press Enter to execute the found command or use the arrow keys to edit it before running.

2. One‑Off Task Scheduling with at

The cron daemon is ideal for recurring jobs, but for a single execution you can avoid editing crontab by using the at command. It accepts a rich set of time specifications, such as absolute dates, relative offsets, or “tomorrow”.

at 12:00 PM September 30 2017
at now +1 hour
at 9:00 AM tomorrow

After entering the command, type the command to run, finish the input with Ctrl+D (which displays EOF), and the job is scheduled. Use atq to list pending jobs and atrm <job‑id> to cancel one.

3. Find Commands by Description

Remembering exact command names can be hard for beginners. The man utility lets you search by keyword or regular expression. For example, man build filesystem returns pages whose description matches those terms. Adding the -R option enables regex‑based searches across manual pages.

4. Managing Multiple Versions with the Alternatives System

Many Linux distributions include an “alternatives” mechanism (e.g., /etc/alternatives) that lets you switch between different implementations of the same command, such as Java, Node.js, or Ruby. On Debian‑based systems you use update-alternatives, while on CentOS the tool is called alternatives. By changing the symlink target, you can select which version runs by default without altering scripts.

5. Secure Deletion with shred

The usual rm command only removes directory entries, leaving the underlying data on disk until it is overwritten. The shred utility overwrites a file’s contents multiple times, optionally adding a final pass of zeros, making recovery extremely difficult. shred -u -z [filename] You can also specify the number of overwrite iterations with the -n option.

6. Automatic Path Correction with shopt cdspell

Typos in long directory paths often result in “No such file or directory” errors. Enabling the cdspell shell option automatically corrects minor misspellings when changing directories. shopt -s cdspell Run shopt without arguments to see all available options. Note that this feature is specific to Bash; other shells may not support it.

7. Quick Return to the Current Directory

If you need to perform actions in another directory but want to stay in your original location, wrap the commands in a subshell. The subshell changes directories, runs the commands, and then exits, leaving your prompt in the original directory. (cd /etc && ls -a) This prints the contents of /etc without changing your current working directory.

Article originally from 程序师
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-lineSystem Administration
ITPUB
Written by

ITPUB

Official ITPUB account sharing technical insights, community news, and exciting events.

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.