8

I want to know if a manpage can be edited. If yes how? (If possible by changing in gedit).

P.S.- I want to know if a manpage already written can be edited (just for fun).

3
  • gedit ... might be problematic since man pages are zipped files if I remember correctly. something like gmanedit (and yes the name is gedit with man in it knows about that ;-) )
    – Rinzwind
    Jun 18, 2016 at 17:49
  • 1
    Interesting to read, this is where I got it (and how I still do it) cyberciti.biz/faq/linux-unix-creating-a-manpage Jun 20, 2016 at 16:56
  • @JacobVlijm not entirely releated to question but still useful.Thanks :-)
    – bha159
    Jun 22, 2016 at 15:31

4 Answers 4

8

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.
1
  • Thnx a lot ,if I can accept both answers I would have accepted this too.
    – bha159
    Jun 18, 2016 at 18:19
6

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.

4
  • so no for using gedit
    – bha159
    Jun 18, 2016 at 18:02
  • well you probably can if you really want to but then need to know what you are doing ... you need to unzip and zip it correctly. copy it to the right place. and make sure you correctly edit the text.
    – Rinzwind
    Jun 18, 2016 at 18:04
  • You know any link or guide where I can see?
    – bha159
    Jun 18, 2016 at 18:06
  • sorry no, have not found one.
    – Rinzwind
    Jun 18, 2016 at 18:13
3

As already discussed it isn't recommended to do so - the other post explain as well that it is possible nevertheless.

I would like to mention some alternatives - software projects offering some kind of user-editable cheat-sheets

Most of them come with a good preset of cheat-sheets, which you then enhance on demand.

1
  • good, though many (inc myself) like single point entry to problem solving. I try to go to man pages to be "independent" but in case it fails go to google. if I edit man page I can find solution second time from 1st source. Apr 12, 2022 at 7:42
1
man  Your_Command_HERE > ~/your_cmd.man
neovim ~/your_cmd.man

edit as regular file then :Man! to enjoy manpage's syntax highlights

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .