Previous 1 2 3 Next 32 Replies Latest reply: Apr 13, 2010 12:34 AM by Neville Hillyer
Neville Hillyer Level 4 Level 4 (1,855 points)
From time to time new users ask where they can find a list of Terminal commands.

Clearly there are many possible replies to this but I like these four:

1 - Short list: http://ss64.com/osx/

2 - Long list: http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/

3 - Use the excellent 'List pages' facility of ManOpen. Each item is a clickable hot link.

4 - Produce your own list:

Open Terminal and paste the following and then type return:

/usr/libexec/makewhatis

Wait for the prompt.

Paste the following and then type return;

apropos ' '

On a basic Leopard installation this produces over 4,000 lines with each line containing one or more manual references. If you want to use the list it may be best to set the terminal to 999 columns before you start. It is easy to page down (shift page-down several times) to the bottom, select all (cmd A), copy (cmd C) and paste into a fast text editor (I still use BBEdit Light).

It is possible, although the mass edits are not trivial, to make each item in this list a hot link with one of the following:

A - HTML: <a href="x-man-page://ls">ls</a> - opens the manual page for ls in your Terminal - should work with most browsers - perhaps try clicking it!

B - Manual page - pity the hot links don't work in the Terminal although they do with several other applications such as ManOpen - see groff_mdoc for further information.

      .Dd
      .Dt LISTOFLINKS
      .Os
      .Bl -item -compact
      .It
      List of Links
      .It
      .Xr whatis 1
      - search the whatis database for complete words
      .It
      .Xr man 1
      - list directory contents
      .It
      .Xr ls 1
      - format and display the on-line manual pages
      .It
      .Xr groff_mdoc 7
      - reference for groff's mdoc implementation
      .El

Do others have better ways to view local manual pages with full scroll and hot links?

