Linux which man page

How to read Linux man pages? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.

Every time I find some command confusing, I’d reach out for man pages. Sometimes I get what I want with it, but mostly it confused me even more. I understand that a man page is divided into parts: NAME , SYNOPSIS , DESCRIPTION , OPTIONS , EXPRESSIONS , EXAMPLES , etc. But I have no clue what all the options mean. Like, how many parameters every option should have, their dependencies etc. Can someone please clarify it for me? Are there any documents for this?

Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See What topics can I ask about here in the Help Center. Perhaps Super User or Unix & Linux Stack Exchange would be a better place to ask.

4 Answers 4

Being productive in reading man pages

Apart from Laxmikant’s answer, I would like to add something which will actually make you faster and more productive while reading man pages.

You can use various Vim-like keybindings to navigate faster.

A few quintessential examples:

  • Press / and then type some keyword you want to search for and then press enter. It will highlight the first result. Then, you can go to the next search result by pressing n and back by Shift+n
  • If you are reading a very long page, and you need to switch back and forth between a few sections, use marks. Let us say, I am at a certain position of the man page. To mark the position, I press m and followed by some key, say 1 . Now, the position is saved at mark 1 . If I scroll somewhere else and I need to revisit this position, I simple press a followed by 1 .
  • Use d and u for scrolling half a page down/up.

And remember, to escape from any command/mode mentioned above, the key is esc , of course.

UPDATE: Using Vim for reading man pages

To be even more productive, you could directly use Vim, like:

Or even better, define a function in your ~/.bashrc file (in case you’re using Bash):

Читайте также:  Linux log file mysql

Источник

man Command in Linux with Examples

The man command is a built-in manual for using Linux commands. It allows users to view the reference manuals of a command or utility run in the terminal. The man page (short for manual page) includes a command description, applicable options, flags, examples, and other informative sections.

In this tutorial, you will learn to use the man command in Linux.

How to use the man command in Linux.

  • A machine running Linux
  • Access to the command line
  • An account with root privileges

Linux man Command Syntax

The basic man command syntax is:

man [option] [section number] [command name]
  • option – the search result output.
  • section number – the section in which to look for the man page.
  • command name – the name of the command which man page you want to see.

By default, man looks in all the available sections of the manual and shows the first match (even if the page exists in several sections). Providing a section number instructs the man command to look in a specific section.

There are nine sections of the manual:

1. General commands: Commands used in the terminal.

2. System calls: Functions the kernel provides.

3. Library functions: Functions in program libraries.

4. Special files: Usually devices found in /dev and related drivers.

5. File formats and conventions: File formats like etc/passwd.

6. Games: Descriptions of commands that display database quotes.

7. Miscellaneous: Various descriptions, including macro packages and conventions, boot parameters, and others.

8. System administration commands: Commands mostly reserved for root.

9. Kernel Routines: Information about internal kernel operations.

How to Use man in Linux

In the terminal window, type man followed by the Linux command name which man page you want to see.

The output is lengthy. Use the mouse scroll wheel, the up and down arrow keys, or the PgDn and PgUp keys to navigate through it.

After running the man command, press H to see the help section and a table of possible keystrokes for navigating the output.

To exit, press Q.

The output of the command displays the available man page headings for the specified command.

The list of possible headings includes:

  • Name: The name of the command.
  • Synopsis: The command’s syntax.
  • Configuration: Configuration details for a device.
  • Description: A description of the command.
  • Examples: Several examples demonstrating the use of the command.
  • Defaults: The default functions of the command and how they can be overridden.
  • Options: A list of options and flags that the command accepts.
  • Exit Status: A list of possible exit status values for the command.
  • Environment: A list and description of environment variables that affect the command.
  • Files: A list of files used by the command.
  • See also: Commands related to the described topic.
  • Authors: The people who wrote or maintain the command.
  • History: Command development history.
  • Notes: Various notes, including permissions required, dependencies, etc.
  • Bugs: Any known issues in this program version.
Читайте также:  Сборка ядра linux manjaro

Note: Pages may contain more or fewer headings depending on the man page contents.

Look for man Pages

The -f option displays all man pages that match the specified command name and states the sections in which the given command is present.

Look for man pages in Linux.

The output is a list of results that match the search criteria. With multiple matches, the number next to the search result indicates the section.

Display man Pages From Specific Sections

To display the page from a specific section of a manual, use the syntax:

