Friday, January 24, 2014

How to use the 'apropos' command in Unix

apropos - A utility searches through man pages in Unix and returns results that match keywords.
 
Syntax
      apropos [-d] keyword ...


I've found at times, I'm not exactly sure which man-page to read up on when dealing with something new.  Man pages are often updated as well.  Being able to search for keywords will help you to locate topics to learn.

For example, what if I discover I need to generate a private key, but I'm not sure how to do this?  I could try the following:

]$ man private
No manual entry for private

But, let's try this instead:

]$ apropos private
gendsa(1)                - generate a DSA private key from a set of parameters
genpkey(1)               - generate a private key
genrsa(1)                - generate an RSA private key
libpng(3)                - Portable Network Graphics (PNG) Reference Library 1.4.8 

pkcs8(1)                 - PKCS#8 format private key conversion tool
pkey(1)                  - public or private key processing tool


Now we have a lead.  Let's take a look at 'genpkey'

]$ man genpkey

NAME
       genpkey - generate a private key

SYNOPSIS
       openssl genpkey [-out filename] [-outform PEM|DER] [-pass arg]
       [-cipher] [-engine id] [-paramfile file] [-algorithm alg] [-pkeyopt
       opt:value] [-genparam] [-text]

DESCRIPTION
       The genpkey command generates a private key.
...

'apropos' can also be emulated by man by using the -k flag.  Typing 'man -k private' generates the same results as 'apropos'.  In a sense, apropos is a wrapper for 'man -k' as well.

No comments:

Post a Comment