CentOS7將新建帳號加到Sudoer中

如何將新建的帳號加到Sudoer中呢?

灌完Linux之後,

除了最原始的帳號(root)之外,

通常會要我們在新增一組帳號密碼,

畢竟因為安全性的問題,

可是新增完一組帳號密碼後,

卻發現權限不夠。

(↑​透過Sudo還是出現錯誤訊息"not in the sudoers file")

這時該怎麼做呢?

先切換到root帳號,

使用Terminal來進行visudo的修改,

sudo visudo

進入之後透過i來修改,

尋找設定值 ALL=(ALL),

## Next comes the main part: which users can run what software on
## which machines (the sudoers file can be shared between multiple
## systems).
## Syntax:
##
##      user    MACHINE=COMMANDS
##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL

在root底下新增需要有sudoer的帳號,

## Next comes the main part: which users can run what software on
## which machines (the sudoers file can be shared between multiple
## systems).
## Syntax:
##
##      user    MACHINE=COMMANDS
##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL
misroot ALL=(ALL)       ALL

按下ESC之後,

按下「:」之後輸入wq,

Enter完之後,

在切回新增的那組帳號中,

再執行一樣的指令,

就可以囉!