本文摘自PHP中文网,作者藏色散人,侵删。

linux怎么添加用户并赋予root权限?
linux下添加用户并赋予root权限的方法:
1、添加用户,首先用adduser命令添加一个普通用户,命令如下:
1 2 3 4 5 6 7 | #adduser 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 文件,找到下面一行,把前面的注释(#)去掉
1 2 | ## Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL
|
然后修改用户,使其属于root组(wheel),命令如下:
修改完毕,现在可以用tommy帐号登录,然后用命令 su ?C ,即可获得root权限进行操作。
方法二:修改 /etc/sudoers 文件,找到下面一行,在root下面添加一行,如下所示:
1 2 3 | ## Allow root to run any commands anywhere
root ALL=(ALL) ALL
tommy ALL=(ALL) ALL
|
修改完毕,现在可以用tommy帐号登录,然后用命令 sudo ?C ,即可获得root权限进行操作。
方法三:修改 /etc/passwd 文件,找到如下行,把用户ID修改为 0 ,如下所示:
1 | tommy:x:0:33:tommy:/data/webroot:/bin/bash
|
以上就是linux怎么添加用户并赋予root权限的详细内容,更多文章请关注木庄网络博客!
相关阅读 >>
Linux无法删除文件怎么办
Linux是怎么样的
怎么以 base64 编码的方式查询一台 ecs 实例的 自定义数据
在Linux下统计文件夹或文件夹中文件个数的方法
Linux中某个目录进不去导致卡死问题
Linux查看内存命令详解
Linux开机启动的方法有哪些?
Linux怎么打开3306端口
ecs ubuntu系统单独禁用和启动内外网卡命令
Linux截取命令是什么?
更多相关阅读请进入《Linux》频道 >>
转载请注明出处:木庄网络博客 » linux怎么添加用户并赋予root权限