Linux 普通用戶sudo執行命令不須要密碼

假設我這裏的用戶名是 hellovim

step 0: 切換到 root 用戶:

su root

step 1: 設置文件權限

chmod 0777 /etc/sudoers

step 2: 修改文件

vim /etc/sudoers

#includedir /etc/sudoers.d 追加以下內容並保存退出:code

hello	ALL=(ALL) NOPASSWD:ALL

注意:位置必須在#includedir /etc/sudoers.d 後面,添加在其餘地方不生效權限

step 3: 設置文件權限

chmod 0440 /etc/sudoers
相關文章
相關標籤/搜索