How to View Colored Man Pages in Linux

Introduction

Man pages are a great source of information for Linux users. They provide detailed information about commands, programs, and other aspects of the operating system. However, the default man pages are displayed in plain text, which can be difficult to read. Fortunately, there is a way to view colored man pages in Linux, which can make them easier to read and understand. In this article, we will discuss how to view colored man pages in Linux.

How to View Colored Man Pages in Linux

1. Install the most recent version of the less command line pager.

2. Open the terminal and type the following command to enable colored man pages:

export LESS_TERMCAP_mb=$’\E[01;31m’

export LESS_TERMCAP_md=$’\E[01;31m’

export LESS_TERMCAP_me=$’\E[0m’

export LESS_TERMCAP_se=$’\E[0m’

export LESS_TERMCAP_so=$’\E[01;44;33m’

export LESS_TERMCAP_ue=$’\E[0m’

export LESS_TERMCAP_us=$’\E[01;32m’

3. To view a colored man page, type the following command:

man -c

Replace with the name of the command you want to view.

In Unix-like operating systems, a man page (in full manual page) is a documentation for a terminal-based program/tool/utility (commonly known as a command). It contains the name of the command, syntax for using it, a description, options available, author, copyright, related commands etc.

You can read the manual page for a Linux command as follows; this will display the man page for the df command:

$ man df 
df Command Man Page
df Command Man Page

By default, the man program normally uses a terminal pager program such as more or less to format its output, and the default view is normally in white color for every kind of text (bold, underlined etc..).

You can make some tweaks to your ~/.bashrc file to get nicely colored man pages by specifying a color scheme using various LESS_TERMCAP variables.

$ vi ~/.bashrc

Add following color scheme variables.

export LESS_TERMCAP_mb=$'\e[1;32m'
export LESS_TERMCAP_md=$'\e[1;32m'
export LESS_TERMCAP_me=$'\e[0m'
export LESS_TERMCAP_se=$'\e[0m'
export LESS_TERMCAP_so=$'\e[01;33m'
export LESS_TERMCAP_ue=$'\e[0m'
export LESS_TERMCAP_us=$'\e[1;4;31m'

Following are the color codes that we used in the above configuration.

  • 31 – red
  • 32 – green
  • 33 – yellow

And here are the meanings of the escape codes used in the above configuration.

  • 0 – reset/normal
  • 1 – bold
  • 4 – underlined

You can additionally reset your terminal by typing reset or even start up another shell. Now when you try to view a man page df command, it should look like this, nicer than the default view.

Colored Man Page
Colored Man Page

Alternatively, you can use the MOST paging program, which works on Unix-like operating systems and supports multiple windows and can scroll left and right.

$ sudo apt install most		#Debian/Ubuntu 
# yum install most		#RHEL/CentOS
# dnf install most		#Fedora 22+

Next, add the line below in your ~/.bashrc file, then source the file like before and possibly reset your terminal.

export PAGER="most"
Most Paging Program for Linux
Most Paging Program for Linux

In this article, we showed you how to display beautifully colored man pages in Linux. To send us any queries or share any useful Linux shell tips/tricks, use the comment section below.

How to View Colored Man Pages in Linux

Man pages are a great source of information for Linux users. They provide detailed information about commands, programs, and other topics related to the Linux operating system. However, the default man pages are plain text and can be difficult to read. Fortunately, there is a way to view colored man pages in Linux.

Step 1: Install the Man Page Colorizer

The first step is to install the Man Page Colorizer. This is a command-line utility that will allow you to view colored man pages in Linux. To install it, open a terminal window and enter the following command:

sudo apt-get install manpage-colorizer

Step 2: Configure the Man Page Colorizer

Once the Man Page Colorizer is installed, you need to configure it. To do this, open the configuration file in a text editor. The configuration file is located at /etc/manpage-colorizer.conf. In the configuration file, you can set the colors for different types of text. For example, you can set the color for command names, options, and other text.

Step 3: View Colored Man Pages

Once the Man Page Colorizer is configured, you can view colored man pages in Linux. To do this, simply use the man command as you normally would. For example, to view the man page for the ls command, you would enter the following command:

man ls

The man page will be displayed in color, making it much easier to read.

Conclusion

Colored man pages can make it much easier to read and understand the information in man pages. By following the steps outlined in this article, you can easily view colored man pages in Linux.

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

Contact
San Vito Al Tagliamento 33078
Pordenone Italy
Item added to cart.
0 items - 0.00
Open chat
Scan the code
Hello 👋
Can we help you?