ubuntu下新增用户

whdugh 2014-04-24 10:28:48
在看鸟哥的私房菜,按书上的新建了一个用户,输入useradd命令,但是在/home目录下没有这个用户,这个是怎么回事啊

用grep查看时,如下:
...全文
296 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
yn_wolf 2014-05-05
  • 打赏
  • 举报
回复
引用 11 楼 yn_wolf 的回复:
那是因为useradd 默认不加-m参数,只会建立用户而不会建立相对应的用户目录(其实查看/etc/passwd文件是可以看到用户对应的目录的,只不过没有建立而已)。没加-m参数的话,后面需要手动建立目录,mkdir /home/vbird1 ,usermod -d /home/vbird1 vbird1 就可以了
对了要先chown -R username:username /home/username (其实改完之后usermod 也没有必要了)
yn_wolf 2014-05-05
  • 打赏
  • 举报
回复
那是因为useradd 默认不加-m参数,只会建立用户而不会建立相对应的用户目录(其实查看/etc/passwd文件是可以看到用户对应的目录的,只不过没有建立而已)。没加-m参数的话,后面需要手动建立目录,mkdir /home/vbird1 ,usermod -d /home/vbird1 vbird1 就可以了
剑指七星 2014-04-30
  • 打赏
  • 举报
回复
useradd -m -d /home/vbird2 -s /usr/bin/bash -g gid/gname vbird2 -s:用户的shell类型,要自己确定shell的位置,可以用which bash查看位置; -d:用户的家目录,请自行选择位置。 -g:用户组名或组id 另外:楼主第一幅图中是vbird1用户已经存在了
IT界的厨师 2014-04-26
  • 打赏
  • 举报
回复
引用 7 楼 ljc007 的回复:
-d /home/vbird2 -m -d, --home 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. -m, --create-home The user’s home directory will be created if it does not exist. The files contained in SKEL_DIR will be copied to the home directory if the -k option is used, otherwise the files contained in /etc/skel will be used instead. Any directories contained in SKEL_DIR or /etc/skel will be created in the user’s home directory as well. The -k option is only valid in conjunction with the -m option. The default is to not create the directory and to not copy any files.
版主果然是大牛
罗万千 2014-04-26
  • 打赏
  • 举报
回复
默认配置文件你看看是否有问题
ljc007 2014-04-25
  • 打赏
  • 举报
回复
-d /home/vbird2 -m -d, --home 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. -m, --create-home The user’s home directory will be created if it does not exist. The files contained in SKEL_DIR will be copied to the home directory if the -k option is used, otherwise the files contained in /etc/skel will be used instead. Any directories contained in SKEL_DIR or /etc/skel will be created in the user’s home directory as well. The -k option is only valid in conjunction with the -m option. The default is to not create the directory and to not copy any files.
whdugh 2014-04-25
  • 打赏
  • 举报
回复
引用 2 楼 ljc007 的回复:
-d, --home 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.

版主,我是想在/home目录下创建vbird2用户,加了参数-d还是不行,在home目录下没有文件夹,求指点,谢谢
loong0306 2014-04-24
  • 打赏
  • 举报
回复
useradd xxxxxx -u -g 把uid和gid加上试试、
loong0306 2014-04-24
  • 打赏
  • 举报
回复
引用 3 楼 whdugh 的回复:
[quote=引用 1 楼 u010957746 的回复:] useradd xxxxxx -u -g 把uid和gid加上试试、
额,为何用adduser就可以新建一个用户啊?新建了vbird1这个用户,但是切换到root时,出现下面的错误 [/quote]4楼的哥们应该说的对,楼主您看下。
FeelTouch Labs 2014-04-24
  • 打赏
  • 举报
回复
用户没有加入到sudo的配置文件里。可以利用 vi sudo 进行编辑加入。 在打开的配置文件中,找到root ALL=(ALL) ALL,在下面添加一行 xxx ALL=(ALL) ALL 其中xxx是你要加入的用户名称。然后保存就可以了。
whdugh 2014-04-24
  • 打赏
  • 举报
回复
引用 1 楼 u010957746 的回复:
useradd xxxxxx -u -g 把uid和gid加上试试、
额,为何用adduser就可以新建一个用户啊?新建了vbird1这个用户,但是切换到root时,出现下面的错误
ljc007 2014-04-24
  • 打赏
  • 举报
回复
-d, --home 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.

19,612

社区成员

发帖
与我相关
我的任务
社区描述
系统使用、管理、维护问题。可以是Ubuntu, Fedora, Unix等等
社区管理员
  • 系统维护与使用区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