su; # become super user adduser
sudo; # add username to the group 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
vim /etc/sudoers; # open up config # add the orange line for username "user" # User privilege specification root ALL=(ALL:ALL) ALL user ALL=(ALL:ALL) ALL :wq! # save and quit in vim reboot; # reboot system
WRONG FOR DEBIAN! http://askubuntu.com/questions/7477/how-can-i-add-a-new-user-as-sudoer-using-the-command-linehttp://askubuntu.com/questions/7477/how-can-i-add-a-new-user-as-sudoer-using-the-command-line
if you get strange error „can’t resolve hostname“:
Two things to check (assuming your machine is called
, you can change this as appropriate):
- That the
file contains just the name of the machine.
has an entry forlocalhost
. It should have something like:
127.0.0.1 localhost.localdomain localhost 127.0.1.1 my-machine
If either of these files aren’t correct (since you can’t sudo), you may have to reboot the machine into recovery mode and make the modifications, then reboot to your usual environment.