How to View Colored Man Pages in Linux?

Man pages are important reference documents for Unix/Linux users, but their default appearance is plain text that can be hard to read. This article shows how to add colors and highlighting to man pages to make them more readable and easier to follow.

Using most

The most command is a pager that can display colored man pages. First, install it using your package manager ?

sudo apt install most

Once installed, add most as your default pager by adding this line to your .bashrc file ?

export PAGER="most"

Reload your bash profile to apply the changes ?

source ~/.bashrc

Now when you view a man page, it will be displayed with colors ?

man cp

The output will show the man page with syntax highlighting, making different sections easily distinguishable ?

CP(1)                           User Commands                          CP(1)

NAME
       cp - copy files and directories

SYNOPSIS
       cp [OPTION]... [-T] SOURCE DEST
       cp [OPTION]... SOURCE... DIRECTORY
       cp [OPTION]... -t DIRECTORY SOURCE...

DESCRIPTION
       Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.

       Mandatory arguments to long options are mandatory for short options too.

       -a, --archive
              same as -dR --preserve=all

       --attributes-only
              don't copy the file data, just the attributes

       --backup[=CONTROL]

Using LESS_TERMCAP Variables

Another approach uses terminal capability (TERMCAP) variables to customize colors in the less pager. Add these environment variables to your .bashrc file ?

export LESS_TERMCAP_mb=$'\e[1;32m'     # Start blinking
export LESS_TERMCAP_md=$'\e[1;32m'     # Start bold mode
export LESS_TERMCAP_me=$'\e[0m'        # End all modes
export LESS_TERMCAP_se=$'\e[0m'        # End standout mode
export LESS_TERMCAP_so=$'\e[01;33m'    # Start standout mode
export LESS_TERMCAP_ue=$'\e[0m'        # End underline mode
export LESS_TERMCAP_us=$'\e[1;4;31m'   # Start underline mode

These variables define color codes for different text formatting ?

  • LESS_TERMCAP_md − Bold text (green)
  • LESS_TERMCAP_so − Standout mode (yellow)
  • LESS_TERMCAP_us − Underlined text (red)
  • LESS_TERMCAP_me, LESS_TERMCAP_se, LESS_TERMCAP_ue − Reset formatting

After adding these variables, reload your bash profile and view any man page to see the colored output ?

source ~/.bashrc
man ls

Color Code Reference

Color Code Color Usage
31 Red Underlined text
32 Green Bold text
33 Yellow Standout mode
1 Bold Text formatting
4 Underline Text formatting

Conclusion

Both most and LESS_TERMCAP variables provide effective ways to colorize man pages. The most pager offers built−in syntax highlighting, while TERMCAP variables give you more control over specific colors and formatting styles.

Updated on: 2026-03-15T17:37:31+05:30

463 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements