The “info” Command in Linux [6 Practical Examples]

The “info” command in Linux is a Unix utility that reads documentation stored in Info format. The Info document pages are made with Texinfo tools, can link with other pages, and create menus for easy navigation. Typically, you use the “info” command to access documentation for programming languages, system commands, and other Unix-related topics. This command is useful for working in text-based environments without graphical interfaces.

In this tutorial, you will learn the definition, characteristics, and uses of the “info” command in Linux with 6 examples.

Syntax of “info” Command in Linux

The basic syntax of the “info” command in Linux is:

info [OPTION]... [MENU-ITEM...]
EXPLANATION
  • The [OPTION] is an optional attribute that modifies the behavior of the “info” command.
  • The [MENU-ITEM] is also an optional argument that specifies the menu item or document page you want to see.

Options of “info” Command in Linux

Here is a list of some common options of the “info” command in Linux:

Option Description
-a, – – all Uses all matching manuals.
-k, – – apropos Looks up STRING in all indices of all manuals.
-d, – – directory=DIR Adds DIR to INFOPATH.
-f, – – file=Manual Specifies Info manual to visit.
-o, – – output=FILE Outputs selected nodes to FILE.
-O, – – show-options, – -usage Goes to command-line options node.
– – subnodes Recursively outputs menu items.
– – version Shows version information and exits.
-w, – – where, – – location Prints physical location of Info file.

Note: To display the manual pages for the “info” command, run the command below:

man info

To view the available options and usage information of the “info” command briefly, run:

info --help

How Does “info” Command in Linux Work?

The “info” command allows moving around its documentation by using arguments after it. If the first argument is not an option, the command treats it like a menu entry and is looked up in all the info files. If you don’t type anything or start with options, it shows the top-level menu. And, any other arguments you type after the option, the command interprets them as names of sub-menu items relative to the initial node you visited.

How to Use “info” Command in Linux?

To use the “info” command in Linux, follow the below steps:

  1. Open the terminal.
  2. To read the top-level directory menu, type the following command and press ENTER:
    info

    Reading top-level directory menu using info command

    Here, the “info” command displays the top-level directory menu.

  3. To read the given menu item from the top-level directory, use the command below:
    info info

    Reading given menu item from the top-level directory

    Upon running the command, it displays the general manual for the Info readers.

  4. To read the second menu item within the first menu, run:
    info info emacs

    Reading the second menu item within the first menu

    Thus, running the above command takes you to the “emacs” node within the “info” menu item manual.

6 Practical Examples of Applying “info” Command in Linux

Here are 6 practical examples of using the “info” command:

1. Displaying All Available Matching Manuals

To display all matching manuals for a particular command, use the info command with the  -a option. Here is the command to view all matching manuals for the ls command:

info -a ls

Viewing all matching manuals for ls using info command

Upon execution, the command uses all matching manuals for “ls” and displays them.

2. Showing STRING in Index of All Manuals

To look up and display STRING in all indices of all the manuals, use the info command followed by the -k option. For example: run the below command to search for the “ls” command within the index entries of all manuals:

info -k ls

Searching "ls" command within the index entries of all manuals

Thus, it displays any entries in the manuals that are relevant to “ls”.

3. Including Directory in INFOPATH

To include Directory in INFOPATH and display the same, use the info command followed by the -d option. Here is the command to do so:

info -d ls

Adding dir to filepath using info command with -d

Consequently, the command adds the DIR to INFOPATH and shows the same on your terminal.

4. Listing Command-Line Options

To go to the command-line options node and show them, you can use the info command with the -O option. For example, run the below command to view the command-line option for the “ls” command:

info -O ls

Viewing command-line options using info command with -O

As a result, the command-line option menu appears on the screen.

5. Printing File Locations

To print the physical file location of an Info file, use the info command along with -w option. For instance, use the command below to see the file location of the “ls” command:

info -w ls

Printing physical file location of ls command using info command with -w

Thus, the physical file location of the specified command pops up on display.

6. Displaying Version Information

To get the version information of a file and exit the command simultaneously, apply the info command with the --version option. For example, apply the below command to view the version information of the “ls” command:

info --version ls

Displaying version information of ls command

As you can see, the command shows the version information of the given command and exits.

How to Navigate Info Pages Like Man Pages in Linux?

To navigate through the Info pages menu like Man pages, use the info menu items recursively and pipe output contents to the less command. In this way, you can scroll through the Info pages just like the man command pages but with detailed information and cross-reference links in the document. This provides an overall reader experience in the Info pages.

Here is the command to get your Info pages menu output like the Man pages:

info --subnodes -o - ls | less

Moving through info pages like man pages

The above gif shows you can now scroll through your Info pages like Man pages using the above command.

Conclusion

To wrap up, the “info” command is a useful tool to access documentation in the Info format on Linux. You can rely on “info” to explore system commands, learn about programming languages, or research technical concepts. Moreover, you can extend and customize the Info formats for additional information or documentation for your software projects. Anyway, feel free to reach out if there are any questions or suggestions through the comment box below.

People Also Ask

What is “info” command in Linux?

The “info” command in Linux is a tool used to read documentation stored in the Info format. Info documents are generally written in plain text and structured hierarchically, with larger topics divided into smaller sections or subtopics. The default location of the info document is /usr/share/info.

What are the primary documentation sets found in Linux distributions?

The primary documentation sets found in Linux distributions include: Man pages, Info pages, and /usr/share/docs.

What is the difference between “info” command and “man” command in Linux?

The main difference between the “info” and “man” commands is that the “info” provides more readability. Man pages are great for short prompts. However,  the Info pages provide more details, robustness, better cross-reference linking between resources, and more readability. Also, not all commands have man pages or incomplete man pages. In that case, you need to use the Info pages.

What are the challenges of using the “info” command in Linux?

The main challenge of using the “info” command is its keybinding or keyboard shortcuts. If you are a Vim user, you might find it very unusual. To get more control over the info key bindings, you can run: info --vi-keys. Or type h within the info command for a summary of key bindings.

Rate this post
LINUX
FUNDAMENTALS
A Complete Guide for Beginners Enroll Course Now
icon linux
Avatar photo

Yousuf Shovon is a Linux Content Developer Executive (LCDE) at SOFTEKO. Previously, he worked for ExcelDemy, writing over 60+ articles on Excel. His goal is to write quality content for users to read and learn. In the future, he also wants to build various projects with LinuxSimply. He completed his graduation and post-graduation in Information Technology from Jahangirnagar University. Yousuf finds joy in solving diverse Linux-related problems to gain an all-around experience in Linux. Read Full Bio

Leave a Comment