Download the authoritative guide: Cloud Computing 2018: Using the Cloud to Transform Your Business
The Linux command-line can appear pretty complicated and occasionally even a little alarming. But it also offers a whole stack of helpful documentation which you can access directly from the command-line. Read on to learn how to help yourself when – or even before – you get stuck.
A question you may have quite early on in your command-line exploration is: is there a command that does the thing I want to do? apropos is here to help. Manual pages (I'll discuss these in more detail below) are available for almost all Linux commands, and include a short description of the command. apropos searches this for the string you provide. So
apropos datewill output every command that has the word "date" in its name or its short description, as in this Figure 1.
If you know what command you want to use, and you know roughly how it works, but you've forgotten the details, then the option --help may be useful. For example, try the command:
du --helpto get information on what options you can use with the du command (this gives you information about disk usage). In some cases the help output may be too long for the screen: in this case try:
du --help | moreand press the space key to scroll down through the information.
--help, however, may not be much good if you don't really understand the command in the first place. To get a bit more information, try the man (short for "manual") command:
man duThe man (manual) pages will give you more information about a command. It should cover what it is supposed to do, what options you can use, with details about how to use them, other relevant information, and suggestions of other related commands. Some manpages may also have a useful "examples" section. The start of the du manpage, shown in Figure 2, shows the standard format.
Man pages can be limited, and they're often not great if you're an absolute beginner, especially if the command is a complicated one. But they are often enough to get you started – and in some cases they can quite genuinely provide an entire manual. Check out man bash for a very comprehensive example.
One point to bear in mind is that there can be multiple categories of man page. The ones you are most likely to run across are:
1 Executable programs or shell commands 5 File formats and conventions eg /etc/passwd 8 System administration commands (usually only for root)(Type man man for further information.)
For an example of this, compare the output of man crontab with man 5 crontab. The first one describes the crontab command (this edits crontab files, which tell the program cron which tasks to run at what time). The second one describes the format that a crontab file should have. Both are obviously useful!
If you'd rather read manpages online, just type man command into Google.KDE's Konqueror Web and file browser has a built-in man page reader. Just type "man:[command name]", like "man:bash" in the URL bar. It even gives a list of alphabetical suggestions as you type--ed
An alternative to man pages is the info command. Indeed, for some commands, the man page is pretty much only a redirection to the more comprehensive info page. However, info pages can be a little confusing to navigate.
Try typing info find. Your first screen should look a bit like figure 3.
To get a list of navigation commands, hit ? (to quit this help page, hit l). n moves to the next node (so just hitting n repeatedly will take you straight through an info document), and p to the previous node; u goes up one menu level. If you use the arrow keys to move to a hyperlink (marked with *asterisks*), and hit return, you'll be taken to that menu item. l will take you back one level (to the point where you hit return).
In some cases, the info command will just take you to the man page for a command.
Many more complicated Linux programs have documentation available in /usr/share/doc/. Sometimes this will consist only of the changelog for your distribution, but sometimes there may be example files, or more extensive documentation or handbooks. It's certainly worth checking out if you're at a loss. This directory is more likely to be helpful for programs rather than commands.
So, there's plenty of Linux help available at your fingertips and no excuse for not getting stuck in with the command line!
This article was first published on ServerWatch.com.