I’m sitting here staring at my terminal, unsure which command it was I needed to do something. Sure I could probably run a Google search to find out that command, but I’d much rather keep it local.
I walked up to this computer for something. I just can’t remember what.
It was a command to do something important, like work with the firewall.
How many times has that scenario smacked you upside the grok? I’ve certainly experienced it. Every so often I catch a lucky break and the command is in my bash history. On those rare occasions I hadn’t issued the command for a while, I have to turn to another command to offer up assistance. That command is apropos.
The apropos command is able to search the Linux man pages, to help you find the command you’re looking for. It’s incredibly easy to use and installed by default. Let’s see how simple it is to use, so you don’t have to worry about memorizing a host of commands.
SEE: 15 books every programmer should read (free PDF) (TechRepublic)
Using apropos is quite easy. The syntax of the command is:
apropos "search string"
Say you cannot remember the command to work with your firewall; you could make use of apropos like so:
The output of that command will clue you in on the necessary command (Figure A).
As you might expect, you do have to be clear with your search strings. For example, enter apropos “list” and the output will include any command that contains list in its man page description (Figure B).
If you’re trying to remember the command to list directory contents, you might want to get slightly more specific, such as:
apropos "list directory"
The output of the above command will be quite a bit more narrowly focused (Figure C).
What commands are available for remote login? Issue apropos “remote login” to see what the platform offers (Figure D).
When all else fails
Naturally, you have to be able to remember the apropos command. When that fails you, you can always fall back to the bash history. Issue the command history and bash will spit out the last commands you’ve issued (Figure E).
On those occasions when you can’t remember the apropos command, you can also tap your up arrow key (on your keyboard). This action will display the commands saved in your bash history one at a time.
Thanks to your bash history and the apropos command, you no longer have to stare at the monitor in front of you, waiting intervention from your IT muse. There are thousands of commands available on the Linux platform–there’s no shame in not being able to remember all of them.