Help commands in linux

Keywords: Linux shell yum

Catalog

  • man
  • whatis
  • apropos
  • --help
  • info
  • help

    man

    explain

Command name:man
 Command English original meaning:manual
 Command path: /usr/bin/man
 Execution rights: all users
 Function description: Get help information

grammar

man [command or configuration file]

Example

#View help for ls command
man ls
    Page Down with Space
    Page Up
    Up Arrow Up
    Down Arrow Down
    /Keyword Search (Enter Search, n Look Down)
    
    
#View/etc/services profile help documentation
man services
    Prompt No manual entry for services
    Run the command yum-y install man-pages, then you can run it
    
    
#View help documentation for/etc/passwd configuration file (incorrect)
man passwd
    The help document for the queried command is incorrect at this time
    
whereis passwd    
[root@izm5e2q95pbpe1hh0kkwoiz ~]# whereis passwd
passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man1/passwd.1.gz /usr/share/man/man5/passwd.5.gz
    passwd has both commands and configuration files, preferring help documentation for commands
    1 Help documentation for commands
    5 Help documentation for profile

#View the help documentation for the passwd configuration file
man 5 passwd

whatis

View a simple description of the command

Example

# View a simple description of ls
whatis ls

[root@izm5e2q95pbpe1hh0kkwoiz ~]# whatis ls
ls (1)               - list directory contents

apropos

View a simple description of the configuration file

Example

# View a simple description of services
apropos services

--help

View option information for a specific command

Example

# View the specific options information for the touch command
touch --help

[root@izm5e2q95pbpe1hh0kkwoiz ~]# touch --help
Usage: touch [OPTION]... FILE...
Update the access and modification times of each FILE to the current time.

A FILE argument that does not exist is created empty, unless -c or -h
is supplied.

A FILE argument string of - is handled specially and causes touch to
change the times of the file associated with standard output.

Mandatory arguments to long options are mandatory for short options too.
  -a                     change only the access time
  -c, --no-create        do not create any files
  -d, --date=STRING      parse STRING and use it instead of current time
  -f                     (ignored)
  -h, --no-dereference   affect each symbolic link instead of any referenced
                         file (useful only on systems that can change the
                         timestamps of a symlink)
  -m                     change only the modification time
  -r, --reference=FILE   use this file's times instead of current time
  -t STAMP               use [[CC]YY]MMDDhhmm[.ss] instead of current time
      --time=WORD        change the specified time:
                           WORD is access, atime, or use: equivalent to -a
                           WORD is modify or mtime: equivalent to -m
      --help     display this help and exit
      --version  output version information and exit

Note that the -d and -t options accept different time-date formats.

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'touch invocation'

info

Almost identical in usage to man and displaying much the same information

help

explain

Command name:help
 Command path: shell built-in command (cannot find path through which, cannot view help documentation through man)
Execution rights: all users
 Capability description: Get help with shell built-in commands

grammar

help [command]

Example

# Use man to view shell built-in commands (unable to view correct help information)
man cd

NAME
       bash,  :,  .,  [,  alias, bg, bind, break, builtin, caller, cd, command, compgen, complete, compopt, continue,
       declare, dirs, disown, echo, enable, eval, exec, exit, export, false, fc, fg, getopts,  hash,  help,  history,
       jobs,  kill, let, local, logout, mapfile, popd, printf, pushd, pwd, read, readonly, return, set, shift, shopt,
       source, suspend, test, times, trap, true, type, typeset, ulimit, umask, unalias, unset, wait -  bash  built-in
       commands, see bash(1)
......

# man queries cd to find out the correct help document information, instead shell's built-in commands



# View Help documentation for shell built-in commands correctly and umask
help umask

[root@izm5e2q95pbpe1hh0kkwoiz ~]# help umask
umask: umask [-p] [-S] [mode]
    Display or set file mode mask.
    
    Sets the user file-creation mask to MODE.  If MODE is omitted, prints
    the current value of the mask.
    
    If MODE begins with a digit, it is interpreted as an octal number;
    otherwise it is a symbolic mode string like that accepted by chmod(1).
    
    Options:
      -p        if MODE is omitted, output in a form that may be reused as input
      -S        makes the output symbolic; otherwise an octal number is output
    
    Exit Status:
    Returns success unless MODE is invalid or an invalid option is given.

Posted by Eiolon on Tue, 18 Feb 2020 18:47:48 -0800