如果我跑grep user /etc/passwd
,我得到字符串user:x:1021:1021::/home/user:/bin/bash
。数字“1021:1021”是什么意思?有没有一种离线方式可以找到这些意味着什么?如果我这样做,man passwd
我会得到有关命令的信息,而不是文件
/etc/passwd
每个用户帐户包含一行,七个字段以冒号(“:”)分隔。这些字段是:
- 登录名
- 可选的加密密码
- 数字用户 ID
- 数字组 ID
- 用户名或评论栏
- 用户主目录
- 可选的用户命令解释器
嗯,差不多就是这样。
(man7.org
该手册页有两个版本,上面是我在 Debian 上的版本。幸运的是,passwd
or的内容确实没有变化shadow
,我认为至少在 Linuxen 上是这样。)
其含义5
由例如手册页man
本身描述,它告诉手册“部分”是:
Run Code Online (Sandbox Code Playgroud)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)
您正在寻找文件passwd
,所以它是第 5 部分。
crontab
类似于它是一个命令 ( crontab(1)
) 和一个文件 ( crontab(5)
)。此外,open
似乎有命令(在 Linux 中,别名为openvt(1)
)、系统调用 ( open(2)
) 和 Perl pragma ( open(3perl)
) 的手册页。带有尾随文本的节号,例如3perl
也有些常见。
使用whatis foo
以找出是否有不止一个匹配:
$ whatis passwd
passwd (1) - change user password
passwd (1ssl) - compute password hashes
passwd (5) - the password file
Run Code Online (Sandbox Code Playgroud)
(哦,对了,还有openssl passwd
)
再有就是apropos
,这“[搜索]手动页面名称和说明”。通常给予更多的点击。
另请参阅:手册页中的数字是什么意思?
如果您有多个章节出现相同的命令/配置文件,这通常会在man
页面中提及。例如在底部man passwd
会发现
也可以看看
chpasswd(8)、passwd(5)、shadow(5)、usermod(8)。
暗示密码的第 5 章条目。反过来man 5 passwd
有
也可以看看
crypt(3), getent(1), getpwnam(3), login(1), passwd(1), pwck(8), pwconv(8), pwunconv(8), shadow(5), su(1),登录 (8)。