Linux普通用戶無法使用sudo


問題描述:

  jenkins執行發布腳本,因為使用的是jenkins用戶,所以有些shell命令需要 sudo 來執行,導致報錯。

+ 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

 

解決辦法:

  編輯 '/etc/sudoers' 文件,因為沒有編輯權限,需要增加權限

chmod u+w /etc/sudoers

  進入編輯模式,找到

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

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

jenkins ALL=(ALL)       ALL

  然后保存,退出,恢復文件的權限

chmod u-w /etc/sudoers

  

 


免責聲明!

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



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