关于linux:linux创建新的用户

6次阅读

共计 712 个字符,预计需要花费 2 分钟才能阅读完成。

1、增加用户,首先用 adduser 命令增加一个普通用户,命令如下:

adduser tommy

// 增加一个名为 tommy 的用户

passwd tommy // 批改明码

Changing password for user tommy.
New UNIX password: // 在这里输出新密码
Retype new UNIX password: // 再次输出新密码
passwd: all authentication tokens updated successfully.

2、赋予 root 权限

办法一:批改 /etc/sudoers 文件,找到上面一行,把后面的正文(#)去掉

Allows people in group wheel to run all commands

%wheel ALL=(ALL) ALL

而后批改用户,使其属于 root 组(wheel),命令如下:

usermod -g root tommy

批改结束,当初能够用 tommy 帐号登录,而后用命令 su –,即可取得 root 权限进行操作。

办法二:批改 /etc/sudoers 文件,找到上面一行,在 root 上面增加一行,如下所示:

Allow root to run any commands anywhere

root ALL=(ALL) ALL
tommy ALL=(ALL) ALL

批改结束,当初能够用 tommy 帐号登录,而后用命令 sudo –,即可取得 root 权限进行操作。

办法三:批改 /etc/passwd 文件,找到如下行,把用户 ID 批改为 0,如下所示:
tommy0:33:tommy:/data/webroot:/bin/bash

切换登录用户:su [username]

或者 sudo [username]
参考链接:
2 ways to list users in Linux

正文完
 0