This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature: Desktop Software

Secrets of the man command

By Shashank Sharma on September 07, 2007 (4:00:00 PM)

Share    Print    Comments   

The most referenced and most often used command on any Linux distribution is man, which lets users read the manual pages of other commands. Here are a couple of less well-known but useful commands that let you bookmark a position within a man page, and test a command you read from the man page without closing the page.

Trick #1: Bookmarking

Man uses the less utility to display the manual pages on your screen. When reading through a lengthy man page, I often forget an interesting fact if I don't make a note of it somewhere before moving on to reading the rest of the man page. In such a scenario you can create a bookmark within the man page.

While reading through a man page, you can press m followed by any letter to mark a position in the page. You can then return to this position in the page from anywhere by typing ' (single quote) followed by that letter. You can mark multiple positions within a man page by using a different letter to mark each position. You can use only use alphabet characters to mark a position within the man page, but contrary to what the man page for less suggests, you can use capital letters as well as lower case. For example, you can mark a position with the letter w and mark an entirely different one with W.

The marked positions are remembered for only the current session, which means that as soon as you close the man page, the marked positions are lost. Also, if you accidentally use the same letter to mark two positions, only the most recently marked position is marked.

Suppose you jumped from marked position a to marked position q, a distance of 10 lines. You next jumped from this position to another position t 30 lines away, then jumped to a position p 5 lines away. When you now type '' (two single quotes) you will jump to the position where you had traveled the most lines. That is, you'll end up at position t, since you had traveled the most, 30 lines, to get there.

Since man uses less to display man pages, you can also use the bookmarking trick to mark positions in any file you read using less.

Trick #2: Testing commands from within man

Another useful man trick is to press ! whenever you wish to test a command you've just read in the man page. This allows you to execute the command without closing the man page or opening another terminal window. Once you've tested the command, press the Enter key and you'll be dropped back to where you were in the man page.

Again, this works because man uses less to display the man pages. The commands used in less, as described in its man page, are based on both the more utility and the vi text editor. The exclamation trick can also be used from within vi. Try it yourself: open a file in vi, then press : followed by ! and type ls -l.

The exclamation mark trick makes life easier by reducing the number of clicks or key-presses it would require to otherwise test a command and then return to the man page.

Shashank Sharma specializes in writing about free and open source software for new users and moderates the Linux.com forum boards. He is the coauthor of Beginning Fedora, published by Apress.

Share    Print    Comments   

Comments

on Secrets of the man command

Note: Comments are owned by the poster. We are not responsible for their content.

exclamation mark

Posted by: Anonymous [ip: 24.80.34.124] on September 07, 2007 05:36 PM
That's wonderful! I've always had to open another konsole when I want to read man pages. This is a very useful trick that I'm sure will become a habit very quickly.

#

Secrets of the man command

Posted by: Anonymous [ip: 88.73.65.217] on September 07, 2007 06:13 PM
These are neither secrets, nor is this arbicle about the man command.

#

Re: Secrets of the man command

Posted by: Anonymous [ip: 202.153.40.235] on September 13, 2007 11:33 AM
whatever is it....it works with man...

#

Secrets of the man command

Posted by: Anonymous [ip: 86.141.196.45] on September 07, 2007 09:29 PM
Common PAGER commands more like

#

Secrets of the man command

Posted by: Anonymous [ip: 67.96.58.89] on September 08, 2007 03:50 PM
the secret of the man command is to suck, swallow and never spit

#

Secrets of the man command

Posted by: Anonymous [ip: 190.24.78.27] on September 08, 2007 06:15 PM
Please be accurate and precise and call this article "Secrets of less". man(1) has nothing to do with either tip and it is misleading to tell to all newbies that man uses less(1) by default. In fact, it uses more(1) (in the BSD 4.xx lineage) or pg(1) (in the SysVR4 lineage) but it has come to pass that most GNU/Linux and BSDs (otherwise known as "can't-call-myself-UNIX(tm)-till-I-pay-the-opengroup") have realized that "less is more" and have replaced more(1) and pg(1) for less(1). To attribute to man(1) the abilities of the pager is just plain wrong.

