Linux / Unix: Colored Man Pages With less Command

How do I see colored man pages with standard Unix or Linux less command without installing most paging program for Unix / Linux like operating system?

You can use the less command, which is a program similar to more), but which allows backward movement in the file as well as forward movement. Edit ~/.bashrc file using a text editor such as vim / vi, enter:

How to view colored man pages in Linux

Edit the ~/.bashrc, run:
$ vi ~/.bashrc
Append the following code to get coloured manual pages with less command:

man() {
    command man "[email protected]"

Save and close the file. Just load your updated ~/.bashrc with the source command:
$ source ~/.bashrc
Test it:
$ man ls
$ man date
$ man 3 printf

A Note About Colored Man Pages On xterm or rxvt-unicode

If you are using xterm/uxterm or rxvt-unicode edit the ~/.Xresources or ~/.Xdefaults file, enter:
$ vi ~/.Xresources
$ vi ~/.Xdefaults
Xterm user add:

*VT100.colorBDMode:     true
*VT100.colorBD:         red
*VT100.colorULMode:     true
*VT100.colorUL:         cyan

rxvt-unicode user add:

URxvt.colorIT:      #87af5f
URxvt.colorBD:      #d7d7d7
URxvt.colorUL:      #87afd7

Save and close the file. Type the following command:
$ xrdb -load ~/.Xresources
$ xrdb -load ~/.Xdefaults
To view the man page of grep command, enter:
$ man grep
Sample outputs:

Fig.01: Colored man page

This entry is 2 of 2 in the Linux / UNIX Colorful Man Pages Tutorial series. Keep reading the rest of the series:

  1. Unix / Linux: Display Color Man Pages
  2. Linux / Unix: Colored Man Pages With less Command

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.