useradd用户添加、 sudoers修改

linux 用户添加

root@master:~# adduser
adduser: Only one or two names allowed.
root@master:~# adduser user1
Adding user `user1' ...
Adding new group `user1' (1001) ...
Adding new user `user1' (1001) with group `user1' ...
Creating home directory `/home/user1' ...
Copying files from `/etc/skel' ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information for user1
Enter the new value, or press ENTER for the default
        Full Name []:
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n] y

修改用户属组

root@master:~# usermod user1 -G docker

sudoer 文件修改

切换到超级用户root登录,如果是其它用户登录,输入命令“su -”,输入root密码后,登录到root。

2、增加对etc/sudoers文件的修改权限 输入命令“chmod u+w /etc/sudoers”

3、输入命令“vim /etc/sudoers”,开始修改sudoers文件,找到 “root ALL=(ALL) ALL”,按键盘上的"i"键,切换到插入模式,在这条语句的下面录入: xxx ALL=(ALL) ALL

其中,xxx代表需要增加的用户名。

4、输入完成后,按ESC键后,保存修改记录。
如图:

 

posted @ 2023-03-09 15:55  橘子飞飞  阅读(265)  评论(0编辑  收藏  举报