1. 程式人生 > >Linux Ubuntu 16.04 獲取 root 同等權限

Linux Ubuntu 16.04 獲取 root 同等權限

2.3 非root touch use tee 輸入 root t權限 root權限

1、簡介

????很多 時候 ,不允許 使用 root 用戶,但是 非 root 用戶 有時 又要 具備 root 權限,此時,就需要 對 非root用戶 賦予 root 同等權限操作(具備了 root 同等權限 後,修改/刪除 之類 的操作 就要 慎重嘍!!!);
????

2、sudoer用戶

2.1 基本概念

????使用 sudo 獲取 root權限的 非root用戶,叫做 sudoer
????

2.2 配置

2.2.1 創建 非root 用戶同名文件

????在 "/etc/sudoers.d" 目錄下創建 與 sudoer用戶同名的文件

# touch /etc/sudoer.d/{user_name}

????

2.2.2 sudoer 權限設置

????用戶配置文件中添加相應的權限設置(如免密碼輸入)

# echo "{user_name} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoer.d/{user_name}

????

2.3 shell 實現

#[ -e /etc/sudoers.d/{user_name}] || echo ‘{user_name} ALL=(ALL) NOPASSWD:ALL‘ | tee  /etc/sudoers.d/{user_name}

????

Linux Ubuntu 16.04 獲取 root 同等權限