GNU/Linux >> LINUX-Kenntnisse >  >> Linux

Linux whatis Command Tutorial für Anfänger (5 Beispiele)

Manpages sind eine der nützlichsten Ressourcen, wenn es darum geht, Befehlszeilenprogramme zu verstehen. Eine Manpage enthält jedoch viele Details über den Befehl. Es kann Zeiten geben, in denen Sie schnell wissen möchten – möglicherweise in einer kleinen Zeile oder so – was ein Befehlszeilentool tut. Nun, Sie werden froh sein zu hören, dass es einen Befehl gibt, der speziell für diesen Zweck entwickelt wurde.

In diesem Tutorial werden wir die Grundlagen von whatis besprechen Befehl anhand einiger leicht verständlicher Beispiele. Aber bevor wir das tun, ist es erwähnenswert, dass alle Beispiele hier auf einem Ubuntu 18.04 LTS- und Debian 10-Rechner getestet wurden.

Der Linux-whatis-Befehl

Mit dem Befehl whatis in Linux können Sie einzeilige Handbuchseitenbeschreibungen anzeigen. Es folgt die Syntax:

whatis  [-dlv?V]  [-r|-w]  [-s  list]  [-m  system[,...]] [-M path] [-L
       locale] [-C file] name ...

Und so erklärt es die Manpage des Tools:

       Each manual page has a short description available within  it.   whatis
       searches  the  manual  page names and displays the manual page descrip?
       tions of any name matched.

       name may contain wildcards (-w) or be a regular expression (-r).  Using
       these  options, it may be necessary to quote the name or escape (\) the
       special characters to stop the shell from interpreting them.

Im Folgenden finden Sie einige Beispiele im Q&A-Stil, die Ihnen eine bessere Vorstellung davon vermitteln sollen, wie der Befehl whatis funktioniert.

Q1. Wie verwende ich den whatis-Befehl?

Die grundlegende Verwendung ist ziemlich einfach. Übergeben Sie einfach einen Werkzeugnamen als Eingabe, und whatis sucht danach und zeigt eine einzeilige Beschreibung dafür an.

Hier ist ein Beispiel:

whatis ls

Die folgende Ausgabe wurde durch den oben genannten Befehl erzeugt:

ls (1)               - list directory contents

Q2. Wie erhalte ich Informationen für mehr als einen Befehl?

Dies ist auch ziemlich einfach - übergeben Sie einfach die Werkzeugnamen als Eingabe an whatis. Nachfolgend ein Beispiel:

whatis ls cp rm mv

Und hier ist die Ausgabe dieses Befehls:

ls (1)               - list directory contents
cp (1)               - copy files and directories
rm (1)               - remove files or directories
mv (1)               - move (rename) files

Sie können also sehen, dass der whatis-Befehl problemlos mehrere Eingaben verarbeitet.

Q3. Können wir Wildcards mit whatis verwenden?

Ja, es ist möglich, Wildcards mit dem whatis-Befehl zu verwenden. Die Befehlszeilenoption -w aktiviert diese Funktion.

Hier ist ein Beispiel;

whatis -w 'who*'

Und das Folgende ist die Ausgabe:

who (1)              - show who is logged on
whoami (1)           - print effective userid

Q4. Wie kann whatis Debugging-Informationen erzeugen?

Die Option -d bewirkt, dass der whatis-Befehl Debugging-Informationen in der Ausgabe erzeugt. Natürlich ist diese Option hauptsächlich für Entwickler gedacht.

Hier ist ein Beispiel:

whatis -d ls

Und das Folgende ist die Ausgabe, die von diesem Befehl erzeugt wird:

From the config file /etc/manpath.config:

Mandatory mandir `/usr/man'.
Mandatory mandir `/usr/share/man'.
Mandatory mandir `/usr/local/share/man'.
Path `/bin' mapped to mandir `/usr/share/man'.
Path `/usr/bin' mapped to mandir `/usr/share/man'.
Path `/sbin' mapped to mandir `/usr/share/man'.
Path `/usr/sbin' mapped to mandir `/usr/share/man'.
Path `/usr/local/bin' mapped to mandir `/usr/local/man'.
Path `/usr/local/bin' mapped to mandir `/usr/local/share/man'.
Path `/usr/local/sbin' mapped to mandir `/usr/local/man'.
Path `/usr/local/sbin' mapped to mandir `/usr/local/share/man'.
Path `/usr/X11R6/bin' mapped to mandir `/usr/X11R6/man'.
Path `/usr/bin/X11' mapped to mandir `/usr/X11R6/man'.
Path `/usr/games' mapped to mandir `/usr/share/man'.
Path `/opt/bin' mapped to mandir `/opt/man'.
Path `/opt/sbin' mapped to mandir `/opt/man'.
Global mandir `/usr/man', catdir `/var/cache/man/fsstnd'.
Global mandir `/usr/share/man', catdir `/var/cache/man'.
Global mandir `/usr/local/man', catdir `/var/cache/man/oldlocal'.
Global mandir `/usr/local/share/man', catdir `/var/cache/man/local'.
Global mandir `/usr/X11R6/man', catdir `/var/cache/man/X11R6'.
Global mandir `/opt/man', catdir `/var/cache/man/opt'.
Added section `1'.
Added section `n'.
Added section `l'.
Added section `8'.
Added section `3'.
Added section `2'.
Added section `3posix'.
Added section `3pm'.
Added section `3perl'.
Added section `3am'.
Added section `5'.
Added section `4'.
Added section `9'.
Added section `6'.
Added section `7'.
`/usr/man'    `'    `1'
`/usr/share/man'    `'    `1'
`/usr/local/share/man'    `'    `1'
`/bin'    `/usr/share/man'    `0'
`/usr/bin'    `/usr/share/man'    `0'
`/sbin'    `/usr/share/man'    `0'
`/usr/sbin'    `/usr/share/man'    `0'
`/usr/local/bin'    `/usr/local/man'    `0'
`/usr/local/bin'    `/usr/local/share/man'    `0'
`/usr/local/sbin'    `/usr/local/man'    `0'
`/usr/local/sbin'    `/usr/local/share/man'    `0'
`/usr/X11R6/bin'    `/usr/X11R6/man'    `0'
`/usr/bin/X11'    `/usr/X11R6/man'    `0'
`/usr/games'    `/usr/share/man'    `0'
`/opt/bin'    `/opt/man'    `0'
`/opt/sbin'    `/opt/man'    `0'
`/usr/man'    `/var/cache/man/fsstnd'    `-1'
`/usr/share/man'    `/var/cache/man'    `-1'
`/usr/local/man'    `/var/cache/man/oldlocal'    `-1'
`/usr/local/share/man'    `/var/cache/man/local'    `-1'
`/usr/X11R6/man'    `/var/cache/man/X11R6'    `-1'
`/opt/man'    `/var/cache/man/opt'    `-1'
`1'    `'    `-5'
`n'    `'    `-5'
`l'    `'    `-5'
`8'    `'    `-5'
`3'    `'    `-5'
`2'    `'    `-5'
`3posix'    `'    `-5'
`3pm'    `'    `-5'
`3perl'    `'    `-5'
`3am'    `'    `-5'
`5'    `'    `-5'
`4'    `'    `-5'
`9'    `'    `-5'
`6'    `'    `-5'
`7'    `'    `-5'

path directory /usr/local/sbin is in the config file
adding /usr/local/man to manpath
adding /usr/local/share/man to manpath

path directory /usr/local/bin is in the config file
/usr/local/man is already in the manpath
/usr/local/share/man is already in the manpath

path directory /usr/sbin is in the config file
adding /usr/share/man to manpath

path directory /usr/bin is in the config file
/usr/share/man is already in the manpath

path directory /sbin is in the config file
/usr/share/man is already in the manpath

path directory /bin is in the config file
/usr/share/man is already in the manpath

path directory /usr/games is in the config file
/usr/share/man is already in the manpath

path directory /usr/local/games is not in the config file
but does have a ../man, man, ../share/man, or share/man subdirectory
/usr/local/man is already in the manpath

path directory /snap/bin is not in the config file
and doesn't have ../man, man, ../share/man, or share/man subdirectories

adding mandatory man directories

warning: /usr/man: No such file or directory
/usr/share/man is already in the manpath
/usr/local/share/man is already in the manpath
add_nls_manpaths(): processing /usr/local/man:/usr/local/share/man:/usr/share/man
checking for locale en_IN
adding /usr/local/man to manpathlist
adding /usr/local/share/man to manpathlist
adding /usr/share/man to manpathlist
adding /usr/local/man to manpathlist
adding /usr/local/share/man to manpathlist
adding /usr/share/man to manpathlist
Removing duplicate manpath entry /usr/local/share/man (1) -> /usr/local/man (0)
Removing duplicate manpath entry /usr/local/man (2) -> /usr/local/man (0)
Removing duplicate manpath entry /usr/local/share/man (2) -> /usr/local/man (0)
Removing duplicate manpath entry /usr/share/man (2) -> /usr/share/man (1)
final search path = /usr/local/man:/usr/share/man
path=/usr/local/man
warning: can't read the fallback whatis text database /usr/local/man/whatis
path=/usr/share/man
name:      ls
sec. ext:  1
section:   1
comp. ext: gz
id:        A
mtime:     1516268629.000000000
pointer:   -
filter:    -
whatis:    list directory contents

ls (1)               - list directory contents
hashtable_free: 1 entries, 1 (100%) unique

F5. Wie führt whatis seine Suchen durch?

Hier ist ein relevanter Auszug aus der Manpage:

       index databases are used during the search,  and  are  updated  by  the
       mandb  program.   Depending  on your installation, this may be run by a
       periodic cron job, or may need to be  run  manually  after  new  manual
       pages  have  been installed.  To produce an old style text whatis data?
       base from the relative index database, issue the command:

       whatis -M manpath -w '*' | sort > manpath/whatis

       where manpath is a manual page hierarchy such as /usr/man.
ist

Schlussfolgerung

Wenn Sie sich zu sehr mit den Linux-Befehlszeilentools beschäftigen oder Ihre tägliche Arbeit den Umgang mit Manpages umfasst, kann der Befehl whatis ein hilfreiches Tool für Sie sein. Wir haben hier bereits einige Whatis-Befehlszeilenoptionen besprochen. Weitere Informationen finden Sie auf der Manpage des Tools.


Linux
  1. Linux-CD-Befehls-Tutorial für Anfänger (8 Beispiele)

  2. Linux-Kommando-Tutorial für Anfänger (5 Beispiele)

  3. Linux-df-Befehls-Tutorial für Anfänger (8 Beispiele)

  4. Linux Date Command Tutorial für Anfänger (8 Beispiele)

  5. Linux-Hostname-Befehls-Tutorial für Anfänger (5 Beispiele)

Linux Who Command Tutorial für Anfänger (8 Beispiele)

Linux nl Command Tutorial für Anfänger (7 Beispiele)

Linux-nm-Befehls-Tutorial für Anfänger (10 Beispiele)

Linux OD Command Tutorial für Anfänger (6 Beispiele)

Linux w Command Tutorial für Anfänger (5 Beispiele)

Linux ss Command Tutorial für Anfänger (8 Beispiele)