Not registered yet?
Register now! It is easy and done in 1 minute and gives you access to special discounts and much more!
As the title indicates, what is the use of option -o for command useradd? What is a good use case of this option?
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.
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.
# useradd -o scrooge -u 0
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' :)
su - scrooge -c 'id -u -n'
And, quite unexpectedly, it also totalled my gdm on Ubuntu 18.04. Awww crap, I should have done it inside container...