- Beginners Guide for Whatis Command in Linux
- Tutorial Details
- Syntax of the Whatis Command
- Whatis: returns all commands as “nothing appropriate”
- Fetching Single or Multiple Commands Description
- Displaying the Command Debugging Information
- Displaying the Command Verbose Information
- Interpreting Each Keyword as a Regex
- Interpreting Each Keyword as a Pattern Containing Shell Style Wild Cards
- Do Not Trim the Output to the Terminal Width
- Searching the Keyword in the Specified Section
- Browsing Through a Different Collection of Colon-Delimited Manual Page Hierarchies
- Temporarily Overriding the Determined Value
- Exit Status of Whatis Command?
- Команда Whatis в Linux
- Синтаксис:
- Как использовать команду whatis:
- Как получить информацию о нескольких командах:
- Параметры:
- Заключение:
- Whatis command in Linux
- Syntax:
- How to use whatis Command:
- How to get the information of multiple commands:
- Options:
- Conclusion:
- About the author
- Aqsa Maqbool
Beginners Guide for Whatis Command in Linux
The whatis command is used to fetch a one-line description of the specified command from the manual pages.
The search query (command) you will use as an argument to get the description will be looked up in the index database maintained by the “maindb” program.
Tutorial Details
Description | Whatis (One-Line Command Defination) |
Difficulty Level | Low |
Root or Sudo Privileges | Yes (for database update) |
Host System and Architecture | Ubuntu 22.10 (x64) |
OS Compatibility | Ubuntu, Manjaro, Fedora, etc. |
Prerequisites | whatis |
Internet Required | No |
Discussed Tools in this Article |
Syntax of the Whatis Command
The whatis command takes two arguments: one is the option, and the other is the keyword.
$ whatis [OPTION] [KEYWORD]
You can specify multiple keywords to get a description by using a space as a separator.
Whatis: returns all commands as “nothing appropriate”
While using the whatis command, if it returns all the commands’ output as “nothing appropriate“, then execute the following command to regenerate the database indexes with sudo.
$ sudo mandb
After the database indexes are generated again, check the description of any command.
Fetching Single or Multiple Commands Description
Specify the tool or command name as an argument to get the one line description from the manual page.
$ whatis pwd pwd (1) - print name of current/working directory
The above pwd command is used as an argument to get the description.
If you want to fetch multiple command descriptions, like Nano and Vim, then specify each of them with a space as a separator.
$ whatis nano vim nano (1) - Nano's ANOther editor, inspired by Pico vim (1) - Vi IMproved, a programmer's text editor
Displaying the Command Debugging Information
Use the “ -d ” or “ —debug ” flag and specify the command to get the descriptive debugging information that includes the compilation paths, find search path, warning, name, section, id, mtime, and many more.
$ whatis -d nano From the config file /etc/manpath.config: Mandatory mandir `/usr/man'. Mandatory mandir `/usr/share/man'. Mandatory mandir `/usr/local/share/man'. Path `/bin' mapped to mandir `/usr/share/man'. Path `/usr/bin' mapped to mandir `/usr/share/man'. Path `/sbin' mapped to mandir `/usr/share/man'. Path `/usr/sbin' mapped to mandir `/usr/share/man'. Path `/usr/local/bin' mapped to mandir `/usr/local/man'. Path `/usr/local/bin' mapped to mandir `/usr/local/share/man'. Path `/usr/local/sbin' mapped to mandir `/usr/local/man'. Path `/usr/local/sbin' mapped to mandir `/usr/local/share/man'. Path `/usr/X11R6/bin' mapped to mandir `/usr/X11R6/man'. Path `/usr/bin/X11' mapped to mandir `/usr/X11R6/man'. Path `/usr/games' mapped to mandir `/usr/share/man'. Path `/opt/bin' mapped to mandir `/opt/man'. Path `/opt/sbin' mapped to mandir `/opt/man'. Global mandir `/usr/man', catdir `/var/cache/man/fsstnd'. Global mandir `/usr/share/man', catdir `/var/cache/man'. Global mandir `/usr/local/man', catdir `/var/cache/man/oldlocal'. Global mandir `/usr/local/share/man', catdir `/var/cache/man/local'. Global mandir `/usr/X11R6/man', catdir `/var/cache/man/X11R6'. Global mandir `/opt/man', catdir `/var/cache/man/opt'.
The above command will give you comprehensive debugging information for the nano command (replace with your command).
Displaying the Command Verbose Information
Use the “ -v ” or “ —verbose ” flag to get the specified command’s verbose information.
$ whatis -v nano nano (1) - Nano's ANOther editor, inspired by Pico
Interpreting Each Keyword as a Regex
The “ -r ” or “ —regex ” flag will interpret each name as a regular expression by searching for the match of the specified name rigorously on any part of the manual page.
$ whatis -r "^na" NAN (3) - floating-point constants name_to_handle_at (2) - obtain handle for a pathname and open file via a handle namei (1) - follow a pathname until a terminal point is found namespace.conf (5) - the namespace configuration file namespaces (7) - overview of Linux namespaces nan (3) - return 'Not a Number' nanf (3) - return 'Not a Number' nanl (3) - return 'Not a Number' nano (1) - Nano's ANOther editor, inspired by Pico nanorc (5) - GNU nano's configuration file
The above command will return all the results that start with the “na” keyword.
Interpreting Each Keyword as a Pattern Containing Shell Style Wild Cards
Use the “ -w ” or “ —wildcard ” to interpret each keyword as a pattern containing shell style wildcards.
It will check each keyword for a match from the entire manual page, making the search slower to return the results.
$ whatis -w nano nano (1) - Nano's ANOther editor, inspired by Pico
Do Not Trim the Output to the Terminal Width
If you reduce your terminal width, the description will be trimmed with “…” as shown.
$ whatis -f nano nano (1) - Nano's ANOther editor, i.
To avoid truncating the output to the terminal width, use the “ -l ” or “ —long ” flag with your argument.
$ whatis -l nano nano (1) - Nano's ANOther editor, inspired by Pico
Searching the Keyword in the Specified Section
The manual page is divided into multiple sections; if you want to search your keyword on a specific list of sections, use the “ -s ” or “ —section ” or “ —sections ” flag and specify each list with a comma (“,“) as a separator.
$ whatis -s 1 nano nano (1) - Nano's ANOther editor, inspired by Pico
If the keyword is not found in the specified list of sections, it will throw a “nothing appropriate” error.
$ whatis -s 3 nano nano: nothing appropriate.
Browsing Through a Different Collection of Colon-Delimited Manual Page Hierarchies
By default, whatis uses the “$MANPATH” environment variable unless the value is empty or unset; in that case, it will determine the appropriate manpath based on your “$PATH” environment variable.
To override this option, use a different set of colon-delimited manual page hierarchies to search.
$ whatis nano -M --manpath=/lib/man-db/mandb nano: nothing appropriate.
Temporarily Overriding the Determined Value
Use the “ -L ” or “ —locale ” flag to define the locale for this search.
$ whatis nano -L locale nano (1) - Nano's ANOther editor, inspired by Pico
Exit Status of Whatis Command?
The exit status might come into use when you use the whatis in your shell script to control the follow of your script.
The whatis command has four exit statuses, followed by:
- 0 – Program successfully executed.
- 1 – Usage, syntax, or configuration file error.
- 2 – Operational error.
- 16 – Nothing matched the specified criteria.
If you have questions related to this topic, feel free to ask them in the comment section.
Команда Whatis в Linux
Добавить в избранное
В Linux команда whatis используется для однострочного обзора команды, параметра или флага. Каждый раздел руководства в Linux содержит несколько определений. Эта команда ищет руководство и отображает описание заданного ключевого слова.
Синтаксис:
Как использовать команду whatis:
Если вы хотите узнать о какой-либо команде в Linux, введите имя инструмента или команды в качестве параметра:
Как получить информацию о нескольких командах:
Если вы хотите узнать подробности о нескольких командах одновременно, введите все имена в качестве входных данных:
$ whatis ps rm touch mv more mkdir
Параметры:
Давайте обсудим различные варианты команды «whatis»:
1. -? — h, –help:
используйте «–help» или «?» с командой whatis, чтобы получить помощь. Выполните от них любую команду:
2. D, –debug:
используйте параметр «-d» для получения отладочной информации:
3. -v, verbose:
используйте параметр «-v», чтобы получить подробную информацию о команде:
4. –r, regex
Каждое имя интерпретируется как регулярное выражение с этой опцией. Когда имя совпадает, соединение будет установлено:
Каждое имя интерпретируется как последовательность, содержащая подстановочные знаки в стиле оболочки с этой опцией. Расширенное имя должно соответствовать имени страницы:
6. -l, long
Эта опция не будет обрезать вывод по ширине терминала:
7. -s, –section = LIST
Используйте параметр «-s», чтобы проверить указанные разделы руководства. Список разделов разделяется двоеточием или запятой. Если запись в списке имеет какой-либо раздел перспективы. Затем он отобразит информацию по заданному ключевому слову:
8. -m, –system = SYSTEM
Использование опции «-m» NewOS для поиска имен страниц руководства NewOS. NewOS — это операционная система Linux.
9. –M, –manpath = ПУТЬ.
Параметр «-M» позволяет вам просматривать другой набор иерархий справочных страниц, разделенных двоеточиями:
$ whatis name –M --mathpath=/lib/pwd
10. -L, –locale = LOCALE
Используйте параметр «-L», чтобы временно переопределить данное ключевое слово. LOCALE напрямую передает строку в whatis:
Эта опция будет закрыта после печати быстрой информации об использовании:
Чтобы отобразить информацию о версии, используйте «–V» с параметром команды «whatis»:
Заключение:
«Whatis» — это команда, которая помогает получить краткое объяснение любой командной строки. Он просматривает руководства по всем командам и отображает краткое описание данного ключевого слова. Мы рассмотрели использование команды «whatis» и ее нескольких опций.
Если вы нашли ошибку, пожалуйста, выделите фрагмент текста и нажмите Ctrl+Enter.
Whatis command in Linux
In Linux, the “whatis” command is used to offer a one-line overview of command, option, or a flag. Each manual section in Linux contains some definitions. This command looks for the manual and displays the description of the given keyword.
Syntax:
The syntax of the “whatis” command is:
How to use whatis Command:
If you want to know about any command in Linux, enter the name of the tool or command as a parameter:
How to get the information of multiple commands:
If you want to know the details about multiple commands simultaneously, enter all the names as input:
Options:
Let’s discuss the various options of the “whatis” command:
1. –?-h, –help:
Use “–help” or “?” with whatis command to get help. Run any one command from them:
2. D, –debug:
Use the” -d” option to get debugging information:
3. -v, verbose:
Use the “-v” option to get verbose detail of a command:
4. –r, regex
Each name is interpreted as a regular expression with this option. When the name matches, the connection will be made:
5. -w, a wildcard
Each name is interpreted as a sequence containing shell-style wildcards with this option. An extended name should be matched to the page name:
6. -l, long
This option will not trim output to suit the width of the terminal:
7. -s, –section=LIST
Use the “-s” option to check the manual sections specified. The section list is divided by a colon or a comma. If a list entry has any perspective section. Then it will display the information of a given keyword. Otherwise, it will display “nothing appropriate:
8. -m, –system=SYSTEM
Using the “-m” NewOS option to scan for the names of NewOS’ manual page. NewOS is a Linux operating system.
9. –M, –manpath=PATH
The “-M” option allows you to browse through a different collection of colon-delimited manual page hierarchies:
10. -L, –locale=LOCALE
Use the “-L” option to override the given keyword temporarily. Locale is directly supplying a string to whatis:
This option will exit after printing quick usage information:
To display the version information, use “–V” with the “whatis” command option:
Conclusion:
The “whatis” is a command that assists in getting a short explanation of any command line. It goes through the manuals of all the commands and displays a short description of the given keyword. We covered the usage of the “whatis” command and its several options.
About the author
Aqsa Maqbool
As a Software engineer, I am passionate to write about various IT related
articles but have deep interest in Linux. I spend most of my time reading Linux related blogs and IT related books. I want to serve the world with my writing skills.