#

Re: Secrets of the man command

Posted by: Anonymous [ip: 76.229.84.27] on September 09, 2007 08:26 AM
Right on! In particular, if I set the PAGER variable to something else (like emacs), this will NOT work.

#

Secrets of the man command (secretos del comando man)

Posted by: Anonymous [ip: 189.166.224.76] on September 09, 2007 06:16 AM
Para el publico que habla español, hice una adapatacion de este articulo en mi sitio:

For the spanish speaking audience I made an adaptation of this article in my web site:

<a href="http://www.linuxtotal.com.mx/index.php?cont=info__tips_013">www.linuxtotal.com.mx</a>

#

Secretos del comando man

Posted by: Anonymous [ip: 189.166.224.76] on September 09, 2007 06:20 AM
Para los que quieran verlo en español, hice una adaptacion de este articulo en mi sitio:

<a href="http://www.linuxtotal.com.mx/index.php?cont=info__tips_013">www.linuxtotal.com.mx</a>


(For the spanish speaking audience, here there is an adaptation of this article)

#

Secrets of the man command

Posted by: Anonymous [ip: 59.178.33.249] on September 09, 2007 12:48 PM
This article talks about how to better use man and it mentions some tips which we don't come across by just intuitively using man so it's appropriately titled and has appropriate content. It does mention that man uses less for the purpose.

#

May Favorite Man Page

Posted by: Anonymous [ip: 68.77.161.179] on September 09, 2007 02:19 PM
Man Bash, of course.

#

Re: May Favorite Man Page

Posted by: Anonymous [ip: 142.46.79.234] on September 10, 2007 06:37 PM
There was an old x screensaver called xsublim. It had a brilliant man page. google "man xsublim" if it's not in your distro.

#

Secrets of the man command

Posted by: Anonymous [ip: 63.253.158.75] on September 11, 2007 09:14 PM
Those are a couple tricks I didn't know already, thanks man. But you forgot
the ever important ability to search man pages with /

#

Secrets of the man command

Posted by: Anonymous [ip: 82.146.251.29] on September 12, 2007 11:16 AM
Thanks another for very interesting article. Keep up the good work. Regards
<a href="http://www.profesjonalna-reklama.pl" target="_blank">Pozycjonowanie</a>

#

Secrets of the man command

Posted by: Anonymous [ip: 195.5.37.132] on September 12, 2007 11:52 AM
Thank man. I don't know this!

#

Secrets of the man command

Posted by: Anonymous [ip: 89.59.158.209] on October 10, 2007 03:18 PM
Thank you very much for this interesting Article, very useful information....
<a href="http://www.yellobook.eu" target="_blank">yellowpages</a>

#

Secrets of the man command

Posted by: Anonymous [ip: 83.26.162.4] on November 10, 2007 09:26 AM
You are absolutelly right guys <a href="http://technology-pages.blogowice.pl/">Engineering</a>

#

Secrets of the man command

Posted by: koray on November 13, 2007 11:45 PM
<a href=http://www.ayi.org target=_blank title=ayi>ayi</a>

#

Secrets of the man command

Posted by: Anonymous [ip: 88.214.193.87] on December 06, 2007 12:15 PM
<a href="http://biturls.com">biturls</a>
<a href="http://gosurls.com">gosurls</a>
<a href="http://urlsbox.com">urlsbox</a>
<a href="http://wazzuplinks.com">wazzuplinks</a>
<a href="http://solarurls.com">solarurls</a>

#

Secrets of the man command

Posted by: Anonymous [ip: 85.98.233.242] on February 24, 2008 02:43 AM
<a href="http://www.oyunambari.com">oyun</a>

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya