The Unix Shell: Getting Help

Use a search engine

This is often the simplest approach.

Getting general information

In [41]:
info bash | head -n 40
/usr/share/info/bash.info
File: bash.info,  Node: Top,  Next: Introduction,  Prev: (dir),  Up: (dir)

Bash Features
*************

This text is a brief description of the features that are present in
the Bash shell (version 3.2, 28 September 2006).

   This is Edition 3.2, last updated 28 September 2006, of `The GNU
Bash Reference Manual', for `Bash', Version 3.2.

   Bash contains features that appear in other popular shells, and some
features that only appear in Bash.  Some of the shells that Bash has
borrowed concepts from are the Bourne Shell (`sh'), the Korn Shell
(`ksh'), and the C-shell (`csh' and its successor, `tcsh'). The
following menu breaks the features up into categories based upon which
one of these other shells inspired the feature.

   This manual is meant as a brief introduction to features found in
Bash.  The Bash manual page should be used as the definitive reference
on shell behavior.

* Menu:

* Introduction::                An introduction to the shell.
* Definitions::                 Some definitions used in the rest of this
                                manual.
* Basic Shell Features::        The shell "building blocks".
* Shell Builtin Commands::      Commands that are a part of the shell.
* Shell Variables::             Variables used or set by Bash.
* Bash Features::               Features found only in Bash.
* Job Control::                 What job control is and how Bash allows you
                                to use it.
* Using History Interactively:: Command History Expansion
* Command Line Editing::        Chapter describing the command line
                                editing features.
* Installing Bash::             How to build and install Bash on your system.
* Reporting Bugs::              How to report bugs in Bash.
* Major Differences From The Bourne Shell::     A terse list of the differences

Command shell commands

In [35]:
help
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin16)
These shell commands are defined internally.  Type `help' to see this list.
Type `help name' to find out more about the function `name'.
Use `info bash' to find out more about the shell in general.
Use `man -k' or `info' to find out more about commands not in this list.

A star (*) next to a name means that the command is disabled.

 JOB_SPEC [&]                       (( expression ))
 . filename [arguments]             :
 [ arg... ]                         [[ expression ]]
 alias [-p] [name[=value] ... ]     bg [job_spec ...]
 bind [-lpvsPVS] [-m keymap] [-f fi break [n]
 builtin [shell-builtin [arg ...]]  caller [EXPR]
 case WORD in [PATTERN [| PATTERN]. cd [-L|-P] [dir]
 command [-pVv] command [arg ...]   compgen [-abcdefgjksuv] [-o option
 complete [-abcdefgjksuv] [-pr] [-o continue [n]
 declare [-afFirtx] [-p] [name[=val dirs [-clpv] [+N] [-N]
 disown [-h] [-ar] [jobspec ...]    echo [-neE] [arg ...]
 enable [-pnds] [-a] [-f filename]  eval [arg ...]
 exec [-cl] [-a name] file [redirec exit [n]
 export [-nf] [name[=value] ...] or false
 fc [-e ename] [-nlr] [first] [last fg [job_spec]
 for NAME [in WORDS ... ;] do COMMA for (( exp1; exp2; exp3 )); do COM
 function NAME { COMMANDS ; } or NA getopts optstring name [arg]
 hash [-lr] [-p pathname] [-dt] [na help [-s] [pattern ...]
 history [-c] [-d offset] [n] or hi if COMMANDS; then COMMANDS; [ elif
 jobs [-lnprs] [jobspec ...] or job kill [-s sigspec | -n signum | -si
 let arg [arg ...]                  local name[=value] ...
 logout                             popd [+N | -N] [-n]
 printf [-v var] format [arguments] pushd [dir | +N | -N] [-n]
 pwd [-LP]                          read [-ers] [-u fd] [-t timeout] [
 readonly [-af] [name[=value] ...]  return [n]
 select NAME [in WORDS ... ;] do CO set [--abefhkmnptuvxBCHP] [-o opti
 shift [n]                          shopt [-pqsu] [-o long-option] opt
 source filename [arguments]        suspend [-f]
 test [expr]                        time [-p] PIPELINE
 times                              trap [-lp] [arg signal_spec ...]
 true                               type [-afptP] name [name ...]
 typeset [-afFirtx] [-p] name[=valu ulimit [-SHacdfilmnpqstuvx] [limit
 umask [-p] [-S] [mode]             unalias [-a] name [name ...]
 unset [-f] [-v] [name ...]         until COMMANDS; do COMMANDS; done
 variables - Some variable names an wait [n]
 while COMMANDS; do COMMANDS; done  { COMMANDS ; }

Using the Unix manual

Most commands have built-in help accessible with -h or --help. Let’s see how to use the man command.

In [17]:
man -h
man, version 1.6c

usage: man [-adfhktwW] [section] [-M path] [-P pager] [-S list]
        [-m system] [-p string] name ...

  a : find all matching entries
  c : do not use cat file
  d : print gobs of debugging information
  D : as for -d, but also display the pages
  f : same as whatis(1)
  h : print this help message
  k : same as apropos(1)
  K : search for a string in all pages
  t : use troff to format pages for printing
  w : print location of man page(s) that would be displayed
      (if no name given: print directories that would be searched)
  W : as for -w, but display filenames only

  C file   : use `file' as configuration file
  M path   : set search path for manual pages to `path'
  P pager  : use program `pager' to display pages
  S list   : colon separated section list
  m system : search for alternate system's man pages
  p string : string tells which preprocessors to run
               e - [n]eqn(1)   p - pic(1)    t - tbl(1)
               g - grap(1)     r - refer(1)  v - vgrind(1)

In [21]:
man --help
man, version 1.6c

usage: man [-adfhktwW] [section] [-M path] [-P pager] [-S list]
        [-m system] [-p string] name ...

  a : find all matching entries
  c : do not use cat file
  d : print gobs of debugging information
  D : as for -d, but also display the pages
  f : same as whatis(1)
  h : print this help message
  k : same as apropos(1)
  K : search for a string in all pages
  t : use troff to format pages for printing
  w : print location of man page(s) that would be displayed
      (if no name given: print directories that would be searched)
  W : as for -w, but display filenames only

  C file   : use `file' as configuration file
  M path   : set search path for manual pages to `path'
  P pager  : use program `pager' to display pages
  S list   : colon separated section list
  m system : search for alternate system's man pages
  p string : string tells which preprocessors to run
               e - [n]eqn(1)   p - pic(1)    t - tbl(1)
               g - grap(1)     r - refer(1)  v - vgrind(1)

What does the manual say about itself?

In [18]:
man man | head -n 20
man(1)                                                                  man(1)



NAME
       man - format and display the on-line manual pages

SYNOPSIS
       man  [-acdfFhkKtwW]  [--path]  [-m system] [-p string] [-C config_file]
       [-M pathlist] [-P pager] [-B browser] [-H htmlpager] [-S  section_list]
       [section] name ...


DESCRIPTION
       man formats and displays the on-line manual pages.  If you specify sec-
       tion, man only looks in that section of the manual.  name  is  normally
       the  name of the manual page, which is typically the name of a command,
       function, or file.  However, if name contains  a  slash  (/)  then  man
       interprets  it  as a file specification, so that you can do man ./foo.5
       or even man /cd/foo/bar.1.gz.

What does the parenthesis in man (1) mean?

The text in parenthesis indicates the section of the Unix manual (man) to find out more about the keyword. The standard sections are:

  1. General commands
  2. System calls
  3. C library functions
  4. Special files (usually devices, those found in /dev) and drivers
  5. File formats and conventions
  6. Games and screensavers
  7. Miscellanea
  8. System administration commands and daemons

Full details in Unix Programmer’s Mnaual

Getting brief descriptions

In [24]:
man -f cat
fc-cat(1)                - read font information cache files
parcat(1)                - cat files or fifos in parallel
cat(1)                   - concatenate and print files

This is the same as the whatis command

In [25]:
whatis cat
fc-cat(1)                - read font information cache files
parcat(1)                - cat files or fifos in parallel
cat(1)                   - concatenate and print files

Getting the manual entry for cat

In [26]:
man cat | head -n 20

CAT(1)                    BSD General Commands Manual                   CAT(1)

NAME
     cat -- concatenate and print files

SYNOPSIS
     cat [-benstuv] [file ...]

DESCRIPTION
     The cat utility reads files sequentially, writing them to the standard
     output.  The file operands are processed in command-line order.  If file
     is a single dash (`-') or absent, cat reads from the standard input.  If
     file is a UNIX domain socket, cat connects to it and then reads it until
     EOF.  This complements the UNIX domain binding capability available in
     inetd(8).

     The options are as follows:

     -b      Number the non-blank output lines, starting at 1.

RTFM

On help sites, you will often be asked to Read The F(ine) Manual if you ask a question that is answered by man.

In [14]:
man 3ssl blowfish | head -n 20
blowfish(3)                         OpenSSL                        blowfish(3)



NAME
       blowfish, BF_set_key, BF_encrypt, BF_decrypt, BF_ecb_encrypt,
       BF_cbc_encrypt, BF_cfb64_encrypt, BF_ofb64_encrypt, BF_options -
       Blowfish encryption

SYNOPSIS
        #include <openssl/blowfish.h>

        void BF_set_key(BF_KEY *key, int len, const unsigned char *data);

        void BF_ecb_encrypt(const unsigned char *in, unsigned char *out,
                BF_KEY *key, int enc);
        void BF_cbc_encrypt(const unsigned char *in, unsigned char *out,
                long length, BF_KEY *schedule, unsigned char *ivec, int enc);
        void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out,
                long length, BF_KEY *schedule, unsigned char *ivec, int *num,
In [15]:
man n blowfish | head -n 20
blowfish(n)                  Blowfish Block Cipher                 blowfish(n)



______________________________________________________________________________

NAME
       blowfish - Implementation of the Blowfish block cipher

SYNOPSIS
       package require Tcl  8.4

       package require blowfish  ?1.0.4?

       ::blowfish::blowfish  ?-mode  [ecb|cbc]?  ?-dir [encrypt|decrypt]? -key
       keydata ?-iv vector? ?-out channel? ?-chunksize size? ?-pad padchar?  [
       -in channel | ?--? data ]

       ::blowfish::Init mode keydata iv