Monday, August 15, 2016

Getting help from using command line (whatis, whereis, man, help, info, –help and pinfo)

Situation is there is no internet on production servers..!! Suddenly you need help to execute an commands in Linux Servers, How..?? Read this Getting Help 5 command line tools article end of this article you will get an confidence.
  1. Reading Manual Pages (man)
  2. Reading Page Information (pinfo)
  3. Reading info pages (info)
  4. Identify where is the command path (whereis)
  5. Know what the command will do (whatis)
  6. Help command to get options on the go (help command/command –help)

Getting help 5 command line tools

1. man command
man is an interface to the on-line reference manuals. 
Man Pages has 8 categories to refer the manual
  1. Executable programs or shell commands
  2. System calls (functions provided by the kernel)
  3. Library calls (functions within program libraries)
  4. Special files (usually found in /dev)
  5. File formats and conventions eg /etc/passwd
  6. Games
  7. Miscellaneous (including macro packages and conventions)
  8. System administration commands (usually only for root)
  9. Kernel routines [Non standard]

Manual page

Navigating Man Pages

  • Spacebar – Scrolling man page down
  • PageDown/Down Arrow – Scrolling man page down
  • PageUp/Up Arrow – Scrolling man page UP
  • /string – Search for particular string
  • n (key) – Repeat search Up to down
  • N (key) – Repeat search Down to up
  • g – Go to first to man page
  • G  – Go to end of the man page
  • q – Exit from man page
Search the short manual page descriptions for keywords and display any matches
[root@desktop ~]# man -k passwd
chpasswd (8) - update passwords in batch mode
fgetpwent_r (3) - get passwd file entry reentrantly
getpwent_r (3) - get passwd file entry reentrantly
gpasswd (1) - administer /etc/group and /etc/gshadow
grub2-mkpasswd-pbkdf2 (1) - Generate a PBKDF2 password hash.
lpasswd (1) - Change group or user password
lppasswd (1) - add, change, or delete digest passwords.
To see man page of particular command
[root@desktop ~]# man ls
LS(1) User Commands LS(1)
NAME
ls - list directory contents
Lookup for smail/short description about command
[root@Techtutorials ~]# man -f cat
cat (1)              - concatenate files and print on the standard output
cat (1p)             - concatenate and print files

2. pinfo command to Getting help

pinfo is the command to access man pages and get help to execute commands same like man command. Page info will be displayed in different format.
3. info command to read info documents
Read info documents, which will open all the documents continuous to one
  • UP Arrow/Page Up – To go upwards of the document
  • Down Arrow / Page Down – To go downwards of the document
  • /String – Search for particular word
  • Press ‘q’ – Quit from info document
info command 5 command line tools
info command options
  • -k = look up STRING in all indices of all manuals
  • -d = Add DIR to INFOPATH
  • -f = Specify info file and read
  • -R = Output “RAW” ANSI escapes

4. Whereis command to Locate binaries

whereis command is very handy when your environment is secured with path variables, where you have to type entire path to execute commands example like .i.e. /bin/ls
all the binaries are not located in same path like /bin/ binaries are located in different path like /bin /sbin /usr/bin/ /usr/sbin/, to identify banary location we have to execute whereis command to know binary exact location
[root@Techtutorials ~]# whereis ls
ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz

5. whatis command line tool

whatis utility will help you when you would like to know about  any command which you don’t know. Command i know but when i execute it what happens.
[root@Techtutorials ~]# whatis ls
ls (1)               - list directory contents
ls (1p)              - list directory contents
[root@Techtutorials ~]# whatis ip
ip (7)               - Linux IPv4 protocol implementation
ip (8)               - show / manipulate routing, devices, policy routing and tunnels
6. instance help on command
you can use <command –help> to get command options with little bit explanation
Use help command
[root@Techtutorials ~]# help cd
cd: cd [-L|[-P [-e]]] [dir]
    Change the shell working directory.
    Change the current directory to DIR.  The default DIR is the value of the
    HOME shell variable.
    The variable CDPATH defines the search path for the directory containing
    DIR.  Alternative directory names in CDPATH are separated by a colon (:).
    A null directory name is the same as the current directory.  If DIR begins
    with a slash (/), then CDPATH is not used.
Conclusion
Getting help from 5 command line tools is very handy to do our regular daily to daily activities

No comments:

Post a Comment