Open Source

How to use the apropos command to easily remember other Linux commands

Tired of not being able to quickly recall the Linux command you need to use? Here's a tip to help you find the needle in that massive haystack.

linuxhero.jpg
Image: Jack Wallen

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)

Usage

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:

apropos "firewall"

The output of that command will clue you in on the necessary command (Figure A).

Figure A

Figure A

What was that firewall command?

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).

Figure B

Figure B

A too-generic search.

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).

Figure C

Figure C

This is far more useful.

What commands are available for remote login? Issue apropos "remote login" to see what the platform offers (Figure D).

Figure D

Figure D

How can I login to that remote machine?

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).

Figure E

Figure E

Apropos that I would have issued the apropos command.

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.

Stop staring

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.

Also see

About Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website jackwallen.com.

Editor's Picks

Free Newsletters, In your Inbox