8

So I understand that there are man pages for getting the documentation when the internet is unavailable, or when you need advanced uses, but what if I'm offline and I don't even know what tool I need for the job? Is there a command that lets me see each program/command and a short description?

4 Answers 4

9

In general: No, some programs come without documentation.

However, apropos might be just what you need.

For example apropos ssh will list the man pages related to ssh, in my case:

authorized_keys (5)  - OpenSSH SSH daemon
git-shell (1)        - Restricted login shell for Git-only SSH access
rlogin (1)           - OpenSSH SSH client (remote login program)
rsh (1)              - OpenSSH SSH client (remote login program)
slogin (1)           - OpenSSH SSH client (remote login program)
ssh (1)              - OpenSSH SSH client (remote login program)
ssh-add (1)          - adds private key identities to the authentication agent
ssh-agent (1)        - authentication agent
ssh-argv0 (1)        - replaces the old ssh command-name as hostname     handling
ssh-copy-id (1)      - use locally available keys to authorise logins on a     remote machine
ssh-keygen (1)       - authentication key generation, management and conversion
ssh-keyscan (1)      - gather ssh public keys
ssh-keysign (8)      - ssh helper program for host-based authentication
ssh-pkcs11-helper (8) - ssh-agent helper program for PKCS#11 support
ssh_config (5)       - OpenSSH SSH client configuration files
sshd (8)             - OpenSSH SSH daemon
sshd_config (5)      - OpenSSH SSH daemon configuration file
XAllocClassHint (3)  - allocate class hints structure and set or read a window's WM_CLASS property
XClassHint (3)       - allocate class hints structure and set or read a window's WM_CLASS property
XGetClassHint (3)    - allocate class hints structure and set or read a window's WM_CLASS property
XSetClassHint (3)    - allocate class hints structure and set or read a window's WM_CLASS property
XtIsShell (3)        - obtain and verify a widget's class

You can see some pages appear more than once, the reason being that rsh slogin and ssh have the same man page. Also there (as usual) false positives.

2
  • I guess although not exactly what I was looking for, definitely a very helpful and similar tool. Thanks! Commented May 19, 2014 at 23:34
  • Maybe add to your answer apropos -s1, which will pull all commands from man section 1, and only those commands, which seems to be what the OP wants. Commented Mar 26, 2018 at 0:12
4

You can use the bash(1) built-in compgen

  • compgen -c will list all the commands you could run.
  • compgen -a will list all the aliases you could run.
  • compgen -b will list all the built-ins you could run.
  • compgen -k will list all the keywords you could run.
  • compgen -A function will list all the functions you could run.
  • compgen -A function -abck will list all the above in one go.

The above command lists all the available commands for an user based on his privileges set. I disabled the network and tested the above command and it works even when disabled. However, for short description, as far as I can tell, once you get an command, you can view the man page.

Some other commands that can be used to view the description about a command are,

apropos
whatis
less
groff

References

https://stackoverflow.com/a/949006/1742825

2
  • Of course, that wouldn't necessarily tell you if running those commands will do anything useful. Taking your disabled networks example, I suppose ping would still be listed as executable, but it wouldn't do you much good. Also, isn't this based on the user's current $PATH, meaning that if a command is not within one of the directories named as the search path it will never show up?
    – user
    Commented May 25, 2014 at 10:20
  • apropos -s1 seems like a better answer, because it includes a one-line description of what each command does. What this answer does contribute is a list of aliases, functions, etc, but with no explanation of them it's of limited use, IMO. Commented Mar 26, 2018 at 0:16
3

You can read short description of many commands using whatis:

$ whatis pwd
pwd (1p)             - return working directory name
pwd (1)              - print name of current/working directory
pwd (n)              - Return the absolute path of the current working directory

And you can ask for several commands:

$ whatis pwd ls ps
pwd (1p)             - return working directory name
pwd (1)              - print name of current/working directory
pwd (n)              - Return the absolute path of the current working directory
ls (1p)              - list directory contents
ls (1)               - list directory contents
ps (1)               - report a snapshot of the current processes.
ps (1p)              - report process status

Therefore, you can try to generate list of descriptions of all commands by combining whatis with compgen:

$ whatis $(compgen -c)
1
  • If it generates some garbage on STDERR you can use ` whatis $(compgen -c) 2>/dev/null ` to clean it.
    – Hastur
    Commented May 25, 2014 at 9:25
2

In bash you can start with a simple help invocation from the prompt to have a built-in command list and after refine with help commandname, man commandname and man -k commandname (the last to extend the research to the related ones).

You can find useful to read even info coreutils and info.(not only in bash)

At the end of the man pages (and info too) for each command there is a list of other related commands after the title SEE ALSO. A good starting point to expand your research.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .