Ubuntu新增使用者並賦予sudo許可權
Create a User
To create a user in Ubuntu, open terminal (Ctrl+Alt+t) and execute the command (replace user_name with the username of your choice etc coolgeek).
sudo adduser user_name
(Then you will be prompted to Enter the details for the new user such as password, Name, Room Number, Phone Number etc, just enter the details correctly and hit ‘y’)
Granting sudo power to the User
Now, you’ve created the user, you can add the user to sudo group (which is created by default in Ubuntu, you could also use admin group) using the following command -
sudo adduser user_name sudo
OR
sudo adduser user_name admin
In the case if sudo group doesn’t exist or you want to create your own group then use the following commands -
Creating a Group (User Group)
First create a group using the command (Replace group_name with the group you want to create e.g geeky)-
sudo addgroup group_name
Then add that group to sudoers file, to do that first open the file using the command -
sudo visudo
and add the following line to the bottom of the file (then save the file and exit).
%group_name ALL=(ALL:ALL) ALL
Although creating groups isn’t necessary but it makes user management (with different privileges) much easier. Anyway, if you just want to grant root permission to any user then add this line to the sudoers file -
user_name ALL=(ALL:ALL) ALL