Red Hat – Finding things

      No Comments on Red Hat – Finding things

MAN Pages
So one of the most important things is just knowing where to find help when you need it.  Linux is great at this!  MAN pages are attached to most commands and they give you a wealth of knowledge on how the command works.  For instance, take a look at this…

[root@CentosBox etc]# man mv

Gives me…

MORE(1)                   BSD General Commands Manual                  MORE(1)

     more – file perusal filter for crt viewing

     more [-dlfpcsu] [-num] [+/ pattern] [+ linenum] [file …]

     More is a filter for paging through text one screenful at a time.  This
     version is especially primitive.  Users should realize that less(1) pro-
     vides more(1) emulation and extensive enhancements.

     Command line options are described below.  Options are also taken from
     the environment variable MORE (make sure to precede them with a dash
     (ââ-ââ)) but command line options will override them.

     -num  This option specifies an integer which is the screen size (in

     -d    more will prompt the user with the message "[Press space to con-
           tinue, âqâ to quit.]" and will display "[Press âhâ for instruc-
           tions.]" instead of ringing the bell when an illegal key is

     -l    more usually treats ^L (form feed) as a special character, and will
           pause after any line that contains a form feed.  The -l option will
           prevent this behavior.

     -f    Causes more to count logical, rather than screen lines (i.e., long
           lines are not folded).

     -p    Do not scroll.  Instead, clear the whole screen and then display
           the text.

     -c    Do not scroll.  Instead, paint each screen from the top, clearing
           the remainder of each line as it is displayed.

     -s    Squeeze multiple blank lines into one.

     -u    Suppress underlining.

     +/    The +/ option specifies a string that will be searched for before
           each file is displayed.

     +num  Start at line number num.

     Interactive commands for more are based on vi(1).  Some commands may be
     preceded by a decimal number, called k in the descriptions below.  In the
     following descriptions, ^X means control-X.

     h or ?      Help: display a summary of these commands.  If you forget all
                 the other commands, remember this one.

     SPACE       Display next k lines of text.  Defaults to current screen

     z           Display next k lines of text.  Defaults to current screen
                 size.  Argument becomes new default.

     RETURN      Display next k lines of text.  Defaults to 1.  Argument
                 becomes new default.

     d or ^D     Scroll k lines.  Default is current scroll size, initially
                 11.  Argument becomes new default.

     q or Q or INTERRUPT

     s           Skip forward k lines of text.  Defaults to 1.

     f           Skip forward k screenfuls of text.  Defaults to 1.

     b or ^B     Skip backwards k screenfuls of text.  Defaults to 1.  Only
                 works with files, not pipes.

     â           Go to place where previous search started.

     =           Display current line number.

     /pattern    Search for kth occurrence of regular expression.  Defaults to

     n           Search for kth occurrence of last r.e.  Defaults to 1.

     !<cmd> or :!<cmd>
                 Execute <cmd> in a subshell

     v           Start up an editor at current line.  The editor is taken from
                 the environment variable VISUAL if defined, or EDITOR if
                 VISUAL is not defined, or defaults to "vi" if neither VISUAL
                 nor EDITOR is defined.

     ^L          Redraw screen

     :n          Go to kth next file.  Defaults to 1.

     :p          Go to kth previous file.  Defaults to 1.

     :f          Display current file name and line number

     .           Repeat previous command

     More utilizes the following environment variables, if they exist:

     MORE        This variable may be set with favored options to more.

     SHELL       Current shell in use (normally set by the shell at login

     TERM        Specifies terminal type, used by more to get the terminal
                 characteristics necessary to manipulate the screen.

     vi(1) less(1)

     Eric Shienbrood, UC Berkeley
     Modified by Geoff Peck, UCB to add underlining, single spacing
     Modified by John Foderaro, UCB to add -c and MORE environment variable

     The more command appeared in 3.0BSD.  This man page documents more ver-
     sion 5.19 (Berkeley 6/29/88), which is currently in use in the Linux com-
     munity.  Documentation was produced using several other versions of the
     man page, and extensive inspection of the source code.

Linux 0.98                     December 25, 1992                    Linux 0.98

So if you don’t know how to use a command, just put ‘man’ in front of it and see if there are any directions. 

Finding commands by searching whatis
This is a great tip I picked up from class today.  Say you want to do something, but you aren’t 100% sure what the command is for it.  Easy enough, just use the ‘whatis’ database.  The whatis database lists all available programs with a one line description of the program.  Better yet, you can search it for pieces of words.  Check out this example…

[root@CentosBox etc]# man -k partition
GNU Parted [parted]  (8)  – a partition manipulation program
addpart              (8)  – simple wrapper around the add partition ioctl
delpart              (8)  – simple wrapper around the del partition ioctl
fdisk                (8)  – Partition table manipulator for Linux
kpartx               (8)  – Create device maps from partition tables
kpartx              (rpm) – Partition device manager for device-mapper devices.
mpartition           (1)  – partition an MSDOS hard disk
parted              (rpm) – The GNU disk partition manipulation program
partprobe            (8)  – inform the OS of partition table changes
partx                (8)  – telling the kernel about presence and numbering of on-disk partitions
pvcreate             (8)  – initialize a disk or partition for use by LVM
pvresize             (8)  – resize a disk or partition in use by LVM2
sfdisk               (8)  – Partition table manipulator for Linux

Check it out, it just gave us all the program available that have ‘partition’ in the program name or in it’s description.  Pretty handy if you ask me.  If the ‘whatis’ database isn’t updated (or hasn’t been built yet) you can do so by running the ‘makewhatis’ command from the root user. 

The locate command
The locate command allows you to quickly list all files including a particular string.  It also works off of a database like whatis did.  The command is again ridiculously easy to use…

[root@CentosBox etc]# locate jon

Note, that this returns any instance that includes ‘jon’ in the full path.  The last result is called ‘index.html’ but since the path included ‘jon’ it still got returned.  If you aren’t getting any results, you can run the ‘updatedb’ command from root to load the database.

The find command
Find works much like locate but it only searches for file names and you generally specify a starting path.  For instance, here is the same search for ‘jon’ using find…

[root@CentosBox etc]# find / -name *jon*

Note that I had to use wildcard(*) symbols around my search term in order to get it to return file names that included ‘jon’.

Leave a Reply

Your email address will not be published. Required fields are marked *