我的系统有很多用户,但从未创建过,例如mysql
或tomcat
。这些用户内部没有主目录/home
显然,守护程序在这些用户下运行。
这些用户的用语是什么?
如何创建自己的此类用户?例如,我希望为创建一个用户deluged
,但我不想为此创建并记住密码,也不想允许某人从控制台使用该用户登录。
如何完成?
您可以给useradd-r
或--system
标志来告诉您您想要这样的用户(您已经将其称为系统用户)。这是我系统手册页的摘录:
-r, --system Create a system account. System users will be created with no aging information in /etc/shadow, and their numeric identifiers are choosen in the SYS_UID_MIN-SYS_UID_MAX range, defined in /etc/login.defs, instead of UID_MIN-UID_MAX (and their GID counterparts for the creation of groups). Note that useradd will not create a home directory for such an user, regardless of the default setting in /etc/login.defs (CREATE_HOME). You have to specify the -m options if you want a home directory for a system account to be created.
尽管您可以通过将shell设置为/bin/false
或/sbin/nologin
诸如此类来使任何用户无法从控制台登录。您可以使用-s
touseradd
进行更改,也可以chsh -s /sbin/nologin
例如使用更改现有用户。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句