当前位置: 首页 > Linux

Linux创建一个新用户

时间:2023-04-07 00:03:33 Linux

1。要添加用户,首先使用adduser命令添加一个普通用户。命令如下:addusertommy//添加一个名为tommy的用户passwdtommy//ChangepasswordChangingpasswordforusertommy.NewUNIXpassword://Inputthenewpasswordhere:RetypenewUNIXpassword://Enterthenewpasswordagainpasswd:所有身份验证令牌已成功更新。Comment(#)Remove允许wheel组的人运行所有命令%wheelALL=(ALL)ALL然后修改用户,使其属于根组(wheel),命令如下:usermod-groottommy后修改后,现在可以使用tommy账号登录,然后使用命令su-获取root权限进行操作。方法二:修改/etc/sudoers文件,找到下面这一行,在root下添加一行,如下:AllowroottorunanycommandsanywhererootALL=(ALL)ALLtommyALL=(ALL)ALL修改后即可使用tommynow账号登录,然后使用命令sudo–获取root权限进行操作。方法三:修改/etc/passwd文件,找到下面这一行,将用户ID改为0,如下图:tommy0:33:tommy:/data/webroot:/bin/bashswitchloginuser:su[username]或sudo[用户名]参考链接:Linux中列出用户的2种方法