1. 程式人生 > >/etc/sudoers: syntax error near line xxxx

/etc/sudoers: syntax error near line xxxx

>>> /etc/sudoers: syntax error near line 28 <<<
sudo: parse error in /etc/sudoers near line 28
sudo: no valid sudoers sources found, quitting

這個錯誤其實是挺棘手的,一般來說我們有一個能夠使用 sudo 獲取超級許可權的使用者是相當方便的,不需要去啟用 root 使用者。而且現在的 Ubuntu 中也是預設不啟用 SuperUser 的,在官網上也列出了好幾個不錯的優點,轉而讓普通使用者通過 sudo 來獲取對應的許可權。

今天想通過

新增使用者命令添加了一個使用者,有這樣的提示:

[email protected]:~$ sudo apt-get update
[sudo] password for edgarzeng: 
edgarzeng is not in the sudoers file.  This incident will be reported.

完了,咱這個新使用者沒這麼受歡迎,還不讓用 sudo 了。不過,其實人家已經說的比較清楚了,泥小子不在 sudoers 裡邊哦。好吧,這麼客氣,我們就給個申請進去不就好了麼。
edgarzeng ALL = (ALL) ALl

以上這句話我們需要新增到一個任意命名的檔案中,置於/etc/sudoers.d/之下,我將這個檔案就命名為 edgarzeng,呵呵,不錯。完了有件事可別忘了:

 sudo chmod 0440 edgarzeng
這是將剛剛我們建立的那個檔案許可權給改了,這樣才有效,否則系統會很有愛的提示您:
[email protected]:/etc/sudoers.d$ sudo apt-get update
sudo: /etc/sudoers.d/edgarzeng is mode 0644, should be 0440
[sudo] password for edgarzeng: 

就在我要使用的時候就有這玩意兒提示我了。最終,也是 sudo 無法使用。

好了,其實如果一切順利的話就會如上一樣,輕輕鬆鬆搞定了。

可是,不知道是否有注意到我 edgarzeng 檔案中的語法是問題的呢?這直接就導致了 sudo 直接無法使用了,錯誤即開篇提到的那個。哎,悲催。請注意 最後一個 ALl

,二筆般的就給把 L 小寫了,這就是傳說中的 syntax error。

然後我開始滿大街的找方案,又見識了滿大街都是一家人的網路,一律都是暴力方式啊,這裡我就不舉出是什麼方案了,有興趣自己百度(不推薦使用,但是這種方案也就只有百度能給出了)

那既然我們是把語法給搞錯了麼,就把它搞正確不就好了麼,介紹個其實和 sudo 有異曲同工的 命令 pkexec,而且官方推薦在執行具有 gui 的程式時最好用後者的:

pkexec visudo -f /etc/sudoers.d/edgar 

然後,就可以編輯那個錯誤的東東。ok,搞定。


相關推薦

/etc/sudoers: syntax error near line xxxx

>>> /etc/sudoers: syntax error near line 28 <<< sudo: parse error in /etc/sudoers near line 28 sudo: no valid sudoers s

改錯了sudoer檔案出現 /etc/sudoers: syntax error錯誤的解決辦法並且root無法使用

# # This file MUST be edited with the 'visudo' command as root. # # Please consider adding local content in /etc/sudoers.d/ instead of # directly modifying

ubuntu改錯了sudoer檔案出現 /etc/sudoers: syntax error錯誤的解決辦法

問題描述:在使用ubuntu的過程中修改了/etc/sudoers檔案導致出現如下錯誤:>>> /etc/sudoers: syntax error near line 32 <<<sudo: parse error in /etc/sud

bash: ./xxxx.sh: line xx: syntax error near unexpected token "xx''

今天在編譯android openssl的時候使用指令碼檔案出現了下面的錯誤: [email protected]:~/AndroidBox/openssl-1.1.0f$ source ./setenv-android.sh : command not fou

-bash:syntax error near unexpected token '('

xshell5 shel 括號 ted bash 出錯 linu linux5 ear 在Xshell5中編寫int main(int argc,char** argv)時, 出現-bash:syntax error near unexpected token ‘(‘ ;

shell中syntax error near unexpected token `fi'錯誤

一、原始碼 #! /bin/bash   if [ $# -eq 0 ] then echo  "$0 filename" exit fi   if [ $# = 1 ] then if ! [ -c $1 ] th

mac下-bash: syntax error near unexpected token `('

在使用go-xorm將mysql的表結構匯出為go 結構體時候,出現如下錯誤 $ xorm reverse mysql root:[email protected](127.0.0.1:3306)/dbname?charset=utf8 templates/goxorm/ -bash:

linux下解決rm 反向刪除報錯syntax error near unexpected token `('的問題

程式碼: #!/bin/bash service csrasm stop sleep 5 service csrass stop sleep 10 cd /etc/csrass rm -fr !(csrass.srd) service csrasm start service csrass star

(轉)Windows 平臺下解決httpd.exe: syntax error on line 39

計算機 inf src 由於 不清楚 出現 分享圖片 服務 syn 近來在研究PHP,結果為了Apache的安裝傷神不已。。。小白我在安裝後,啟動Apache的服務雖然可以,不過,在Apache sevice monitor 中啟動services時就會出現

[Bash]syntax error near unexpected token 'then'

#!/bin/bash clear function test { if[$1 -eq "root"]&&[$2 -eq "123456"] then echo "Right" else echo

shell程式設計 報錯 syntax error near unexpected token 最終解決

剛接觸shell程式設計,問題不斷,這個問題有兩種情況: 第一種是像網上說的那些,因為換行符的問題,其產生的通常情況是你在Windows下編寫好的程式碼,放到linux下執行出錯,如果是此種情況,請移步網上方法解決,這裡不再贅述。 下面說我遇到的第二種情況,其實這種問題出

syntax error near unexpected token `(' 問題解決方法

 #!/bin/bash  #Program: # #History: #2018/11/10 LY first release PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin

linux--shell錯誤:syntax error near unexpected token ‘('

這幾天編寫了幾個簡單的shell程式,然後都出現了syntax error near unexpected token ‘(' 的錯誤,然後實在是檢查不出錯誤;後面百度了才找到的原因: 之前錯誤的程式

shell編程報錯:“syntax error near unexpected token `”

一個 兩個 tle ctrl+v center 以及 中修改 blank 存儲 shell編程報錯:“syntax error near unexpected token `” 今天寫了個shell腳本,在自己機器上運行正常,給同事,運行報錯syntax error nea

syntax error near unexpected token `do

這種情況發生的原因是因為你所處理的檔案換行符是dos格式的"\r\n"可以使用cat -v 檔名來檢視換行符是否是。如果是上述的,則行結尾會是^m,需要轉換成linux/unix格式的"\n"。#!/b

執行shell指令碼提示“syntax error near unexpected token for((i=0;i

sh指令碼如下: #!/usr/bin/env bash county="3 4 5 6 7 8 9 10 11 12 16 29 39 44 53 62 72 84 97 115 128 151

關於報錯“syntax error near unexpected token `”和回車換行

本來是很簡單一個事情,轉過來是因為打字機這事比較有趣…… http://blog.csdn.net/xyp84/archive/2009/08/11/4435899.aspx 摘要一下: 回車 換行 0D 0A <CR> <LF&

bash: syntax error near unexpected token `newline'(關鍵詞:flask/bug)

《Flask Web開發》第6章 電子郵件 使用Flask-Mail提供電子郵件支援,P60: (venv) $ export MAIL_USERNAME=<Gmail username>

shell程式設計報錯:“syntax error near unexpected token `”

在UE下使用16進位制看了一下,是0D0A結尾的,修改為OA結尾的。使用b.cat filename1 | tr -d "\r" http://blog.csdn.net/xyp84/article/details/4435899   今天寫了個shell指令碼,

指令碼報錯:syntax error near unexpected token

今天將之前寫好的shell指令碼拿出來用,發現執行時就報錯:syntax error near unexpected token 很奇怪,之前執行的一直沒事... 後來在網上找了下,發現指令碼內容每行尾行都添加了^M的字元,檢視方式:vi -b 開啟指令碼檔案 後