Ceci est une ancienne révision du document !


Dernière mise-à-jour : 2020/09/07 10:11

LCF403 - Aide et Documentation

Contenu du Module

  • LCF403 - Aide et Documentation
    • Contenu du Module
    • L'Aide des Commandes Externes au Shell
    • L'Aide des Commandes Internes du Shell
    • La Commande man
    • La Commande apropos
    • Les Commandes mandb et whatis
    • La Commande info

L'Aide des Commandes Externes au Shell

Les commandes externes au shell sont des binaires exécutables ou des scripts, généralement situés dans /bin, /sbin, /usr/bin ou /usr/sbin :

[root@centos8 ~]# type ifconfig
ifconfig is /usr/sbin/ifconfig

L'aide d'une commande externe au shell peut être visualisée dans la plupart des cas en passant le paramètre - -help en argument à la commande en question :

[root@centos8 ~]# ifconfig --help
Usage:
  ifconfig [-a] [-v] [-s] <interface> [[<AF>] <address>]
  [add <address>[/<prefixlen>]]
  [del <address>[/<prefixlen>]]
  [[-]broadcast [<address>]]  [[-]pointopoint [<address>]]
  [netmask <address>]  [dstaddr <address>]  [tunnel <address>]
  [outfill <NN>] [keepalive <NN>]
  [hw <HW> <address>]  [mtu <NN>]
  [[-]trailers]  [[-]arp]  [[-]allmulti]
  [multicast]  [[-]promisc]
  [mem_start <NN>]  [io_addr <NN>]  [irq <NN>]  [media <type>]
  [txqueuelen <NN>]
  [[-]dynamic]
  [up|down] ...

  <HW>=Hardware Type.
  List of possible hardware types:
    loop (Local Loopback) slip (Serial Line IP) cslip (VJ Serial Line IP) 
    slip6 (6-bit Serial Line IP) cslip6 (VJ 6-bit Serial Line IP) adaptive (Adaptive Serial Line IP) 
    ash (Ash) ether (Ethernet) ax25 (AMPR AX.25) 
    netrom (AMPR NET/ROM) rose (AMPR ROSE) tunnel (IPIP Tunnel) 
    ppp (Point-to-Point Protocol) hdlc ((Cisco)-HDLC) lapb (LAPB) 
    arcnet (ARCnet) dlci (Frame Relay DLCI) frad (Frame Relay Access Device) 
    sit (IPv6-in-IPv4) fddi (Fiber Distributed Data Interface) hippi (HIPPI) 
    irda (IrLAP) x25 (generic X.25) infiniband (InfiniBand) 
    eui64 (Generic EUI-64) 
  <AF>=Address family. Default: inet
  List of possible address families:
    unix (UNIX Domain) inet (DARPA Internet) inet6 (IPv6) 
    ax25 (AMPR AX.25) netrom (AMPR NET/ROM) rose (AMPR ROSE) 
    ipx (Novell IPX) ddp (Appletalk DDP) ash (Ash) 
    x25 (CCITT X.25) 

L'Aide des Commandes Internes du Shell

Les commandes internes au shell sont des commandes telles type, cd ou umask. Pour vérifier le type de commande, il faut utiliser la commande type :

[root@centos8 ~]# type type
type is a shell builtin

Le shell possède la commande help. Utilisée seule, cette commande fournit la liste des commandes internes :

