linux命令中man是一个很重要的命令,man的全称是manual,即手册。 man的基本用法是 man + 命令。 例如,想知道pwd的用法,只要键入man pwd即可。
其效果如下:
root@itnetcn:~# man pwd
PWD(1) User Commands PWD(1) //注意括号中的数字 NAME //关于命令的名次和说明 pwd - print name of current/working directory SYNOPSIS //命令的几本语法 pwd [OPTION] DESCRIPTION //详细描述语法参数的使用方法 Print the full filename of the current working directory. --help display this help and exit --version output version information and exit NOTE: your shell may have its own version of pwd, which usually super- sedes the version described here. Please refer to your shell's docu- mentation for details about the options it supports. AUTHOR //作者信息 Written by Jim Meyering. REPORTING BUGS //作者的联系方式 Report bugs to <bug-coreutils@gnu.org>. COPYRIGHT //版权声明 Copyright (C) 2008 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO //详细文件可以从哪里查询到 getcwd(3) The full documentation for pwd is maintained as a Texinfo manual. If the info and pwd programs are properly installed at your site, the com- mand info pwd should give you access to the complete manual. GNU coreutils 6.9.92.4-f088d-dirtJanuary 2008 PWD(1) ~ Manual page pwd(1) line 1/48 (END) 上下键表示上下翻,空格键翻页,q键退出。
注意PWD(1),这个括号里面1可是大有文章的,下面的表格解释了各种数字代表的含义。 仔细看,man其实分为很多个区域的,有一个相对固定的格式,每个区域固定显示什么内容,就像老师说写论文有一个固定的格式是一个道理。
以下是每个区域的含义:
代号 内容说明
NAME 简短的指令、资料名称说明 SYNOPSIS 简短的指令下达语法(syntax)简介 DESCRIPTION 较为完整的说明,这部分最好仔细看看! OPTIONS 针对 SYNOPSIS 部分中,有列举的所有可用的参数说明 COMMANDS 当这个程式(软体)在执行的时候,可以在此程式(软体)中下达的指令 FILES 这个程式或资料所使用或参考或连结到的某些档案 SEE ALSO 可以参考的,跟这个指令或资料有相关的其他说明! EXAMPLE 一些可以参考的范例 BUGS 是否有相关的臭虫! 通常在查看man page的时候都需要搜索一些特定的字符串或参数,或者使用快捷键快速跳转到主要查看的区域,这时就要使用到常用的快捷键了,有些用快是通用的,例如/string表示搜索string字符串等,这些用法可以记住。
man可以使用的一些快捷键。
按键 进行工作
空白键 向下翻一页 [Page Down] 向下翻一页 [Page Up] 向上翻一页 [Home] 去到第一页 [End] 去到最后一页 向上键 向上滚一行 向下键 向下滚一行 /string 向『下』搜寻 string 这个字串,如果要搜寻 www.itnetcn.com 的话,就输入 /www.itnetcn.com ?string 向『上』搜寻 string 这个字串,如果要搜寻 www.itnetcn.com 的话,就输入 /www.itnetcn.com n, N 利用 / 或 ? 来搜寻字串时,可以用 n 来继续下一个搜寻 (不论是 / 或 ?) ,可以利用 N 来进行『反向』搜寻。举例来说,我以 /www.itnetcn.com 搜寻 www.itnetcn.com 字串, 那麼可以 n 继续往下查询,用 N 往上查询。若以 ?www.itnetcn.com 向上查询 www.itnetcn.com 字串, 那我可以用 n 继续『向上』查询,用 N 反向查询。 q 结束这次的 man page
man有两个比较重要的参数
例子,man命令查看pwd用法。
root@itnetcn:~# man -f pwd
pwd (1) - print name of current/working directory root@itnetcn:~# man -f man man (1) - an interface to the on-line reference manuals man (7) - macros to format man pages root@itnetcn:~# man -k man HEAD (1p) - Simple command line user agent accessdb (8) - dumps the content of a man-db database in a human readable format. apropos (1) - search the manual page names and descriptions apt-cache (8) - APT package handling utility - cache manipulator apt-cdrom (8) - APT CDROM management utility apt-get (8) - APT package handling utility - command-line interface apt-key (8) - APT key management utility arp (8) - manipulate the system ARP cache bash-builtins (7) - bash built-in commands, see bash(1) blkid (8) - command-line utility to locate/print block device attributes blockdev (8) - call block device ioctls from the command line builtins (7) - bash built-in commands, see bash(1) c++filt (1) - Demangle C++ and Java symbols. catman (8) - create or update the pre-formatted manual pages cfdisk (8) - Curses/slang based disk partition table manipulator for Linux chroot (8) - run command or interactive shell with special root directory chrt (1) - manipulate real-time attributes of a process compress-dummy (1) - manual page for compress-dummy - sharutils 4.6.3 corelist (1) - a commandline frontend to Module::CoreList cpan (1) - easily interact with CPAN from the command line cron (8) - daemon to execute scheduled commands (Vixie Cron) db4.6_printlog (1) - Dumps Berkeley DB log files in a human-readable format DBI::Profile (3pm) - Performance profiling and benchmarking for the DBI DBI::ProfileData (3pm) - manipulate DBI::ProfileDumper data dumps dbiprof (1p) - command-line client for DBI::ProfileData dbmmanage (1) - Manage user authentication files in DBM format defoma (1) - Debian Font Manager, a framework for automatic font configuration. defoma-app (1) - configure a specific application about fonts registered in Debian Font Manager. defoma-font (1) - register/unregister font(s) to Debian Font Manager defoma-id (1) - Manage id-cache of Debian Font Manager defoma-user (1) - Debian Font Manager for users dhparam (1ssl) - DH parameter manipulation and generation dotlockfile (1) - Utility to manage lockfiles dpkg (1) - package manager for Debian dpkg-deb (1) - Debian package archive (.deb) manipulation tool dsaparam (1ssl) - DSA parameter manipulation and generation dselect (1) - Debian package management frontend ecparam (1ssl) - EC parameter manipulation and generation fdisk (8) - Partition table manipulator for Linux find2perl (1) - translate find command lines to Perl code flock (1) - Manage locks from shell scripts GET (1p) - Simple command line user agent getopt (1) - parse command options (enhanced) groff_man (7) - groff `man' macros to support generation of man pages groffer (1) - display groff files and man pages on X and tty grog (1) - guess options for groff command hman (1) - browse the on-line manual pages hosts.equiv (5) - list of hosts and users that are granted "trusted"r command access to your system htdbm (1) - Manipulate DBM password databases htdigest (1) - manage user files for digest authentication htpasswd (1) - Manage user files for basic authentication initscript (5) - script that executes inittab commands. intro (1) - Introduction to user commands intro (8) - Introduction to administration and privileged commands ip (8) - show / manipulate routing, devices, policy routing and tunnels lexgrog (1) - parse header information in man pages logger (1) - a shell command interface to the syslog(3) system log module logsave (8) - save the output of a command in a logfile lprng_certs (1) - lprng SSL certificate management lprng_index_certs (1) - lprng SSL certificate management lwp-request (1p) - Simple command line user agent LWP::ConnCache (3pm) - Connection cache manager lwres_buffer (3) - lightweight resolver buffer management lwres_buffer_add (3) - lightweight resolver buffer management lwres_buffer_back (3) - lightweight resolver buffer management lwres_buffer_clear (3) - lightweight resolver buffer management lwres_buffer_first (3) - lightweight resolver buffer management lwres_buffer_forward (3) - lightweight resolver buffer management lwres_buffer_getmem (3) - lightweight resolver buffer management lwres_buffer_getuint16 (3) - lightweight resolver buffer management lwres_buffer_getuint32 (3) - lightweight resolver buffer management lwres_buffer_getuint8 (3) - lightweight resolver buffer management lwres_buffer_init (3) - lightweight resolver buffer management lwres_buffer_invalidate (3) - lightweight resolver buffer management lwres_buffer_putmem (3) - lightweight resolver buffer management lwres_buffer_putuint16 (3) - lightweight resolver buffer management lwres_buffer_putuint32 (3) - lightweight resolver buffer management lwres_buffer_putuint8 (3) - lightweight resolver buffer management lwres_buffer_subtract (3) - lightweight resolver buffer management lwres_context (3) - lightweight resolver context management lwres_context_allocmem (3) - lightweight resolver context management lwres_context_create (3) - lightweight resolver context management lwres_context_destroy (3) - lightweight resolver context management lwres_context_freemem (3) - lightweight resolver context management lwres_context_initserial (3) - lightweight resolver context management lwres_context_nextserial (3) - lightweight resolver context management lwres_context_sendrecv (3) - lightweight resolver context management magic (5) - file command's magic pattern file Mail::Field (3pm) - Base class for manipulation of mail header fields Mail::Header (3pm) - manipulate MIME headers Mail::Internet (3pm) - manipulate email messages man (1) - an interface to the on-line reference manuals man (7) - macros to format man pages man-pages (7) - conventions for writing Linux man pages man2html (1) - format a manual page in html manconv (1) - convert manual page from one encoding to another mandb (8) - create or update the manual page index caches manpath (1) - determine search path for manual pages manpath (5) - format of the /etc/manpath.config file mii-tool (8) - view, manipulate media-independent interface status MIME::Parser::Filer (3pm) - manage file-output of the parser missing (7) - missing manual pages mkmanifest (1) - makes list of file names and their DOS 8+3 equivalent moduli (5) - Diffie Hellman moduli nohup (1) - run a command immune to hangups, with output to a non-tty nroff (1) - emulate nroff command with groff odbcinst (1) - command line tool for batch ODBC configuration omshell (1) - OMAPI Command Shell openssl (1ssl) - OpenSSL command line tool pam_exec (8) - PAM module which calls an external command pod2man (1) - Convert POD data to formatted *roff input POST (1p) - Simple command line user agent prove (1) - - A command-line tool for running tests against Test::Harness qtool (8) - manipulate sendmail queues rarp (8) - manipulate the system RARP table route (8) - show / manipulate the IP routing table runcon (1) - run command with specified security context s_time (1ssl) - SSL/TLS performance timing program screen (1) - screen manager with VT100/ANSI terminal emulation sfdisk (8) - Partition table manipulator for Linux sg (1) - execute command as different group ID snmpbulkwalk (1) - retrieve a subtree of management values using SNMP GETBULK requests snmpcmd (1) - options and behaviour common to most of the Net-SNMP command-line tools snmpinform (1) - sends an SNMP notification to a manager snmpstatus (1) - retrieves a fixed set of management information from a network entity snmptrap (1) - sends an SNMP notification to a manager snmpwalk (1) - retrieve a subtree of management values using SNMP GETNEXT requests speed (1ssl) - test library performance ssh-argv0 (1) - replaces the old ssh command-name as hostname handling ssh-keygen (1) - authentication key generation, management and conversion sudo (8) - execute a command as another user sudoedit (8) - execute a command as another user tc (8) - show / manipulate traffic control settings tcsh (1) - C shell with file name completion and command line editing tempfile (1) - create a temporary file in a safe manner Time::Zone (3pm) - - miscellaneous timezone manipulations routines undocumented (7) - No manpage for this program, utility or function. update-alternatives (8) - maintain symbolic links determining default commands update-modules (8) - obsolete command whatis (1) - display manual page descriptions whereis (1) - locate the binary, source, and manual page files for a command which (1) - locate a command xargs (1) - build and execute command lines from standard input xqmstats (8) - Display XFS quota manager statistics from /proc root@itnetcn:~#
其实linux上这两个参数是有替代命令的,那就是whatis和apropos
用法:
root@itnetcn:~# man -f man
man (1) - an interface to the on-line reference manuals man (7) - macros to format man pages root@itnetcn:~# whatis man man (1) - an interface to the on-line reference manuals man (7) - macros to format man pages root@itnetcn:~# man -k pwd pwd (1) - print name of current/working directory pwdx (1) - report current working directory of a process unix_chkpwd (8) - Helper binary that verifies the password of the current user root@itnetcn:~# apropos pwd pwd (1) - print name of current/working directory pwdx (1) - report current working directory of a process unix_chkpwd (8) - Helper binary that verifies the password of the current user root@itnetcn:~# 有关linux上man的用法就这些吧,其他的暂时没有想到了。 (责任编辑:IT) |