| |
 |
|
 |
 |
|
 |
Linux下如何提高查询效率?
|
|
|
适用情况:知道查询内容,需要了解更为详细的情况
方法一:Linux下命令一般都提供“--help”这个选项,你可以利用该选项查看该命令如何使用。
例如:ps命令
|
[armlinux@lqm armlinux]$ ps --help ********* simple selection ********* ********* selection by list ********* -A all processes -C by command name -N negate selection -G by real group ID (supports names) -a all w/ tty except session leaders -U by real user ID (supports names) -d all except session leaders -g by session leader OR by group name -e all processes -p by process ID T all processes on this terminal -s processes in the sessions given a all w/ tty, including other users -t by tty g all, even group -u by effective user ID (supports names) r only running processes U processes for specified users x processes w/o controlling ttys t by tty *********** output format ********** *********** long options *********** -o,o user-defined -f full --Group --User --pid --cols -j,j job control s signal --group --user --sid --rows -O,O preloaded -o v virtual memory --cumulative --format --deselect -l,l long u user-oriented --sort --tty --forest --version X registers --heading --no-heading ********* misc options ********* -V,V show version L list format codes f ASCII art forest -m,m show threads S children in sum -y change -l format -n,N set namelist file c true command name n numeric WCHAN,UID -w,w wide output e show environment -H process heirarchy
|
这种方法的优点是比较快速,缺点是帮助内容比较少。在比较熟悉该命令,但是不知道具体选项时,可以使用。
方法二:使用man文档。
这时也有技巧,因为man文档分为不同部分,有时可能找不到或找不全。所以,你可以首选使用whereis查看所在man的分册n,然后使用man n <查找内容>来查看。这种方法适合于系统学习某个部分。
例如:查找exit
|
[armlinux@lqm armlinux]$ whereis exit exit: /usr/share/man/man1/exit.1.gz /usr/share/man/man2/exit.2.gz /usr/share/man/man3/exit.3.gz /usr/share/man/mann/exit.n.gz
|
你可以分别使用man 1 exit, man 2 exit, man 3 exit, man n exit来查看各个分册的内容。
如果了解man分册的内容,则更容易选择你要查看的内容。
|
[armlinux@lqm armlinux]$ whereis man man: /usr/bin/man /etc/man.config /usr/local/man /usr/share/man /usr/share/man/man1/man.1.gz /usr/share/man/man7/man.7.gz [armlinux@lqm armlinux]$ man 7 man
The manual sections are traditionally defined as follows:
1 Commands Those commands that can be executed by the user from within a shell.
2 System calls Those functions which must be performed by the kernel.
3 Library calls Most of the libc functions, such as qsort(3))
4 Special files Files found in /dev)
5 File formats and conventions The format for /etc/passwd and other human-readable files.
6 Games
7 Macro packages and conventions A description of the standard file system layout, net- work protocols, ASCII and other character codes, this man page, and other things.
8 System management commands Commands like mount(8), many of which only root can execute.
9 Kernel routines This is an obsolete manual section. Once it was thought a good idea to document the Linux kernel here, but in fact very little has been documented, and the documentation that exists is outdated already. There are better sources of information for kernel develop- ers.
|
由此比较清楚,如果要查询exit作为库函数调用时的接口,可以用man 3 exit来查看,可以方便的找到头文件。
|
SYNOPSIS #include <stdlib.h>
void exit(int status);
|
另外,所有的系统调用都在man 2分册中。这样查询时可以更有目的,提高效率。
注:
Linux下的帮助文档非常丰富,英文描述很简洁,比较容易读,可以利用这一资源解决平时所遇到的大部分问题。
|
|
|
发表于: 2007-05-14,修改于: 2007-05-15 12:29,已浏览1000次,有评论0条
推荐
投诉
|
|
 |
|
 |
|  |
|
 |
|