By osmak


2019-04-09 17:23:37 8 Comments

What is the use of option -o for command useradd? What is a good use case of this option?

2 comments

@Stephen Kitt 2019-04-09 17:28:54

useradd’s -o option, along with its -u option, allows you to create a user with a non-unique user id. One use case for that is to create users with identical privileges (since they share the same user id) but different passwords, and if appropriate, home directories and shells. This can be useful for service accounts (although typically you’d achieve the same result using sudo nowadays); it can also be useful for rescue purposes with a root-equivalent account using a statically-linked shell such as sash.

@K7AAY 2019-04-09 17:35:15

The -o option allows the creation of users with non-unique IDs, only when you also supply the numerical value of their UID with the -u option in the same line, e.g.:

# useradd -o huey -u 501
# useradd -o dewey -u 501
# useradd -o louie -u 501

This permits setting up multiple users with same rights and priveleges, but with different home directories and passwords.

@rrauenza 2019-04-09 21:44:53

# useradd -o scrooge -u 0

@kubanczyk 2019-04-10 07:30:52

Wonderful way to break all applications that parse usernames as output of id or ls -l. Given su - scrooge -c 'id -u -n' says 'root' :)

@kubanczyk 2019-04-11 14:30:30

And, quite unexpectedly, it also totalled my gdm on Ubuntu 18.04. Awww crap, I should have done it inside container...

Related Questions

Sponsored Content

1 Answered Questions

[SOLVED] what is difference between useradd -m and useradd -d?

  • 2018-06-09 17:20:30
  • Sanskar Sharma
  • 422 View
  • 0 Score
  • 1 Answer
  • Tags:   linux ubuntu

2 Answered Questions

[SOLVED] adduser has no difference from useradd

  • 2018-06-02 09:34:16
  • Hugues
  • 651 View
  • 6 Score
  • 2 Answer
  • Tags:   fedora useradd

0 Answered Questions

Debian 9 - useradd

3 Answered Questions

[SOLVED] What does adduser do that useradd doesn't?

1 Answered Questions

[SOLVED] What variables are valid within /etc/default/useradd file?

2 Answered Questions

[SOLVED] useradd where account name is a number

  • 2017-01-25 17:18:46
  • Peter Turner
  • 1046 View
  • 0 Score
  • 2 Answer
  • Tags:   useradd sles

2 Answered Questions

[SOLVED] useradd fails on archlinux

  • 2012-12-26 10:22:58
  • user29157
  • 7885 View
  • 3 Score
  • 2 Answer
  • Tags:   arch-linux useradd

1 Answered Questions

[SOLVED] Can't add users anymore by using useradd

  • 2015-11-01 16:23:18
  • tildearrow
  • 1588 View
  • 3 Score
  • 1 Answer
  • Tags:   useradd

1 Answered Questions

[SOLVED] useradd PAM authentication failed

  • 2015-01-22 09:12:26
  • Puneet S. Chauhan
  • 936 View
  • 0 Score
  • 1 Answer
  • Tags:   centos pam useradd

3 Answered Questions

[SOLVED] Disable login for useradd

  • 2014-03-03 13:50:49
  • Jimmy
  • 8992 View
  • 3 Score
  • 3 Answer
  • Tags:   linux shell debian

Sponsored Content