Joh*_*ohn 26 users administration
所以我不得不在书中做一个练习作为家庭作业。首先,您必须创建一个用户,例如:
useradd -c "Steven Baxter" -s "/bin/sh" sbaxter
Run Code Online (Sandbox Code Playgroud)
然后你必须在/home/sbaxter
目录中添加一些文件:
touch /home/sbaxter/ some.txt new.txt files.txt
Run Code Online (Sandbox Code Playgroud)
然后您必须删除该sbaxter
用户并创建一个名为 的新用户mjane
。令我惊讶的是,当我运行时find /home/ -user mjane
,新用户mjane
现在拥有 sbaxter 的所有旧文件,发生了什么?
Dra*_*oan 43
魔鬼在细节中,在useradd
手册页中(您可以通过发出 看到man 8 useradd
):
-u, --uid UID
The numerical value of the user's ID. This value must be unique,
unless the -o option is used. The value must be non-negative. The
default is to use the smallest ID value greater than or equal to
UID_MIN and greater than every other user.
Run Code Online (Sandbox Code Playgroud)
因此,它将默认使用密码文件中最小的未使用的 uid,即比其他用户大的 uid。看到删除 sbaxter 会将他从 passwd 文件中删除,他的 uid 是“空闲的”并被分配给 mjane(因为在使用命令useradd
时两个用户的 uid选择是相同的useradd
)。
磁盘上的文件仅存储 uid,而不存储用户名转换(因为此转换在密码文件中定义)。您可以通过发出ls -ln
查看 uid 所有权文件来确认这一点。
我实际上建议您禁用而不是删除帐户。大多数 Linux 发行版上的锁定帐户都可以使用 来实现usermod -L -e today <username>
,它会锁定密码并将帐户设置为今天到期(您可以使用 来查看帐户的到期日期chage -l
)。
归档时间: |
|
查看次数: |
1179 次 |
最近记录: |