Linux创建用户指定密码、组、sudo权限

  • 添加用户
    useradd [选项] 用户名 //其中 [选项],可省略。eg:useradd test添加test用户

    • 添加-g参数,用于指定用户组,如下例所示
    • useradd -g grp_1 test //新建test用户并增加到grp_1工作组
  • 设置密码
    passwd 用户名,eg:passwd test为test用户设置密码。
    在设置密码时,如果设置的密码少于8个长度,会有BAD PASSWORD: The password is shorter than 8 characters的提示,可以忽略该提示,继续设置密码。

  • 建立工作组
    groupadd grp_1 //新建grp_1工作组

  • 查看用户所在的组

    • groups查看当前用户所属的组
    • groups [user1] [user2] 查看user1、user2所属的组
  • 为用户添加sudo权限
    使用vim /etc/sudoers打开 suduers文件,找到root ALL=(ALL) ALL,对其进行复制,修改为用户名 ALL=(ALL) ALL。接上例所示,为test ALL=(ALL) ALL

发布了134 篇原创文章 · 获赞 30 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/donaldsy/article/details/104321874
今日推荐