What is the use of option -o in the useradd command?

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.

Tags:

Linux

Useradd