How do I edit a manpage?

Solution 1:

Install gmanedit.

Gtk+ Manpages Editor is an editor for man pages that runs on X with GTK+.

Gmanedit is an application which allows you to edit manual pages (man) on Linux/Unix systems.

It is like most common HTML editors but more easy. You need to know manpages format.

Update: since gmanedit is dead, try its fork gmanedit2.

Solution 2:

Yes, you can, but it isn't recommended. The best approach would probably be something like the tool Rinzwind suggested, but yes, you can also do it manually. I will use the man page for grep as an example.

  1. Man pages are compressed files so you either need to use a real editor, like emacs, that can read/write compressed files, or you must first uncompress it:

    sudo gunzip /usr/share/man/man1/grep.1.gz
    
  2. Edit it:

    sudo gedit /usr/share/man/man1/grep.1
    

    Now, the format is a little weird. However, if you only want to change simple things, you can ignore the formatting and only change the plain text. For example, I can change the description of grep quite easily. This is what the first few lines look like when you open the file in gedit (or any other editor):

    .\" GNU grep man page
    .if !\n(.g \{\
    .   if !\w|\*(lq| \{\
    .       ds lq ``
    .       if \w'\(lq' .ds lq "\(lq
    .   \}
    .   if !\w|\*(rq| \{\
    .       ds rq ''
    .       if \w'\(rq' .ds rq "\(rq
    .   \}
    .\}
    .
    .ie \n[.g] .mso www.tmac
    .el \{\
    . de MTO
    \\$2 \(laemail: \\$1 \(ra\\$3
    ..
    . de URL
    \\$2 \(laURL: \\$1 \(ra\\$3
    ..
    .\}
    .
    .TH GREP 1 \*(Dt "GNU grep 2.25" "User Commands"
    .hy 0
    .
    .SH NAME
    grep, egrep, fgrep \- print lines matching a pattern
    .
    .SH SYNOPSIS
    .B grep
    .RI [ OPTIONS ]
    .I PATTERN
    .RI [ FILE .\|.\|.]
    .br
    .B grep
    .RI [ OPTIONS ]
    .RB [ \-e
    .I PATTERN
    |
    .B \-f
    .IR FILE ]
    .RI [ FILE .\|.\|.]
    .
    .SH DESCRIPTION
    .B grep
    searches the named input
    .IR FILE s
    for lines containing a match to the given
    .IR PATTERN .
    If no files are specified, or if the file
    .RB "\*(lq" \- "\*(rq"
    is given,
    .B grep
    searches standard input.
    By default,
    .B grep
    prints the matching lines.
    .PP
    In addition, the variant programs
    

    So, to change the description, I might change that to (scroll down to the "DESCRIPTION" section):

    .\" GNU grep man page
    .if !\n(.g \{\
    .   if !\w|\*(lq| \{\
    .       ds lq ``
    .       if \w'\(lq' .ds lq "\(lq
    .   \}
    .   if !\w|\*(rq| \{\
    .       ds rq ''
    .       if \w'\(rq' .ds rq "\(rq
    .   \}
    .\}
    .
    .ie \n[.g] .mso www.tmac
    .el \{\
    . de MTO
    \\$2 \(laemail: \\$1 \(ra\\$3
    ..
    . de URL
    \\$2 \(laURL: \\$1 \(ra\\$3
    ..
    .\}
    .
    .TH GREP 1 \*(Dt "GNU grep 2.25" "User Commands"
    .hy 0
    .
    .SH NAME
    grep, egrep, fgrep \- print lines matching a pattern
    .
    .SH SYNOPSIS
    .B grep
    .RI [ OPTIONS ]
    .I PATTERN
    .RI [ FILE .\|.\|.]
    .br
    .B grep
    .RI [ OPTIONS ]
    .RB [ \-e
    .I PATTERN
    |
    .B \-f
    .IR FILE ]
    .RI [ FILE .\|.\|.]
    .
    .SH DESCRIPTION
    .B grep
    searches for and destroys all the unicorns on your system.
    .PP
    In addition, the variant programs
    
  3. Save the file, exit gedit and then recompress it (this isn't actually needed, man grep already works, but better to be tidy):

    sudo gzip /usr/share/man/man1/grep.1
    

Now, just run man grep and you will see:

GREP(1)

NAME
       grep, egrep, fgrep - print lines matching a pattern

SYNOPSIS
       grep [OPTIONS] PATTERN [FILE...]
       grep [OPTIONS] [-e PATTERN | -f FILE] [FILE...]

DESCRIPTION
       grep searches for and destroys all the unicorns on your system.

       In addition, the variant programs egrep and fgrep are the same as grep -E and grep -F, respectively.  These variants are deprecated, but are provided
       for backward compatibility.