As you know, each Unix/Linux distro comes with a massive set of man pages – helpful manuals for using pretty much every standard command found in your OS.
Quite often you don't know the command though, but know what it should do. In such a scenario, apropos and whatis commands may come in handy.
Man pages database
There's a special database (index) of man pages on your system, which indexes man pages and keeps a list of short 1-line descriptions of each command documented in a man page. This is how such a database looks in text form on a Ubuntu 16.04 Linux system:
... ldap.conf (5) - LDAP configuration file/environment variables adduser.conf (5) - configuration file for adduser(8) and addgroup(8) . mailcap.order (5) - the mailcap ordering specifications interfaces (5) - network interface configuration for ifup and ifdown Compose (5) - X client mappings for multi-key input sequences PAM (7) - Pluggable Authentication Modules for Linux [ (1) - check file types and compare values access.conf (5) - the login access control table file accessdb (8) - dumps the content of a man-db database in a human readable format add-apt-repository (1) - Adds a repository into the /etc/apt/sources.list or /etc/apt/sources.lis... add-shell (8) - add shells to the list of valid login shells addgroup (8) - add a user or group to the system addpart (8) - tell the kernel about the existence of a partition adduser (8) - add a user or group to the system agetty (8) - alternative Linux getty apropos (1) - search the manual page names and descriptions apt (8) - command-line interface ...
Left side of the output lists command names, right side of the outout shows a brief command description. apropos and whatis commands work with these fields and allow you to search them.
Using whatis command
This command is useful when you want to confirm what a particular Unix command does. It searches man pages, but focuses specifically on the command names, rather than their descriptions.
For instance, if I know ls command, I would use whatis like this to find out more:
root@vps1:~# whatis ls ls (1) - list directory contents
if I want to find similar commands, I can use the wildcard (in this example: all commands starting with ls combination):
root@vps1:~# whatis -w 'ls*' ls (1) - list directory contents lsattr (1) - list file attributes on a Linux second extended file system lsb_release (1) - print distribution-specific information lsblk (8) - list block devices lscpu (1) - display information about the CPU architecture lsinitramfs (8) - list content of an initramfs image lsipc (1) - show information on IPC facilities currently employed in the system lslocks (8) - list local system locks lslogins (1) - display information about known users in the system lsmod (8) - Show the status of modules in the Linux Kernel lsof (8) - list open files lspgpot (1) - extracts the ownertrust values from PGP keyrings and list them in GnuPG ow..
Using apropos command
apropos is useful when you don't remember the command but may have a few keywords describing its functionality.
Using ls command from the previous examples, we can find it using "directory" keyword. Of coruse, searching for "directory" will find all the commands which have anything to do with directories, as shown below:
root@vps1:~# apropos directory basename (1) - strip directory and suffix from filenames bindtextdomain (3) - set directory containing message catalogs chroot (8) - run command or interactive shell with special root directory dbus-cleanup-sockets (1) - clean up leftover sockets in a directory depmod.d (5) - Configuration directory for depmod dir (1) - list directory contents find (1) - search for files in a directory hierarchy grub-macbless (8) - bless a mac file/directory grub-mknetdir (1) - prepare a GRUB netboot directory. helpztags (1) - generate the help tags file for directory ls (1) - list directory contents mklost+found (8) - create a lost+found directory on a mounted Linux second extended file system mktemp (1) - create a temporary file or directory modprobe.d (5) - Configuration directory for modprobe mountpoint (1) - see if a directory or file is a mountpoint pam_mkhomedir (8) - PAM module to create users home directory pwd (1) - print name of current/working directory pwdx (1) - report current working directory of a process run-parts (8) - run scripts or programs in a directory vdir (1) - list directory contents