user_id 和 group_id 始终从唯一值开始
当我在 Linux 中使用 useradd
命令时,该帐户的 user_id
和 group_id
会自动选择为 500。现在,如果我删除该帐户并创建再一次,那么user_id和group_id也是500。这个默认值是从哪里选择的?
我使用了这个命令:
$ useradd ping
password:
然后查看了以下文件
$ cat /etc/group /etc/passwd
root::0:root
tty::5:
disk:x:100:
floppy:x:101:
uucp:x:102:
utmp:x:103:
lp:x:104:
kmem:x:105:
vcsa:x:106:
sshd:x:74:
ping:x:500:
root:x:0:0:root:/root:/bin/bash
nobody:x:99:99:Nobody:/:/sbin/nologin
vcsa:x:106:106:vcsa privsep:/var/empty:/sbin/false
sshd:x:74:74:sshd privsep:/var/empty:/sbin/false
ping:x:500:500::/home/ping:/bin/bash
When i used useradd
command in linux, the user_id
and group_id
for the account is automatically chosen as 500. Now if i delete the account and create it again, then also the user_id and group_id is 500. From where is this default value chosen ?
I used this command :
$ useradd ping
password:
and then looked into the following file
$ cat /etc/group /etc/passwd
root::0:root
tty::5:
disk:x:100:
floppy:x:101:
uucp:x:102:
utmp:x:103:
lp:x:104:
kmem:x:105:
vcsa:x:106:
sshd:x:74:
ping:x:500:
root:x:0:0:root:/root:/bin/bash
nobody:x:99:99:Nobody:/:/sbin/nologin
vcsa:x:106:106:vcsa privsep:/var/empty:/sbin/false
sshd:x:74:74:sshd privsep:/var/empty:/sbin/false
ping:x:500:500::/home/ping:/bin/bash
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认值取决于您运行的 Linux 发行版。
我的 debian 盒子在
/etc/login.defs
文件中设置了UID_MIN 1000
。如果您的目标是使用不同的 UID,那么您需要使用
-u |
选项。useradd
的 --uidThe defaults are dependent upon the linux distribution you're running.
My debian box has
UID_MIN 1000
set in the/etc/login.defs
file.If your goal is to use a different UID, then you need to use the
-u | --uid
option foruseradd
.