Sunday, June 6, 2010

Create, Modify, and Delete User in Linux

These steps require root privilege.

To create a new user:
useradd -m -c "User1" -s /bin/bash user1
The -m option will automatically create a user's home directory, i.e. /home/user1.
The -s option is to specify the user's default shell.

To modify an existing user:
Suppose we want to add an additional group newgroup to user1.
In Ubuntu,
usermod -a -G newgroup user1
In openSUSE
usermod -A newgroup user1
Be aware that, if you specify only with -G, you need to include the group that you wish to add as well as the groups that have already been added. That's why in Ubuntu, it has additional switch, which is -a to append the group and -A in openSUSE.

To delete an existing user:
userdel -r user1

No comments:

Post a Comment