Just add the user to the sudo
group:
sudo adduser <username> 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 <username>
to see what groups are normally in use.
admin
I can later add myself to any other groups as well, right? – David B Oct 15 '10 at 12:44sudo
group is for. Let's find out. – ændrük May 17 '11 at 01:49admin
group doesn't exist in 12.04 LTS. – rxgx Jun 12 '12 at 01:10sudo adduser myuser && sudo adduser myuser root
– Kris Aug 18 '16 at 10:23sudo adduser myuser && sudo adduser myuser sudo
– H2ONaCl Feb 09 '17 at 18:42groupadd sudo
– Nicolai Weitkemper Nov 17 '22 at 17:02$ sudo adduser moth sudo
it just gave me usage options likeUsage: adduser [options] LOGIN
. – Aaron Franke Jan 26 '24 at 17:47