Fad*_*adi 9 linux users ubuntu-14.04
我想添加一个名为“nexus”的用户,uid 为 1234567(示例编号),gid 为 1234567。
我正在运行以下命令:
sudo useradd -r -U -u 1234567 -g 1234567 -m -c "nexus role account" -d /sonatype-work -s /bin/false nexus
Run Code Online (Sandbox Code Playgroud)
但我收到错误:
useradd: group '1234567' does not exist
Run Code Online (Sandbox Code Playgroud)
如果我这样做:
sudo useradd -r -U -u 1234567 -m -c "nexus role account" -d /sonatype-work -s /bin/false nexus
Run Code Online (Sandbox Code Playgroud)
然后,当我检查id -u nexus它显示了正确的uid(1234567),但是当我检查id -g nexus的gid设置为999。
如果我这样做,sudo adduser --uid 1234567 nexus则用户和组 ID 设置相同。
我可以用同样的方法useradd还是必须使用它adduser来实现我的目标?
顺便说一句,我一直在关注本教程:
http://www.tecmint.com/add-users-in-linux/
PS:如果我必须使用,adduser那么我可以在没有任何人为交互的情况下使用吗?即:通过脚本自动创建用户?
编辑:
这是结果 sudo adduser --uid 1234567 nexus
Adding user `nexus' ...
Adding new group `nexus' (1234567) ...
Adding new user `nexus' (1234567) with group `nexus' ...
The home directory `/home/nexus' already exists. Not copying from `/etc/skel'.
adduser: Warning: The home directory `/home/nexus' does not belong to the user you are currently creating.
Enter new UNIX password:
Retype new UNIX password:
No password supplied
Enter new UNIX password:
Retype new UNIX password:
No password supplied
Enter new UNIX password:
Retype new UNIX password:
No password supplied
passwd: Authentication token manipulation error
passwd: password unchanged
Try again? [y/N] n
Changing the user information for nexus
Enter the new value, or press ENTER for the default
Full Name []: Nexus
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [Y/n] y
Run Code Online (Sandbox Code Playgroud)
感谢 Tom Yan,我通过创建一个同名的组,然后将用户添加到该组,最终解决了我的问题。所以我做了以下事情:
sudo groupadd -r -g 1234567 nexus \
&& sudo useradd -r -u 1234567 -g 1234567 -m -c "nexus role account" -d /sonatype-work -s /bin/false nexus
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
31873 次 |
| 最近记录: |