Commands to find help in Linux documentation | Linux Tutorial
for Beginners (4:52)
Code Examples and Video Script
Welcome. Today's question: How do you find command help in Linux?
I'm Paul, and if you can relate, a difficult hurdle to jump when
learning Linux is the help system, at least that's what I've found.
Step 1 - Practice Using the Linux Terminal
So in this 4-plus minute video, we'll get our minds around the manuals
that come pre-loaded on Linux and Mac computers. Yes, they aren't as
pretty as books, but they are comprehensive, free and not as heavy.
Finding help is essential for where we're headed.
So first, we'll go to the Terminal, review 4 commands for help.
whatis
man
info
type
Then 6 for navigation.
clear
nano
bash
ls
less
exit
Discuss 3 hidden gems and 2 web docs.
We'll introduce this odd looking term, builtins, and
expand on it in the next video. That's 15 topics, so let's get going.
Step 2 - Practice With 10 Commands
The whatis command for finding short Linux command descriptions
Okay, at the Terminal, let's hit two related commands,
whatis and
man and pick apart this output.
paul@fullstack:~$ whatis -s "1" whatis man
whatis (1) - display one-line manual page descriptions
man (1) - an interface to the on-line reference manuals
So whatis displays one-line
descriptions from the reference manual, and
man shows the whole reference manual.
Now breaking apart the command, it went like this, we used the
whatis command, to pull the first line
from two manuals at once. So these are the arguments
(whatis man) in this structure
# command -option(s) argument(s).
Okay, so for the options now, the
-s "1" says,
"return only those manuals in Section 1." That held back the manual
entry in Section 7. (See the difference in the output below)
paul@fullstack:~$ # command -options(s) argument(s)
paul@fullstack:~$ whatis whatis man
whatis (1) - display one-line manual page descriptions
man (1) - an interface to the on-line reference manuals
man (7) - macros to format man pages
paul@fullstack:~$ clear
The man command for full Linux command reference manual
Let me explain Sections by opening the whole manual. Here I use the
PgDn key.
paul@fullstack:~$ man man
Here are the Sections (numbered 1-9 at the bottom of the output) to
check out later.
MAN(1) Manual pager utils MAN(1)
NAME
man - an interface to the on-line reference manuals
SYNOPSIS
man [-C file] [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L locale] [-m sys
tem[,...]] [-M path] [-S list] [-e extension] [-i|-I] [--regex|--wildcard]
[--names-only] [-a] [-u] [--no-subpages] [-P pager] [-r prompt] [-7] [-E encoding]
[--no-hyphenation] [--no-justification] [-p string] [-t] [-T[device]] [-H[browser]]
[-X[dpi]] [-Z] [[section] page ...] ...
man -k [apropos options] regexp ...
man -K [-w|-W] [-S list] [-i|-I] [--regex] [section] term ...
man -f [whatis options] page ...
man -l [-C file] [-d] [-D] [--warnings[=warnings]] [-R encoding] [-L locale] [-P
pager] [-r prompt] [-7] [-E encoding] [-p string] [-t] [-T[device]] [-H[browser]]
[-X[dpi]] [-Z] file ...
man -w|-W [-C file] [-d] [-D] page ...
man -c [-C file] [-d] [-D] page ...
man [-?V]
DESCRIPTION
man is the system's manual pager. Each page argument given to man is normally the
name of a program, utility or function. The manual page associated with each of
these arguments is then found and displayed. A section, if provided, will direct
man to look only in that section of the manual. The default action is to search in
all of the available sections following a pre-defined order ("1 n l 8 3 2 3posix 3pm
3perl 5 4 9 6 7" by default, unless overridden by the SECTION directive in /etc/man
path.config), and to show only the first page found, even if page exists in several
sections.
The table below shows the section numbers of the manual followed by the types of
pages they contain.
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), e.g. man(7), groff(7)
8 System administration commands (usually only for root)
9 Kernel routines [Non standard]
2.7.0.2 2014-09-28 MAN(1)
Then type q to quit.
So our first manual page was for man,
but it could have been an easier one like
clear.
clear(1) General Commands Manual clear(1)
NAME
clear - clear the terminal screen
SYNOPSIS
clear
DESCRIPTION
clear clears your screen if this is possible, including its scrollback buffer (if
the extended "E3" capability is defined). clear looks in the environment for the
terminal type and then in the terminfo database to determine how to clear the
screen.
clear ignores any command-line parameters that may be present.
SEE ALSO
tput(1), terminfo(5)
This describes ncurses version 5.9 (patch 20140913).
clear(1)
After the NAME, sits SYNOPSIS with
the command ls,
[OPTION]..., in brackets means it's
optional, and the Argument noted as
[FILE]... here, is also optional.
Triple dots means multiple can be accepted.
Under DESCRIPTION sits all possible options. Moving
down, we see 8 pages, 230 lines in total. The sections are fairly
standard, and the takeaway knowing is where to look for options and
syntax.
And info is an alternative to
man, and it has its own interface.
Let's do an info optionless.
paul@fullstack:~$ info
File: dir, Node: Top This is the top of the INFO tree
This (the Directory node) gives a menu of major topics.
Typing "q" exits, "?" lists all Info commands, "d" returns here,
"h" gives a primer for first-timers,
"mEmacs<Return>" visits the Emacs manual, etc.
In Emacs, you can click mouse button 2 on a menu item or cross reference
to select it.
* Menu:
Basics
* Common options: (coreutils)Common options.
* Coreutils: (coreutils). Core GNU (file, text, shell) utilities.
* Date input formats: (coreutils)Date input formats.
* File permissions: (coreutils)File permissions.
Access modes.
* Finding files: (find). Operating on files matching certain criteria.
Compression
* Gzip: (gzip). General (de)compression of files (lzw).
Editors
* nano: (nano). Small and friendly text editor.
GNU Utilities
(158 lines trimmed)
Here we use hyperlinks to move around, activated by going to the
asterisk and hitting Enter.
This one (hitting Enter on
* next to Coreutils) will take you to
Coreutils, which is a package of multiple commands, 105 in fact,
including common ones like cd,
ls,
mv and
rm.
(Then hitting Enter on the
* next to
Introduction will open the following.)
File: coreutils.info, Node: Introduction, Next: Common options, Prev: Top, Up: Top
1 Introduction
**************
This manual is a work in progress: many sections make no attempt to
explain basic concepts in a way suitable for novices. Thus, if you are
interested, please get involved in improving this manual. The entire
GNU community will benefit.
The GNU utilities documented here are mostly compatible with the
POSIX standard. Please report bugs to <bug-coreutils&gnu.org>.
Remember to include the version number, machine architecture, input
files, and any other information needed to reproduce the bug: your
input, what you expected, what you got, and why it is wrong. Diffs are
welcome, but please include a description of the problem as well, since
this is sometimes difficult to infer. *Note (gcc)Bugs::.
This manual was originally derived from the Unix man pages in the
distributions, which were written by David MacKenzie and updated by Jim
Meyering. What you are reading now is the authoritative documentation
for these utilities; the man pages are no longer being maintained. The
original 'fmt' man page was written by Ross Paterson. François Pinard
did the initial conversation to Textinfo format. Karl Berry did the
indexing, some reorganization, and editing of the results. Brian
Youmans of the Free Software Foundation office staff combined the
manuals for textutils, fileutils, and sh-utils to produce the present
Okay, q to quit again, and personally
I prefer to use man pages over
info pages.
The Linux type command to examine a file's types or extension
And next, type gives you the type
and location of commands. For location, let's use
type -a nano and that gives all
locations, and type nano gives the
default location.
paul@fullstack:~$ clear
paul@fullstack:~$ type -a nano
nano is /usr/bin/nano
nano is /bin/nano
paul@fullstack:~$ type nano
nano is /usr/bin/nano
So if you wanted to use the other (the non-default version), you could
type the full path.
paul@fullstack:~$ /usr/bin/nano
Step 3 - Learn Faster with 3 Hidden Gems
Gem 1: Introduction to builtins
Let's do a type for
type itself to introduce a command
type that confuses beginners.
paul@fullstack:~$ type type
type is a shell builtin
It's a builtin, and it is a command that comes
built-in to bash, which is the command
processor I'm using now. I mention it because finding help for
builtins, like type,
can be tricky.
To illustrate, using bash -c help, we
see 60, or so, bashbuiltins.
paul@fullstack:~$ bash -c help
GNU bash, version 4.3.30(1)-release (x86_64-pc-linux-gnu)
These shell commands are defined internally. Type `help' to see this list.
Type `help name' to find out more about the function `name'.
Use `info bash' to find out more about the shell in general.
Use `man -k' or `info' to find out more about commands not in this list.
A star (*) next to a name means that the command is disabled.
job_spec [&] history [-c] [-d offset] [n] or hist>
(( expression )) if COMMANDS; then COMMANDS; [ elif C>
. filename [arguments] jobs [-lnprs] [jobspec ...] or jobs >
: kill [-s sigspec | -n signum | -sigs>
[ arg... ] let arg [arg ...]
[[ expression ]] local [option] name[=value] ...
alias [-p] [name[=value] ... ] logout [n]
bg [job_spec ...] mapfile [-n count] [-O origin] [-s c>
bind [-lpsvPSVX] [-m keymap] [-f file> popd [-n] [+N | -N]
break [n] printf [-v var] format [arguments]
builtin [shell-builtin [arg ...]] pushd [-n] [+N | -N | dir]
caller [expr] pwd [-LP]
case WORD in [PATTERN [| PATTERN]...)> read [-ers] [-a array] [-d delim] [->
cd [-L|[-P [-e]] [-@]] [dir] readarray [-n count] [-O origin] [-s>
command [-pVv] command [arg ...] readonly [-aAf] [name[=value] ...] o>
compgen [-abcdefgjksuv] [-o option] > return [n]
complete [-abcdefgjksuv] [-pr] [-DE] > select NAME [in WORDS ... ;] do COMM>
compopt [-o|+o option] [-DE] [name ..> set [-abefhkmnptuvxBCHP] [-o option->
continue [n] shift [n]
coproc [NAME] command [redirections] shopt [-pqsu] [-o] [optname ...]
declare [-aAfFgilnrtux] [-p] [name[=v> source filename [arguments]
dirs [-clpv] [+N] [-N] suspend [-f]
disown [-h] [-ar] [jobspec ...] test [expr]
echo [-neE] [arg ...] time [-p] pipeline
enable [-a] [-dnps] [-f filename] [na> times
eval [arg ...] trap [-lp] [[arg] signal_spec ...]
exec [-cl] [-a name] [command [argume> true
exit [n] type [-afptP] name [name ...]
export [-fn] [name[=value] ...] or ex> typeset [-aAfFgilrtux] [-p] name[=va>
false ulimit [-SHabcdefilmnpqrstuvxT] [lim>
fc [-e ename] [-lnr] [first] [last] o> umask [-p] [-S] [mode]
fg [job_spec] unalias [-a] name [name ...]
for NAME [in WORDS ... ] ; do COMMAND> unset [-f] [-v] [-n] [name ...]
for (( exp1; exp2; exp3 )); do COMMAN> until COMMANDS; do COMMANDS; done
function name { COMMANDS ; } or name > variables - Names and meanings of so>
getopts optstring name [arg] wait [-n] [id ...]
hash [-lr] [-p pathname] [-dt] [name > while COMMANDS; do COMMANDS; done
help [-dms] [pattern ...] { COMMANDS ; }
paul@fullstack:~$ clear
Help for many can only be found in the vast 5000-line
man page for
bash. That's hidden gem number one.
Gem 2: A directory with additional documentation on commands
Number two, is --help. I'd say 80% of
commands include this option, offering a quick snapshot.
paul@fullstack:~$ whatis --help
Usage: whatis [OPTION...] KEYWORD...
-d, --debug emit debugging messages
-v, --verbose print verbose warning messages
-r, --regex interpret each keyword as a regex
-w, --wildcard the keyword(s) contain wildcards
-l, --long do not trim output to terminal width
-C, --config-file=FILE use this user configuration file
-L, --locale=LOCALE define the locale for this search
-m, --systems=SYSTEM use manual pages from other systems
-M, --manpath=PATH set search path for manual pages to PATH
-s, --sections=LIST, --section=LIST
search only these sections (colon-separated)
-?, --help give this help list
--usage give a short usage message
-V, --version print program version
Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.
Gem 3: A directory with additional documentation on commands
The third gem sits in a directory packed with documentation.
GNU nano - an enhanced clone of the Pico text editor.
Overview
The nano project was started because of a few "problems" with the
wonderfully easy-to-use and friendly Pico text editor.
First and foremost is its license: the Pine suite does not use the
GPL or a GPL-friendly license, and has unclear restrictions on
redistribution. Because of this, Pine and Pico are not included
with many GNU/Linux distributions. Also, other features (like go
to line number or search and replace) were unavailable until
recently or require a command line flag. Yuck.
nano aims to solve these problems by emulating the functionality of
Pico as closely as possible while addressing the problems above and
perhaps providing other extra functionality.
The nano editor is now an official GNU package. For more
information on GNU and the Free Software Foundation, please see
http://www.gnu.org/.
How to compile and install nano
Download the nano source code, then:
tar zxvf nano-x.y.z.tar.gz
cd nano-x.y.z
./configure
make
make install
It's that simple. Use --prefix with configure to override the
default installation directory of /usr/local.
If you configured with the "--enable-nanorc" option, after
installation you might copy the doc/nanorc.sample to your home
directory, rename it to ".nanorc", and then edit it according to
your taste.
Web Page
http://www.nano-editor.org/
Mailing List and Bug Reports
Savannah hosts all the nano-related mailing-lists.
+ info-nano@gnu.org is a very low traffic list
used to announce new nano versions or other important
information about the project.
+ help-nano@gnu.org is for those seeking to get help without
wanting to hear about the technical details of its
development.
+ nano-devel@gnu.org is the list used by the people
that make nano and a general development discussion list, with
moderate traffic.
To subscribe, send email to nano-<name>-request@gnu.org with a
subject of "subscribe", where <name> is the list you want to
subscribe to.
For general bug reports, send a description of the problem to
nano@nano-editor.org or directly to the development list.
Current Status
GNU nano has reached its third stable milestone, 2.0.x.
Development of new features continues in the 2.1.x branch, while
2.0.x versions are dedicated to bug-fixing and polishing.
$Id: README 4057 2007-01-29 12:40:48Z dolorous $
So here's the takeaway with command help. You don't have to memorize
everything, just remember how to look things up, have some patience and
employ cheat sheets.
Step 4 - Learn Faster with Reference Materials on 2 pages
I'll tab over to two, first a cheat sheet for a deeper dive on each of
100 commands
(Cheat Sheet).