The Whatis command returns a small one-line description for Linux commands. It gets this description from the command’s man-page. “whatis” searches for the argument that you pass along with it and returns the one-line description from the man-page wherever there is a match.
In this tutorial we will learn how to use the whatis command in Linux.
Let’s get started.
Using the whatis command with common Linux commands
Let’s try running the whatis command with some popular Linux commands as arguments.
1. Mkdir
We can run it with the mkdir command as follows :
whatis mkdir
Output :
mkdir (1) - make directories
mkdir (2) - create a directory
We get two lines in the output since there are two different manpages that exist.
This is the man-page for mkdir(1).
This is the man-page for mkdir(2).
If you observe carefully you will see that the output for whatis command comes from the text under ‘NAME’ section of the manpage.
2. ls command
You can use whatis to get a brief description about the ls command as follows :
whatis ls
Output :
ls (1) - list directory contents
3. pwd command
You can use whatis to get a brief description about the pwd command as follows :
whatis pwd
Output :
pwd (1) - print name of current/working directory
4. Â cat command
You can use whatis to get a brief description about the cat command as follows :
whatis cat
Output :
cat (1) - concatenate files and print on the standard output
5. Â ifconfig command
You can use whatis to get a brief description about the ifconfig command as follows :
whatis ifconfig
Output :
ifconfig (8) - configure a network interface
Using Whatis with multiple commands as arguments
You can get one line descriptions for multiple commands at once using the whatis command.
whatis ls pwd cat ifconfig
Output :
ls (1) - list directory contents
pwd (1) - print name of current/working directory
cat (1) - concatenate files and print on the standard output
ifconfig (8) - configure a network interface
Search the man-page database
We can perform a search operation on the man-pages in two ways. Either we can use wildcards or we can use regular expressions.
1. Using Wildcards
To perform a search operation with wildcard, use :
whatis -w "ca"
Output :
ca (1ssl) - sample minimal CA application
Let’s try another one :
whatis -w "cat*"
Output :
cat (1) - concatenate files and print on the standard output
catan (3) - complex arc tangents
catanf (3) - complex arc tangents
catanh (3) - complex arc tangents hyperbolic
catanhf (3) - complex arc tangents hyperbolic
catanhl (3) - complex arc tangents hyperbolic
catanl (3) - complex arc tangents
catchsegv (1) - Catch segmentation faults in programs
catclose (3) - open/close a message catalog
catgets (3) - get message from a message catalog
catman (8) - create or update the pre-formatted manual pages
catopen (3) - open/close a message catalog
These are all the matches in man-page database where the command starts with ‘cat’.
2. Using Regular-Expression
We can also use regular expressions to perform search operations along with whatis command.
whatis -r 'cat$'
Output :
bzcat (1) - decompresses files to stdout
cat (1) - concatenate files and print on the standard output
fc-cat (1) - read font information cache files
gencat (1) - Generate message catalog
gvfs-cat (1) - (unknown subject)
lz4cat (1) - lz4, unlz4, lz4cat - Compress or decompress .lz4 files
lzcat (1) - Compress or decompress .xz and .lzma files
netcat (1) - arbitrary TCP and UDP connections and listens
ntfscat (8) - print NTFS files and streams on the standard output
pacat (1) - Play back or record raw or encoded audio streams on a PulseAudio sound server
precat (1) - prefix delta compressor for Aspell
STAILQ_CONCAT (3) - implementations of singly-linked lists, singly-linked tail queues, lists and ta...
strcat (3) - concatenate two strings
strncat (3) - concatenate two strings
systemd-cat (1) - Connect a pipeline or program's output with the journal
TAILQ_CONCAT (3) - implementations of singly-linked lists, singly-linked tail queues, lists and ta...
tarcat (1) - concatenates the pieces of a GNU tar multi-volume archive
wcscat (3) - concatenate two wide-character strings
wcsncat (3) - concatenate two wide-character strings
xzcat (1) - Compress or decompress .xz and .lzma files
zcat (1) - compress or expand files
These are all the commands that end with ‘cat’. Let’s try another one.
whatis -r '^cat'
Output :
cat (1) - concatenate files and print on the standard output
catan (3) - complex arc tangents
catanf (3) - complex arc tangents
catanh (3) - complex arc tangents hyperbolic
catanhf (3) - complex arc tangents hyperbolic
catanhl (3) - complex arc tangents hyperbolic
catanl (3) - complex arc tangents
catchsegv (1) - Catch segmentation faults in programs
catclose (3) - open/close a message catalog
catgets (3) - get message from a message catalog
catman (8) - create or update the pre-formatted manual pages
catopen (3) - open/close a message catalog
These are all the commands in the man-page database that start with ‘cat’.
Display version of whatis command
To display the version of Whatis command use :
whatis -V
Output :
whatis 2.9.1
Conclusion
This tutorial was about whatis command in Linux. We learned how to use the command to display one-line descriptions for Linux commands and how to perform a search using wildcards and regular expressions.