Charly's Column – Shell History

Charly's Column – Shell History

Article from Issue 243/2021
Author(s):

For admins like Charly, who try to avoid typing at all costs, the shell offers an excellent opportunity to avoid wear on your fingertips in the form of built-in history.

There are commands that I type several dozen times a day – grep <something> /var/log/syslog is such a classic. The shell keeps a history of all my entries; thanks to the history command, I can always see in a numbered list which commands I typed last.

The history command is not a separate tool; typing which history at the command line just drops you into a black hole. Instead, history is a part of the shell, a built-in keyword. history's killer feature, for which lazy people like me are eternally grateful, is the interactive search. You enable it with Ctrl+R, changing the command-line prompt to (reverse-i-search)`':.

If you start typing now, for example, the word net, the shell will show you the last command typed containing net. When you press Ctrl+R again, the history feature shows you an increasing number of older commands that contain net (Figure 1).

[...]

Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Effectively using Bash history

    You can do more with the Bash history command than just using the arrow keys. We show you how to use this command-line tool more efficiently.

  • Bash History on Steroids

    You can always browse the Bash history using your arrow keys, but Bash's search capabilities are very limited. Enter the clever Bash History Suggest Box.

  • The sys admin's daily grind: Smorgasbord

    Sys admin columnist Charly Kühnast has an electronic note box in which he collects ideas and small snippets of code. He calls it his "quarry" and is taking this opportunity to offer up some collectors' items to regular readers.

  • Don't Know Much About History

    The versatile Bash history command can save you time and effort at the command line.

  • Bash Tricks

    The Bash shell is powerful and infinitely expressive. In this article we describe some tricky techniques you can use to enhance and customize your Bash environment.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News