[root@centos8 ~]# help
GNU bash, version 4.4.19(1)-release (x86_64-redhat-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 history -anrw [filename] or history -ps arg [arg...]
 (( expression ))                                                                                 if COMMANDS; then COMMANDS; [ elif COMMANDS; then COMMANDS; ]... [ else COMMANDS; ] fi
 . filename [arguments]                                                                           jobs [-lnprs] [jobspec ...] or jobs -x command [args]
 :                                                                                                kill [-s sigspec | -n signum | -sigspec] pid | jobspec ... or kill -l [sigspec]
 [ arg... ]                                                                                       let arg [arg ...]
 [[ expression ]]                                                                                 local [option] name[=value] ...
 alias [-p] [name[=value] ... ]                                                                   logout [n]
 bg [job_spec ...]                                                                                mapfile [-d delim] [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] >
 bind [-lpsvPSVX] [-m keymap] [-f filename] [-q name] [-u name] [-r keyseq] [-x keyseq:shell-co>  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]...) COMMANDS ;;]... esac                                       read [-ers] [-a array] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] >
 cd [-L|[-P [-e]] [-@]] [dir]                                                                     readarray [-n count] [-O origin] [-s count] [-t] [-u fd] [-C callback] [-c quantum] [array]
 command [-pVv] command [arg ...]                                                                 readonly [-aAf] [name[=value] ...] or readonly -p
 compgen [-abcdefgjksuv] [-o option] [-A action] [-G globpat] [-W wordlist]  [-F function] [-C >  return [n]
 complete [-abcdefgjksuv] [-pr] [-DE] [-o option] [-A action] [-G globpat] [-W wordlist]  [-F f>  select NAME [in WORDS ... ;] do COMMANDS; done
 compopt [-o|+o option] [-DE] [name ...]                                                          set [-abefhkmnptuvxBCHP] [-o option-name] [--] [arg ...]
 continue [n]                                                                                     shift [n]
 coproc [NAME] command [redirections]                                                             shopt [-pqsu] [-o] [optname ...]
 declare [-aAfFgilnrtux] [-p] [name[=value] ...]                                                  source filename [arguments]
 dirs [-clpv] [+N] [-N]                                                                           suspend [-f]
 disown [-h] [-ar] [jobspec ... | pid ...]                                                        test [expr]
 echo [-neE] [arg ...]                                                                            time [-p] pipeline
 enable [-a] [-dnps] [-f filename] [name ...]                                                     times
 eval [arg ...]                                                                                   trap [-lp] [[arg] signal_spec ...]
 exec [-cl] [-a name] [command [arguments ...]] [redirection ...]                                 true
 exit [n]                                                                                         type [-afptP] name [name ...]
 export [-fn] [name[=value] ...] or export -p                                                     typeset [-aAfFgilnrtux] [-p] name[=value] ...
 false                                                                                            ulimit [-SHabcdefiklmnpqrstuvxPT] [limit]
 fc [-e ename] [-lnr] [first] [last] or fc -s [pat=rep] [command]                                 umask [-p] [-S] [mode]
 fg [job_spec]                                                                                    unalias [-a] name [name ...]
 for NAME [in WORDS ... ] ; do COMMANDS; done                                                     unset [-f] [-v] [-n] [name ...]
 for (( exp1; exp2; exp3 )); do COMMANDS; done                                                    until COMMANDS; do COMMANDS; done
 function name { COMMANDS ; } or name () { COMMANDS ; }                                           variables - Names and meanings of some shell variables
 getopts optstring name [arg]                                                                     wait [-n] [id ...]
 hash [-lr] [-p pathname] [-dt] [name ...]                                                        while COMMANDS; do COMMANDS; done
 help [-dms] [pattern ...]                                                                        { COMMANDS ; }

L'aide concernant une commande spécifique peut être obtenu en passant la commande concernée en argument à la commande help :

[root@centos8 ~]# help type
type: type [-afptP] name [name ...]
    Display information about command type.
    
    For each NAME, indicate how it would be interpreted if used as a
    command name.
    
    Options:
      -a        display all locations containing an executable named NAME;
                includes aliases, builtins, and functions, if and only if
                the `-p' option is not also used
      -f        suppress shell function lookup
      -P        force a PATH search for each NAME, even if it is an alias,
                builtin, or function, and returns the name of the disk file
                that would be executed
      -p        returns either the name of the disk file that would be executed,
                or nothing if `type -t NAME' would not return `file'
      -t        output a single word which is one of `alias', `keyword',
                `function', `builtin', `file' or `', if NAME is an alias,
                shell reserved word, shell function, shell builtin, disk file,
                or not found, respectively
    
    Arguments:
      NAME      Command name to be interpreted.
    
    Exit Status:
    Returns success if all of the NAMEs are found; fails if any are not found.

La Commande man

La commande man donne accès au manuel de la commande passée en argument. Par exemple man passwd :

[root@centos8 ~]# man passwd
BASH_BUILTINS(1)                                                                   General Commands Manual                                                                   BASH_BUILTINS(1)

NAME
       bash,  :,  ., [, alias, bg, bind, break, builtin, caller, cd, command, compgen, complete, compopt, continue, declare, dirs, disown, echo, enable, eval, exec, exit, export, false, fc,
       fg, getopts, hash, help, history, jobs, kill, let, local, logout, mapfile, popd, printf, pushd, pwd, read, readonly, return, set, shift, shopt, source, suspend,  test,  times,  trap,
       true, type, typeset, ulimit, umask, unalias, unset, wait - bash built-in commands, see bash(1)

BASH BUILTIN COMMANDS
       Unless otherwise noted, each builtin command documented in this section as accepting options preceded by - accepts -- to signify the end of the options.  The :, true, false, and test
       builtins do not accept options and do not treat -- specially.  The exit, logout, return, break, continue, let, and shift builtins accept and process arguments beginning with -  with‐
       out  requiring  --.  Other builtins that accept arguments but are not specified as accepting options interpret arguments beginning with - as invalid options and require -- to prevent
       this interpretation.
       : [arguments]
              No effect; the command does nothing beyond expanding arguments and performing any specified redirections.  The return status is zero.

        .  filename [arguments]
       source filename [arguments]
              Read and execute commands from filename in the current shell environment and return the exit status of the last command executed from filename.  If filename does not contain a
              slash,  filenames  in PATH are used to find the directory containing filename.  The file searched for in PATH need not be executable.  When bash is not in posix mode, the cur‐
              rent directory is searched if no file is found in PATH.  If the sourcepath option to the shopt builtin command is turned off, the PATH is not searched.  If any  arguments  are
              supplied,  they  become  the positional parameters when filename is executed.  Otherwise the positional parameters are unchanged.  If the -T option is enabled, source inherits
              any trap on DEBUG; if it is not, any DEBUG trap string is saved and restored around the call to source, and source unsets the DEBUG trap while it executes.  If -T is not  set,
              and  the sourced file changes the DEBUG trap, the new value is retained when source completes.  The return status is the status of the last command exited within the script (0
              if no commands are executed), and false if filename is not found or cannot be read.

       alias [-p] [name[=value] ...]
              Alias with no arguments or with the -p option prints the list of aliases in the form alias name=value on standard output.  When arguments are supplied, an alias is defined for
              each name whose value is given.  A trailing space in value causes the next word to be checked for alias substitution when the alias is expanded.  For each name in the argument
              list for which no value is supplied, the name and value of the alias is printed.  Alias returns true unless a name is given for which no alias has been defined.

       bg [jobspec ...]
              Resume each suspended job jobspec in the background, as if it had been started with &.  If jobspec is not present, the shell's notion of the current job is used.   bg  jobspec
              returns 0 unless run when job control is disabled or, when run with job control enabled, any specified jobspec was not found or was started without job control.

       bind [-m keymap] [-lpsvPSVX]
       bind [-m keymap] [-q function] [-u function] [-r keyseq]
       bind [-m keymap] -f filename
       bind [-m keymap] -x keyseq:shell-command
       bind [-m keymap] keyseq:function-name
       bind [-m keymap] keyseq:readline-command
              Display  current readline key and function bindings, bind a key sequence to a readline function or macro, or set a readline variable.  Each non-option argument is a command as
              it would appear in .inputrc, but each binding or command must be passed as a separate argument; e.g., '"\C-x\C-r": re-read-init-file'.  Options, if supplied, have the  follow‐
 Manual page help(1) line 1 (press h for help or q to quit)

Une page de manuel peut contenir plusieurs sections :

Section Contenu
NOM Nom et rôle de la commande
SYNOPSIS Syntaxe de la commande, paramètres et arguments
DESCRIPTION Mode d'emploi et les arguments principaux
OPTIONS Descriptions détaillées de chaque paramètre
EXEMPLES / EXAMPLES Exemples d'utilisation de la commande
ENVIRONNEMENT / ENVIRONMENT VARIABLES Fonctionnement selon l'environnement du shell
CONFORMITÉ / STANDARDS / CONFORMING TO Éventuelles normes auxquelles la commande se conforme
BOGUES / BUGS/TO DO Éventuelles bogues connues
DIAGNOSTICS/RETOUR / EXIT STATUS/RETURN VALUE Codes d'erreur et leur signification
VOIR AUSSI / SEE ALSO Commandes liées à celle du manuel actuel

La navigation dans la page de manuel se fait grâce à l'utilisation de certaines touches :

Touche Fonction
Espace Faire défiler une page complète
Entrée Faire défiler la page ligne par ligne
Faire défiler la page une ligne vers le haut
Faire défiler la page une ligne vers le bas
PageHaut Faire défiler une demi-page vers le haut
PageBas Faire défiler une demi-page vers le bas
Début Se positionner au début du manuel
Fin Se positionner à la fin du manuel
/ Rechercher la chaîne qui suit la touche /. La touche n recherche l'occurrence suivante. La touche N recherche l'occurrence précédente
Q Quitter le manuel

Un manuel complet est fait de plusieurs sections :

Section Contenu
1 Instructions exécutables ou commandes shell
2 Appels système
3 Appels des bibliothèques
4 Fichiers spéciaux
5 Format des fichiers
6 Jeux, économiseurs d'écrans, gadgets
7 Divers et commandes non standard
8 Commandes d'administration du système Linux
9 Sous-programmes du noyau

Les différentes sections disponibles sont visibles grâce à l'utilisation de la commande whereis :

[root@centos8 ~]# whereis passwd
passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man1/passwd.1.gz /usr/share/man/man5/passwd.5.gz

Pour visualiser une section spécifique, il convient de préciser son numéro :

[root@centos8 ~]# man 5 passwd
PASSWD(5)                                                                         Linux Programmer's Manual                                                                         PASSWD(5)

NAME
       passwd - password file

DESCRIPTION
       The /etc/passwd file is a text file that describes user login accounts for the system.  It should have read permission allowed for all users (many utilities, like ls(1) use it to map
       user IDs to usernames), but write access only for the superuser.

       In the good old days there was no great problem with this general read permission.  Everybody could read the encrypted passwords, but the hardware was too slow to crack a well-chosen
       password, and moreover the basic assumption used to be that of a friendly user-community.  These days many people run some version of the shadow password suite, where /etc/passwd has
       an 'x' character in the password field, and the encrypted passwords are in /etc/shadow, which is readable by the superuser only.

       If the encrypted password, whether in /etc/passwd or in /etc/shadow, is an empty string, login is allowed without even asking for a password.  Note that  this  functionality  may  be
       intentionally disabled in applications, or configurable (for example using the "nullok" or "nonull" arguments to pam_unix.so).

       If the encrypted password in /etc/passwd is "*NP*" (without the quotes), the shadow record should be obtained from an NIS+ server.

       Regardless  of whether shadow passwords are used, many system administrators use an asterisk (*) in the encrypted password field to make sure that this user can not authenticate him-
       or herself using a password.  (But see NOTES below.)

       If you create a new login, first put an asterisk (*) in the password field, then use passwd(1) to set it.

       Each line of the file describes a single user, and contains seven colon-separated fields:

           name:password:UID:GID:GECOS:directory:shell

       The field are as follows:

       name        This is the user's login name.  It should not contain capital letters.

       password    This is either the encrypted user password, an asterisk (*), or the letter 'x'.  (See pwconv(8) for an explanation of 'x'.)

       UID         The privileged root login account (superuser) has the user ID 0.

       GID         This is the numeric primary group ID for this user.  (Additional groups for the user are defined in the system group file; see group(5)).

       GECOS       This field (sometimes called the "comment field") is optional and used only for informational purposes.  Usually, it contains the full username.  Some programs (for exam‐
                   ple, finger(1)) display information from this field.

                   GECOS  stands for "General Electric Comprehensive Operating System", which was renamed to GCOS when GE's large systems division was sold to Honeywell.  Dennis Ritchie has
                   reported: "Sometimes we sent printer output or batch jobs to the GCOS machine.  The gcos field in the password file was a place to stash the information for  the  $IDENT‐
 Manual page passwd(5) line 1 (press h for help or q to quit)

Les Commandes mandb et whatis

Chaque page de manuel contient une brève description. Ces descriptions ainsi que le nom du manuel sont stockés dans la base de données whatis.

Cette base de données peut être maintenue manuellement par root en invoquant l'exécutable /usr/bin/mandb.

L'utilisation de mandb est très simple :

[root@centos8 ~]# mandb
Processing manual pages under /usr/share/man/overrides...
Updating index cache for path `/usr/share/man/overrides/man3'. Wait...done.
Checking for stray cats under /usr/share/man/overrides...
Checking for stray cats under /var/cache/man/overrides...
...
Processing manual pages under /usr/share/man/pt...
Purging old database entries in /usr/local/share/man...
Processing manual pages under /usr/local/share/man...
0 man subdirectories contained newer manual pages.
0 manual pages were added.
0 stray cats were added.
17 old database entries were purged.

La commande whatis peut maintenant être utilisée pour identifier les sections des manuels disponibles pour une commande donnée :

[root@centos8 ~]# whatis passwd
openssl-passwd (1ssl) - compute password hashes
passwd (1)           - update user's authentication tokens
passwd (5)           - password file

La Commande apropos

La commande apropos cherche dans la base de données whatis la chaine de caractères passée en argument à la commande. Sans option, la sortie obtenue est identique à la commande man -k :

[root@centos8 ~]# apropos passwd
chgpasswd (8)        - update group passwords in batch mode
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
openssl-passwd (1ssl) - compute password hashes
pam_localuser (8)    - require users to be listed in /etc/passwd
passwd (1)           - update user's authentication tokens
passwd (5)           - password file
passwd2des (3)       - RFS password encryption
pwhistory_helper (8) - Helper binary that transfers password hashes from passwd or shadow to opasswd
smbpasswd (5)        - The Samba encrypted password file
sslpasswd (1ssl)     - compute password hashes

Le résultat est une liste de commandes suivies par une description brève de celles-ci.

Important - Notez que les numéros entre parenthèses indiquent les sections disponibles.

La Commande info

En plus du système des manuels, des informations concernant des exécutables peuvent être trouvées dans le système info. De l'information détaillée, des exemples et des tutoriels peuvent être absents du système des manuels. Pour cette raison le système info a été créé.

Dans le système info, de multiples pages d'informations concernant un exécutable, appelées nœuds, sont regroupées. La navigation entre nœuds est simple et utilise un système de liens hypertexte.

Afin de faciliter la navigation chaque page contient une entête qui inclut de l'information sur le nœud courant, le nœud parent, le nœud précédent et le nœud suivant. Pour naviguer entre les nœuds il convient d'utiliser les touches suivantes :

Touch Fonction
n Nœud suivant.
p Nœud précédent.
u Nœud parent.
Espace Défiler une page vers le bas.
Suppr Défiler une page vers le haut.
b Retour au début du nœud courant.
Tab ⇆ Sélectionner le lien hypertexte suivant.
m <lien> Aller au sous-nœud spécifié. En appuyant sur [Tab], on obtient la liste de tous les sous-nœuds.
↵ Entrée Suivre le lien hypertexte courant. Un lien hypertexte commence avec un astérisque et se termine avec le caractère :.
q Quitter le système info.

Pour accéder au premier nœud, utilisez la commande suivante :

[root@centos8 ~]# info
...
File: dir,      Node: Top,      This is the top of the INFO tree.

This is the Info main menu (aka directory node).
A few useful Info commands:

  'q' quits;
  'H' lists all Info commands;
  'h' starts the Info tutorial;
  'mTexinfo RET' visits the Texinfo manual, etc.

* Menu:

Archiving
* Cpio: (cpio).                 Copy-in-copy-out archiver to tape or disk.
* Tar: (tar).                   Making tape (or disk) archives.

Basics
* Bash: (bash).                 The GNU Bourne-Again SHell.
* Common options: (coreutils)Common options.
* Coreutils: (coreutils).       Core GNU (file, text, shell) utilities.
* Date input formats: (coreutils)Date input formats.
* Ed: (ed).                     The GNU line editor
* File permissions: (coreutils)File permissions.
                                Access modes.
* Finding files: (find).        Operating on files matching certain criteria.
* time: (time).                 GNU time Utility

Compression
-----Info: (dir)Top, 307 lines --Top------------------------------------------------------------------------------
Welcome to Info version 6.5.  Type H for help, h for tutorial.

<html>

Copyright © 2020 Hugh Norris.<br><br>

</html>


Menu