CentOS7 添加新用戶並授權 root 權限


參考文章:CentOS 7中添加一個新用戶並授權

# root 用戶操作
$ 普通用戶操作

創建用戶

# adduser USERNAME
# passwd USERNAME (輸入密碼)

授權 root 權限

sudo 命令的授權管理是在sudoers文件里的。查看 sudoers 位置:
# whereis sudoers
查看 sudoers 的讀寫權限:
# ls -l /etc/sudoers
如果 sudoers 沒有寫權限則添加:
# chmod -v u+w /etc/sudoers
修改 sudoers:
# vim /etc/sudoers

找到 ## Allow root to run any commands anywher ,修改如下:
root ALL=(ALL) ALL
USERNAME ALL=(ALL) ALL # 這個是新增的用戶

回收 sudoers 寫權限:
# chmod -v u-w /etc/sudoers

使用$ sudo su命令,輸入密碼切換 root 用戶


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM