本篇介紹如在 Linux 中使用 useradd 指令,使用centos7來新增使用者帳號和擁有root權限帳號
Step 1 建立帳號
[root@xxx ~]$ useradd user
Step 2 修改密碼
[root1@xxx ~]$ passwd user
Step 3 修改設定檔
PS:如果不需要用到root權限以下步驟省略
[root1@xxx ~]$ sudo visudo
尋找設定值『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
在下一行新增設定值,user就是想要改成能夠執行sudo的帳號
## Allow root to run any commands anywhere root ALL=(ALL) ALL user ALL=(ALL) ALL
Step 4 存檔離開
:wq