Groffer Command on Linux



The Groffer program is the easiest way to use Groff. It shows documents written in the groff or roff languages, which are compatible with troff.

Groffer can also find and show manual (man) pages, making it a potential replacement for the man command. It shows these files and man pages on an X window system, tty, and other document viewers. In addition to this, the Groffer command can handle compressed files by automatically decompressing them.

In this tutorial, we will walk you through different use cases of the Groffer command in Linux.

Table of Contents

Here is a comprehensive guide to the options available with the Groffer command −

What is Groffer Command?

Groffer supports several output formats, such as X Window viewer (gxditview), PostScript, PDF, DVI, web browsers (HTML), or text terminals. It also automates many settings using the grog program but its not limited to that, instead, it allows manual control as well.

You can specify multiple files, which can be combined into one document. Moreover, option handling follows the GNU style, where options and file names can be freely mixed, and long options can be shortened.

Groffer Command Installation

Groffer is not pre-installed on most Linux distributions, by default. However, you can install it easily using the distribution default package manager, like apt, DNF, or PACMAN. Use one of the following commands based on your Linux distribution to install groffer on your system −

#To install Groffer on Ubuntu
sudo apt install groff
#To install Groffer on Fedora
sudo dnf install groff
#To install Groffer on Arch Linux
sudo pacman -S groff

After installing groffer, you can use it to view documentation for commands and programs.

How to Use Groffer Command?

The basic usage of the groffer command is simple, just provide a file name or man page without specifying any additional option. Heres a basic syntax of this command −

groffer [options] [files]

Options Groffer Command

The groffer command supports several options to customize its behavior, either through configuration files, the $GROFFER_OPT environment variable, or directly from the command line.

The table below illustrates some commonly used options of the groffer command −

Option Description
-h, --help It shows the help page of groffer and exit.
-v, --version It displays the version information and exit.
--auto It determines the mode automatically.
--default It uses default settings.
--default-modes mode1,mode2,... It sets default modes to specified options.
--dvi It specifies the DVI output format.
--dvi-viewer prog It specifies the viewer program for DVI files.
--groff It uses groff as the processing tool.
--html It generates HTML output.
--html-viewer prog It sets the viewer for HTML output.
--mode display_mode It specifies the display mode explicitly.
--pdf It specifies the output in PDF format.
--pdf-viewer prog It defines the viewer program for PDF files.
--ps It specifies the PostScript output format.
--ps-viewer prog It sets the viewer for PostScript files.
--source It shows the source of the document.
--text It shows output in plain text format.
--to-stdout It sends output to stdout.
--tty It uses terminal mode for output.
--tty-viewer prog Specify the viewer for terminal mode.
--www It enables web mode for output.
--www-viewer prog It defines the viewer for web output.
--apropos Search for commands related to a keyword.
--man Display the manual page.
--no-man Skip displaying the manual page.
--whatis Show a brief description of commands.
--all Show all available options.
--ascii Output in ASCII format.
--ditroff It uses ditroff for output.
--locale language It sets the locale for output.
--manpath dir1:dir2:... It specifies paths to search for manual pages.
--display X-display It sets the X display to use.
--geometry size_pos It sets the window size and position.
--resolution value It sets the resolution for output.
--debug It enables debug mode.
--print text It prints the specified text.
-V It shows the verbose output.

Examples of Groffer Command in Linux

Lets go through different examples of the groffer command to see how it works in Linux:

  • Displaying a File or Man Page with Groffer
  • Concatenating Multiple Commands Man Pages into One PDF with Groffer
  • Searching Man Page Descriptions with Groffer
  • Displaying All Related Man Pages with Groffer
  • Displaying Output in Terminal Mode with Groffer

Displaying a File or Man Page with Groffer

Lets run the groffer command to show the manual page of the printf command −

groffer printf

This command generates a PDF output for the printf man page, allowing you to read or print it as needed.

Concatenating Multiple Commands Man Pages into One PDF with Groffer

You can specify multiple commands in groffer to concatenate their manual pages into a single PDF −

groffer ls grep ps

This command will create a PDF that includes the man pages for the ls, grep, and ps commands.

Searching Man Page Descriptions with Groffer

We can run the groffer command with the --apropos option to search the man page descriptions for the given keyword. This command returns a list of commands and topics related to that keyword −

groffer --apropos echo

When we execute this command, it displays a list of all man pages that mention "echo" in their descriptions. This helps you find related documentation quickly.

Displaying All Related Man Pages with Groffer

You can use the --all option with the groffer command to display all man pages related to a given keyword, such as "printf −

groffer --all printf

When you execute this command, you will see a comprehensive list of man pages that mention "printf. It will include information on related functions like fprintf, dprintf, sprintf, snprintf, and vprintf.

Displaying Output in Terminal Mode with Groffer

You can use the --tty option with the groffer command to display the output in terminal or tty mode −

groffer --tty printf

When you execute this command, it will show the man page for "printf" directly in your terminal.

Conclusion

The Groffer command simplifies the use of Groff by displaying documents written in groff or roff languages. It can replace the traditional man command, offering flexibility in output formats like PDF, HTML, and plain text. Groffer efficiently handles manual pages and compressed files, making it a useful tool for Linux users.

In this tutorial, we covered Groffers installation, basic usage, options, and various examples, demonstrating how to effectively utilize Groffer for viewing and managing documentation.

Advertisements