Search

domingo, 3 de julho de 2011

How to: Add a new user

Hello, in my first post i will explain how to add a new user to your system.

Difficult: easy
Avg Time: 1 min


Linux have a built in command called "useradd" that help people to add new user to the system.
To add a new user you must be logged as root or you will need to use sudo.
I will give some of the must useful examples.

Syntax: useradd options name

Example 1: Add new user to the system
useradd -r ricardo
Example 2: Add new user and do not create home directory (/home)
useradd -rM ricardo
Example 3: Add new user and create home directory in /home
useradd -rm ricardo
Example 4: Add new user and specify the home directory
useradd -rd /somedir/somedir ricardo
Example 5: Add a user and create a group with the same name
useradd -rn /somedir/somedir ricardo
Example 6: Add a user and add user to existent group
useradd -r -g groupname ricardo
Example 7: Add a user, create home directory and a group with same name
useradd -rmn ricardo

If you would like to set a password for the user i recommend you to use the passwd command instead of the -p option of useradd command.

Example 8: Create new user and set the password
useradd -rm ricardo
passwd ricardo

That's the way i use to add new user and set user password, if you have any other suggestion please post it as comment

Sem comentários:

Enviar um comentário