Friday, April 23, 2010

User add/remove in SLES

[Note: Don't use [ ] bracket in command line. You have been warned! ]

In SLES, adding user and removing user from the system requires some special flags to be used in command line.

To add user

#useradd -m [username]

-m flag enables to create /home/[username] directory

#useradd -r -m [username]

-r flag create a system account. A system account is an user with an UID between SYSTEM_UID_MIN and SYSTEM_UID_MAX as defined in /etc/login.defs, if no UID is specified. The GROUPS entry in /etc/default/useradd is ignored, too.

#passwd [username]
to create/change the password



Check out this after you add the user

#tail /etc/passwd --> This file contains user's information
testuser:x:1001:100::/home/testuser:/bin/bash
testuserdev:x:103:100::/home/testuserdev:/bin/false

testuser is created using only -m flag. Since, it is regular user, it is allowed to make login in the shell. It uses /bin/bash shell. [Remember, without shell you can't login. As shell is the middleware between user and kernel]

testuserdev is created using -r -m flag. Since, it is system user, it is not allowed to login in the shell. That's the reason, it has /bin/false




To remove the user
#userdel [username]

This will simply remove the user account credentials, but all the files in /home/[username] directory is not removed

#userdel -r [username]

-r flag forces to remove /home/[username] directory as well while deleting the user.

No comments:

Post a Comment