Working with a terminal, you need to use a lot of commands. Remembering how all of them work and what options they have is difficult – it's much easier to remember where to get help for a specific command. So, before starting to work, you can read relevant documentation and get a clear idea of what lies ahead. To get this information, you may begin with the following three commands: man, whatis, and tldr. They all give out information about other commands, but they differ in the degree of detail. Let's take a closer look at them and start with the man command.
Man pages
Man is short for manual, it is a Unix command for formatting and displaying manual pages. This command comes with almost all UNIX-like distributions and does not need to be additionally installed. Each man help page is a stand-alone document written by the respective software developers.
The help pages are divided into 8 standard sections and one additional section. Each of the sections corresponds to a particular topic within the installed operating system. We will consider only the first one, which is for applications and shell commands. You may also read more about other sections if you like.
Below we will see how to use man to find the documentation for the ls command.
Using man
To use man, you need to write man <the command name> in the terminal and press Enter. For example,
$ man ls
LS(1) User Commands LS(1)
NAME
ls - list directory contents
SYNOPSIS
ls [OPTION]... [FILE]...
DESCRIPTION
List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
Mandatory arguments to long options are mandatory for short options too.
-a, --all
do not ignore entries starting with .
-A, --almost-all
do not list implied .This is a snippet of a page. Each page is divided into several sections. You can see some of them above, and the whole list goes as follows:
NAME – the name of the program or command, as well as its short description;
SYNOPSIS – command syntax and order of passing options to it;
DESCRIPTION – a more detailed description of the command;
CONFIGURATION – program settings;
OPTIONS – command options;
EXAMPLE – examples of use;
AUTHORS – the authors of the program.
Now you know what the man page is. Such pages can be created by anyone, and if you decide to make your own man page for some of your projects, you may use a man page guide.
To view information and manage the help page, you can use the hotkeys like up / down arrows for scrolling information up or down, e or j for moving one line up, z for moving one window down, / for searching the occurrences, specified after the character, and so on. For a quick reference on the commands and hotkeys of the Help system, press H (Help). To exit the help system, use the Q (Quit) key.
The man command gives you a lot of information. It is often inconvenient to read everything at once, especially for beginners. Therefore, there is the tldr command, which produces an abridged version of the documentation. Below we will find out how it works and study several examples.
TLDR command
TLDR stands for Too Long Didn't Read and is described as "a collection of simplified and community-driven man pages." The main product is the actual library of markdown files, which are alternative manual pages for popular console utilities. Most of them are in the general and Linux categories, but there are also separate pages for macOS and even Windows.
The command is not preinstalled and in order to start using it, you need to install it. There are several ways to do this, for example, you may choose one of the commands below:
1. The first way to access TLDR is to install one of the supported clients with Node.js, which is the source client for the tldr-pages project. Next, you can install it from NPM by running
$ sudo npm install -g tldr2. The second solution is to use the snap system. Just do not forget to check if you have snap installed!
$ sudo snap install tldr3. The last one from this list is for the package manager apt
$ sudo apt install tldrAfter you have installed tldr, you are ready to use it!
TLDR usage
To use the tldr command, you need to type tldr <command name> and then press Enter. For example:
$ tldr ls
ls
List directory contents.
More information:
https://www.gnu.org/software/coreutils/ls
.
- List files one per line:
ls -1
- List all files, including hidden files:
ls -aAs a result, you will receive a short description and basic parameters of the command. Such instructions are a lot quicker to read, although they are far from being as detailed as the previous ones. And if you want more, there is always a link with extra information.
However, in case there is no time to understand the parameters at all, or it's just unnecessary, you can limit yourself to a simple description of the utility. This description is given by the whatis command. Let's discuss it briefly below.
Whatis command
The whatis command actually answers the question of what kind of utility is in front of you. You do not need to install whatis. Its syntax is similar to the syntax of the previous commands: you just write whatis <command name> and press Enter. As a result, you get a short message about the purpose of the command you asked about. For example:
$ whatis ls
ls (1) - list directory contentsConclusion
To sum up, now you know that you can find information about any shell command using these three commands: man, tldr, and whatis. You can use every command, or you can choose just one. The choice depends on the level of details about the commands you need. man gives a complete instruction manual, tldr is its abbreviated version, and whatis lets you know what this or that command actually does.