Xserve and two 733 MHz G4s with Leopard !, Mac OS X (10.5.8)
  • red_menace Level 6 Level 6 (14,825 points)
    I use Bwana and put it's index in a tab in Safari.
  • Neville Hillyer Level 4 Level 4 (1,855 points)
    I tried to edit section 'A' but was not quick enough. Here is the revised wording:

    A - HTML: View ls man page - should work with most browsers, both locally and from most sites (but not this site for reasons I don't understand) - Link source: <a href="x-man-page://ls">View ls man page</a>
  • BobHarris Level 6 Level 6 (15,460 points)
    4 - Produce your own list:

    Open Terminal and paste the following and then type return:

    /usr/libexec/makewhatis

    Wait for the prompt.

    Paste the following and then type return;

    apropos ' '

    On a basic Leopard installation this produces over 4,000 lines with each line containing one or more manual references.

    Minor point, but this will give you man pages on operating system calls, library functions, Perl routines, config file formats, etc..., where as your topic title is "List of terminal commands"

    This might be closer to reality

    apropos ' ' | egrep '(1)|(8)'

    Here is a little script that should generate an HTML list of section 1 and 8 commands

    #!/usr/bin/env bash
    apropos ' ' | awk ' /(1)|(8)/ {
    match($0,/ - /)
    cmd = substr($0,1,RSTART-1)
    therest = substr($0,RSTART)
    page = cmd
    sub(/(.*/,"",page)
    printf("%s%s
    ", page, cmd, therest)
    }' >tmp.html
  • Neville Hillyer Level 4 Level 4 (1,855 points)
    I read a poor review a while ago so was put off Bwana.

    However I have just tried it and it does most things it claims to do. Pity 'man' does not work in Safari - I have to use 'man://'.

    In common with other viewers it is not clear if the text width can be increased in the same way that it can with the standard terminal. Any thoughts on this?

    It took over my computer for some time building its index but I assume this is a rare event. ManOpen was much faster at doing this.

    Is there a way to invoke it by typing something simple in the terminal such as 'm ls' ? I have got ManOpen working in this way.

    The HTML is better than most but not as clean as it could be. Putting 'width="50%"' on half the index TDs is totally unnecessary. The individual pages are much worse with much redundant use of 'span' tags. Nothing will validate without DOCTYPE statements. It is now storing its own copy of these bloated files on my disk!
  • Neville Hillyer Level 4 Level 4 (1,855 points)
    apropos ' ' | egrep '(1)|(8)' worked well first time and I agree with your excellent point. However I believe that it does miss quite a few terminal commands although most people may never need them.

    Perhaps a quick copy paste of your longer script was too much to expect - it is in the early hours here - I will look at it tomorrow.
  • red_menace Level 6 Level 6 (14,825 points)
    It looks like the application just extracts what is in the existing man file - the main body is in a <pre> statement. The first time it indexes, the HTML formatted commands are built and placed in the /Users/you/Library/Caches/Bwana/ folder, with an index page in the manindex-.html file - this is what I put into the browser tab.

    It is mainly designed to be run in a browser, so if you don't want the bloated files you can just delete the cache folder - source code is available if you want to roll your own flavor.
  • BobHarris Level 6 Level 6 (15,460 points)
    Actually, I think my egrep needs to actually be

    apropos ' ' | egrep '(1)|(8)'

    As egrep treats the open and close paren pairs a grouping. The backslashes should turn off the magic.

    Sorry about that.
  • BobHarris Level 6 Level 6 (15,460 points)
    However I believe that it does miss quite a few terminal commands although most people may never need them.

    Section 2 are the "System Calls Manual" pages, useful to programmers. Think C, C++, Objective-C programming languages.

    Section 3 are the "Library Functions Manual" pages, also useful to programmers.

    Section 4 are the "Kernel Interfaces Manual" pages.

    Section 5 are the "File Formats Manual" pages.

    Section 6 are the "Games Manual" pages. OK, that might be interesting, if there were any interesting games listed

    Section 7 are the "Miscellaneous Information Manual" pages.

    Which leaves section 1 "General Commands Manual", and Section 8 "System Manager's Manual" pages.
  • Lurch66 Level 1 Level 1 (25 points)
    To print man pages as nicely-formatted PDFs, do the following, in this case "dscl":

    % man -t dscl | pstopdf -i -o ~/Desktop/dscl.pdf
  • Neville Hillyer Level 4 Level 4 (1,855 points)
    As far as displayed width of text is concerned I suspect there is something more complex going on.

    All the third party applications I have tried only display text at the default width whereas the default terminal can display text at whatever width you set its window. However this user set width is not picked up by third party applications which often allow you to set their window width but fail to alter the width of displayed text. I have also noticed that eg ManOpen will not work if /usr/bin/man is disabled. I have tried looking at various plist and config files but have not yet found a way to increase text width in anything other than the Terminal.

    Can anybody shed any light on this?

    I am new to groff but as far as I can tell it should replace source CRs within paragraphs with a space, ie not display each paragraph with <pre> (sorry about HTML terminology) as some of these third party applications apparently do.
  • Neville Hillyer Level 4 Level 4 (1,855 points)
    If you do apropos ' ' you will see that there are many more items other than just (1) > (8) not only (but particularly) on a well used OS.
  • Neville Hillyer Level 4 Level 4 (1,855 points)
    Yes, often mentioned as the solution to everything but my concerns about it are:

    1 - slow
    2 - source hot links (Xr) not used
    3 - too little info per screen due to large font and incorrectly interpreted source CRs - see my earlier post.
    4 - too much to type each time - I prefer the simplicity of m dscl
  • Neville Hillyer Level 4 Level 4 (1,855 points)
    I think there is something wrong with apropos ' ' | egrep '(1)|(8)'

    It produces a much shorter list than your earlier one and has very few items other than (1) and (8).
  • Neville Hillyer Level 4 Level 4 (1,855 points)
    I cannot get your HTML script to do anything. No apparent errors but I cannot find any output.
Previous 1 2 3 Next