本篇继续学习linux的常用命令,上接linux学习笔记(一).
学习视频为Linux达人养成计划 I,十分感谢tony老师的无私奉献。
二、常用命令
…
16、帮助命令man
man [命令名称]
获取指定命令的帮助,man是manual的缩写,手册
只能查询非shell内部命令
例
arururururu@ubuntu:~/Desktop/linuxCommand$ man ls
LS(1)//这里的1是指所在section User Commands LS(1)
NAME //作用
ls - list directory contents
SYNOPSIS //用法
ls [OPTION]... [FILE]...
DESCRIPTION //选项说明
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is speci‐
fied.
Mandatory arguments to long options are mandatory for short options
too.
-a, --all
do not ignore entries starting with .
-A, --almost-all
do not list implied . and ..
--author
...
Manual page ls(1) line 1 (press h for help or q to quit)
1、执行man man
时可以看到man分为不同section
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、查看某个命令有哪些section
//ls只有一个section
arururururu@ubuntu:~/Desktop/linuxCommand$ man -f ls
ls (1) - list directory contents
//passwd命令有多个section
arururururu@ubuntu:~/Desktop/linuxCommand$ man -f passwd
passwd (1ssl) - compute password hashes
passwd (1) - change user password
passwd (5) - the password file
//也可以用whatis [命令]查看
arururururu@ubuntu:~/Desktop/linuxCommand$ whatis ls
ls (1) - list directory contents
arururururu@ubuntu:~/Desktop/linuxCommand$ whatis passwd
passwd (1ssl) - compute password hashes
passwd (1) - change user password
passwd (5) - the password file
//还可以用whereis [命令]查看
//.1.gz、.1ssl.gz、.1ssl.gz后缀就显示了所拥有的section
// /etc/passwd为配置文件,可用man 5 passwd查看相关说明
arururururu@ubuntu:~/Desktop/linuxCommand$ whereis passwd
passwd: /usr/bin/passwd /etc/passwd /usr/bin/X11/passwd /usr/share/man/man1/passwd.1.gz /usr/share/man/man1/passwd.1ssl.gz /usr/share/man/man5/passwd.1ssl.gz
3、浏览指定section的帮助手册
arururururu@ubuntu:~/Desktop/linuxCommand$ man 5 passwd
PASSWD(5) File Formats and Conversions PASSWD(5)
NAME
passwd - the password file
DESCRIPTION
/etc/passwd contains one line for each user account, with seven fields
delimited by colons (“:”). These fields are:
· login name
· optional encrypted password
· numerical user ID
· numerical group ID
· user name or comment field
· user home directory
· optional user command interpreter
...
4、查看和命令相关的所有帮助
//列出所有含有passwd字串的帮助文档
arururururu@ubuntu:~$ man -k passwd
chgpasswd (8) - update group passwords in batch mode
chpasswd (8) - update passwords in batch mode
Crypt::PasswdMD5 (3pm) - Provides interoperable MD5-based crypt() functions
fgetpwent_r (3) - get passwd file entry reentrantly
getpwent_r (3) - get passwd file entry reentrantly
gpasswd (1) - administer /etc/group and /etc/gshadow
grub-mkpasswd-pbkdf2 (1) - generate hashed password for GRUB
lppasswd (1) - add, change, or delete digest passwords.
pam_localuser (8) - require users to be listed in /etc/passwd
passwd (1) - change user password
passwd (1ssl) - compute password hashes
passwd (5) - the password file
passwd2des (3) - RFS password encryption
smbpasswd (5) - The Samba