10

I am new to Raspberry PI. I need to create new user in Raspberry PI in Raspbian distro, but I would like to have different username but with equal or same level of privileges? How could I do it?

7
  • Why do you want to do this, Is this login for someone else to use? if you are duplicating the permissions and you are the one using the account I don't see the benefit. This thread raspberrypi.org/forums/viewtopic.php?f=91&t=37324 and particularly the answer from @joan (another user here) will get you started. Sep 8 '15 at 11:18
  • I have another Raspberry PI which also I need to ssh. Having same name in ssh is not helping me. But, I want to have same level of privileges for new user.
    – Main
    Sep 8 '15 at 11:24
  • 1
    The problem would appear to be with your SSH toolchain and prompt, so why not address it with a custom prompt and better SSH tools, instead of creating a bigger attack surface for hackers. What are you using to SSH? What type of computer are you SSHing from? What command are you using that is confusing you? are you SSHing using a hostname or IP address? Sep 8 '15 at 11:34
  • 2
    wouldn't changing host names be a whole lot easier/safer? so you could SSH to applepie and blueberrypie with ssh pi@applepie or ssh pi@blueberrypie? Sep 8 '15 at 13:15
  • 1
    @SteveRobillard: For consistency, I'd recommend one spelling of 'pi/pie' though ;)
    – Jacobm001
    Sep 9 '15 at 17:50
3

If you run adduser with the same group as pi this should work (I haven't tried this).

As per the comments above this is the hard way to solve your problem. Just give each Pi an unique hostname and they should be easy to distinguish.

It is preferable to have the same username on each machine if you want to move files around.

20

Assuming a new name of username:

To create a new user account: sudo addduser username Follow the prompts, being sure to set a good password when prompted.

You also want to add the new user to the same groups that the pi user belongs to. You can view the groups the pi users belongs to with groups pi.

groups pi pi : pi adm dialout cdrom sudo audio video plugdev games users netdev input spi i2c gpio

Note that your new user will automatically have a group created matching their username. You do not need to add your new user to the pi group.

You can add your new user to each group individually using sudo adduser username groupname. For example:

sudo adduser username sudo sudo adduser username audio

If you want your new user to have the exact same rights as the pi user, add the new username to all of the groups except the pi group that the pi user belongs to. You can save some typing by doing this in one pass:

for GROUP in adm dialout cdrom sudo audio video plugdev games users netdev input spi i2c gpio; do sudo adduser username $GROUP; done

Be sure to add your new user to the sudo group since that is what allows the use of the sudo command by the new user. netdev can be important for configuring network devices.

As others have noted, you're probably better off simply changing your hostname (can be done with sudo raspi-config under Advanced->Hostname) to accomplish what you're after. Also, don't forget the old pi account still exists, and possibly with a default password, so be sure to at least change the password for the pi user for security reasons.

4
  • 1
    Better (to avoid typing groups) for GROUP in $(groups pi | sed 's/.*:\spi//'); do sudo adduser username $GROUP; done
    – Milliways
    Sep 9 '15 at 6:08
  • Better so long as figuring out the correct regexp doesn't take longer! Are you guaranteed "pi" will always be the 1st group listed after the username? I don't see anything in the groups manpage. I throw my new user in other groups (e.g. sshusers) as well upon creation.
    – bobstro
    Sep 9 '15 at 14:00
  • I don't have any problem with RE, at least simple ones like this. If pi isn't 1st it will fail to delete it.
    – Milliways
    Sep 9 '15 at 23:32
  • Was thinking more of a new user such as the OP!
    – bobstro
    Sep 9 '15 at 23:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.