man [section number] [command name]

See a man page from a specific section.

The output shows only the page from section 3 of the manual.

Display man Pages in a Browser

Man pages are long and sometimes difficult to scroll through to find the information you need. The man command allows users to display man pages in a browser to find information easily.

To do so, follow these steps:

1. Make sure the groff package is installed. Run:

sudo apt-get install groff

2. Before calling the man command, select a default browser. Run:

To use a different browser, replace firefox with google-chrome , chromium-browser , or any other browser.

3. Use the -H option to read the man page in a browser of your choice:

Man pages can be read in browsers using the -H option.

The -H option instructs groff to produce an HTML output and displays that output in a browser.

Display man Pages and Print Short Descriptions

The -f option allows users to look up the man pages and prints out short descriptions of the specified command in the terminal. The syntax is:

See a short man page description.

Display All man Pages

The -a attribute allows users to display all available intro manual pages contained in each section, one at a time.

Display all man pages using the -a option.

Quit between successive displays or skip through them using Ctrl+C or Ctrl+D, respectively.

Search by Considering Input as a Regular Expression

The -k option allows users to search the short command descriptions and manual page names for a specified keyword as a regular expression. The output shows any available matches.

Conduct a search in man considering input as a regular expression.

Display Location of man Pages

The -w attribute shows the location of the manual page of the specified command. Adding the -a option prints out the locations of all files matching the keyword.

See the location of man pages using the -w option.

In this example, we used the -a option to see the locations of all associated man pages.

Additionally, using the -W option displays the location of the preformatted cat file. With the -a option, it prints out the locations of all preformatted cat files matching the keyword.

Enable Case-Sensitivity

To search for manual pages using case-sensitivity, use the -I option. The syntax is:

The man default setting is to ignore case when looking up manual pages. To go back to default settings and ignore case, use the -i option.

Search for man pages with case sensitivity enabled.

You now know how to use the man command in Linux. Use the command to see user manuals for Linux commands, search for a specific keyword, or see all the entries in the manual.

Читайте также:  Linux ubuntu установка драйверов nvidia

To learn how can you search all man pages using known details as a search term, make sure to read our article apropos Linux command.

For more uses, refer to our article and find out how can man command review the complete manual for Expect.

Источник

which(1) — Linux man page

Which takes one or more arguments. For each of its arguments it prints to stdout the full path of the executables that would have been executed when this argument had been entered at the shell prompt. It does this by searching for an executable or script in the directories listed in the environment variable PATH using the same algorithm as bash(1).

This man page is generated from the file which.texinfo.

Options

—all, -a Print all matching executables in PATH, not just the first. —read-alias, -i Read aliases from stdin, reporting matching ones on stdout. This is useful in combination with using an alias for which itself. For example
alias which=’alias | which -i’
. —skip-alias Ignore option `—read-alias’, if any. This is useful to explicity search for normal binaries, while using the `—read-alias’ option in an alias or function for which. —read-functions Read shell function definitions from stdin, reporting matching ones on stdout. This is useful in combination with using a shell function for which itself. For example:
which()
export -f which —skip-functions Ignore option `—read-functions’, if any. This is useful to explicity search for normal binaries, while using the `—read-functions’ option in an alias or function for which. —skip-dot Skip directories in PATH that start with a dot. —skip-tilde Skip directories in PATH that start with a tilde and executables which reside in the HOME directory. —show-dot If a directory in PATH starts with a dot and a matching executable was found for that path, then print «./programname» rather than the full path. —show-tilde Output a tilde when a directory matches the HOME directory. This option is ignored when which is invoked as root. —tty-only Stop processing options on the right if not on tty. —version,-v,-V Print version information on standard output then exit successfully. —help Print usage information on standard output then exit successfully.

Return Value

Which returns the number of failed arguments, or -1 when no `programname’ was given.

Example

The recommended way to use this utility is by adding an alias (C shell) or shell function (Bourne shell) for which like the following:

alias which 'alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

This will print the readable ~/ and ./ when starting which from your prompt, while still printing the full path when used from a script:

> which q2 ~/bin/q2 > echo `which q2` /home/carlo/bin/q2

Bugs

The HOME directory is determined by looking for the HOME environment variable, which aborts when this variable doesn’t exist. Which will consider two equivalent directories to be different when one of them contains a path with a symbolic link.

Источник

Оцените статью
Adblock
detector