Linux普通用戶沒法使用sudo

問題描述:html

  jenkins執行發佈腳本,由於使用的是jenkins用戶,因此有些shell命令須要 sudo 來執行,致使報錯。nginx

+ sudo rm -rf /usr/share/nginx/html/jenkins_test.bak

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

sudo: no tty present and no askpass program specified

 

解決辦法:shell

  編輯 '/etc/sudoers' 文件,由於沒有編輯權限,須要增長權限spa

chmod u+w /etc/sudoers

  進入編輯模式,找到htm

## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL

  在下面加入一行,jenkins換成要使用 sudo 命令的用戶blog

jenkins ALL=(ALL)       ALL

  而後保存,退出,恢復文件的權限three

chmod u-w /etc/sudoers
相關文章
相關標籤/搜索