Help me! Get information about a command

The terminal can be an intimidating beast where we have to know and remember secret incantations. I can never tell you them all, but I can tell you how to thrive in this world and find some of the information you need!

Here there are some of the simple ways to ask help from the system:

Ask for a manual

In some terminals you can just ask the manual for a command using the command man as you see below. Unfortunately this doesn’t work in the GitBash environment, but if you are using a Linux computer or a Mac computer the chances are high that will be very smooth.

If you want to ask for the manual of the ls command that is how you do:

prompt $ man less

NAME
       less - opposite of more

SYNOPSIS
       less -?
       less --help
       less -V
       less --version
       less [-[+]aABcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~]
            [-b space] [-h lines] [-j line] [-k keyfile]
            [-{oO} logfile] [-p pattern] [-P prompt] [-t tag]
            [-T tagsfile] [-x tab,...] [-y lines] [-[z] lines]
            [-# shift] [+[+]cmd] [--] [filename]...
       (See the OPTIONS section for alternate option syntax with long option names.)

DESCRIPTION
       Less is a program similar to more(1), but which allows backward movement in the file as well as forward movement.  Also, less does not have to read the entire input file before starting,
       so with large input files it starts up faster than text editors like vi(1).  Less uses termcap (or terminfo on some systems), so it can run on a variety of terminals.  There is even lim‐
       ited support for hardcopy terminals.  (On a hardcopy terminal, lines which should be printed at the top of the screen are prefixed with a caret.)

[...snip...]
-? or --help
              This  option  displays  a  summary of the commands accepted by less (the same as the h command).  (Depending on how your shell interprets the question mark, it may be necessary to
              quote the question mark, thus: "-\?".)

       -a or --search-skip-screen
              By default, forward searches start at the top of the displayed screen and backwards searches start at the bottom of the displayed screen (except for repeated searches  invoked  by
              the  n  or N commands, which start after or before the "target" line respectively; see the -j option for more about the target line).  The -a option causes forward searches to in‐
              stead start at the bottom of the screen and backward searches to start at the top of the screen, thus skipping all lines displayed on the screen.

[the above is just a short version of all the manual]

The manual contains extensive reference documentation that is most useful when customising the behaviour of the command you already know you need. This includes all possible arguments and their structure, any input files, legal information, and often some example usage. It will show the usage that you need to write the command + options + file. Options in this cases means the arguments.


The list of arguments

You may notice that some arguments are written twice, for example ls -a and ls --all are do the same thing. These are called short (prefixed with a single -) and long options (prefixed with --) and they are equivalent (one easier to type, one more descriptive): you can pick which you want to use.

The manual will contain the arguments followed by a short description to help you understand what is possible and how it works.

An interesting think to keep in mind is that most of the time you can combine arguments by lining them up. In the previous lessons, for example, you saw that we use ls -la or ls -ltrh that are combination of 2 or more arguments. Obseve that in this case we use the short kind of argument and we only use the - once, in the beginning.


The ‘help’ argument

You can get a summary of the information in the manual by asking for help. Type the command you need help for, then either -h, -?, or --help.

I think this is a great moment to try these commands, try all of them if you can and choose your favorite. You can check for the manual or for help about the commands we have learned here so you have more detailed information or look into some new ones that we will learn in another moment. Here is a list that you can try:

Manuals:
– less

Help output:
– cd
– ls
– mv
– rm
– mkdir
– history
– cat

New commands:
– sort
– head
– tail