13

I have run the following commands:

sudo groupadd -r testgroup
sudo useradd -g testgroup -M -r testuser

Notice the -r option, which according to the man page:

-r
    Create a system account.

Assuming I have a user account with root privileges, I then run:

sudo -u testuser cat /dev/input/mouse0

However, I get:

cat: /dev/input/mouse0: Permission denied

Running the same command as root provides the expected output (garbled output from the mouse driver).

How can I create a user with root privileges?

Marco Ceppi
  • 48,827
Nathan Osman
  • 32,495

5 Answers5

22

Haven't tried it but this should create a new user and add them to the sudo group, which if your /etc/sudoers is as default, should mean they're allowed to use sudo with their password (just like the standard first user):

sudo adduser --group sudo newusername

If you've already created the user, you can just run:

sudo adduser existing_user sudo

man adduser will show you some of the other billion permutations and combinations of arguments this tool has.

Note: If you use Ubuntu 11.10 or older, you should use the admin group instead of sudo.

Eliah Kagan
  • 119,640
Oli
  • 299,380
3

I found some sites where they do the: sudo adduser paul admin

but my linux does not have the admin group so I use:

sudo adduser paul sudo
devav2
  • 37,290
Papi
  • 31
2

"System account" just means that the user will get an UID (user identifier) from a reserved range, it doesn't give any extra permissions. The right way to elavate privileges is to use sudo, as described by Oli.

Adam Byrtek
  • 9,861
0

The following worked on Ubuntu 16.04 LTS:

sudo adduser robert && sudo adduser robert sudo

Creates the user and adds him/er to the sudoer list

Justas
  • 211
0
sudo usermod -a newuser -G sudo