![创建名为“jdoe”的用户后,/home/jdoe 没有出现](https://linux22.com/image/1176659/%E5%88%9B%E5%BB%BA%E5%90%8D%E4%B8%BA%E2%80%9Cjdoe%E2%80%9D%E7%9A%84%E7%94%A8%E6%88%B7%E5%90%8E%EF%BC%8C%2Fhome%2Fjdoe%20%E6%B2%A1%E6%9C%89%E5%87%BA%E7%8E%B0.png)
我在 VirtualBox 上运行 Ubunutu 的最新版本。刚刚学习了 usermod 命令。我遇到了一个问题:
当我输入sudo useradd -d /home/jdoe jdoe
或sudo useradd -D /home/jdoe jdoe
甚至sudo useradd -b /home/jdoe jdoe
我的 jdoe 已成功创建,但我在 /home 部分看不到它的目录。当我以 jdoe 身份登录时,我在 /home 目录中,我可以看到我的个人目录,但看不到 jdoe 目录。
我找不到任何解决方案。我给你一些 /etc/passwd 文件的图片,用户“back”是我的个人账户。
谢谢您的帮助!以下是一些图片:https://i.stack.imgur.com/BhJ0d.jpg
答案1
正如所指出的man useradd
-d, --home-dir HOME_DIR
The new user will be created using HOME_DIR as the value for the
user's login directory. The default is to append the LOGIN name to
BASE_DIR and use that as the login directory name. The directory
HOME_DIR does not have to exist but will not be created if it is
missing.
如果要useradd
创建目录,则需要-m
或--create-home
选项,或者CREATE_HOME
在中设置值/etc/default/useradd
:
-m, --create-home
Create the user's home directory if it does not exist. The files
and directories contained in the skeleton directory (which can be
defined with the -k option) will be copied to the home directory.
By default, if this option is not specified and CREATE_HOME is not
enabled, no home directories are created.