Tuesday, May 7, 2019

sudo - How can I add a new user as sudoer using the command line?




After I add a user using adduser, I can't see it via System > Administration > Users and Groups unless I log out and then log in again. Is that normal?



Also, can I set a newly added user as a sudoer or do I have to change that only after adding it? How can I do that via the shell?



Finally, can I delete the original user that was created upon initial installation of Ubuntu, or is this user somehow 'special'?



Just add the user to the sudo group:



sudo adduser  sudo



The change will take effect the next time the user logs in.



This works because /etc/sudoers is pre-configured to grant permissions to all members of this group (You should not have to make any changes to this):



# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL


As long as you have access to a user that is in the same groups as your "original" user, you can delete the old one.







Realistically, there are also other groups your new user should be a member of. If you set the Account type of a user to Administrator in Users Settings, it will be placed in at least all of these groups:



adm sudo lpadmin sambashare


Because your system configuration may vary, I suggest taking a look at the output of groups to see what groups are normally in use.


No comments:

Post a Comment

11.10 - Can't boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...