In Red Hat, there are three different types of user accounts: root, normal user and system. The root account is the equivalent of the Administrator or Enterprise Admin account in the Windows world. You should never use this account because of the power of this account has. Ever!
Normal user accounts have no write access to anything on the system except their home directory, which is created when user account is added.
A system account is similar to a normal user account. The main different is that system users normally don’t have a home directory and can’t log in the way normal users do. Many system users are created or associated with applications or services to help run them more securely.
Users Management
To manage user accounts, you can use the following commands:
useradd Creates user or system accounts
usermod Modifies user accounts
userdel Removes a user or system account
For example, to create the first user account, you can use the following:
# useradd -c “Han Thuy” -m -s /bin/bash user01
This command creates a user account named user01 and a home directory for the user (-m option), sets the user’s shell to BASH, and adds a description to the user’s account called Han Thuy. All users have a unique ID that defines them (UID) and a group ID (GID). In Red Hat, UIDs start at 500 for normal users and can extend into thousands. For system users, the UID starts at 1 and goes to 499.
You can check to see the new user’s home directory by using the following:
Now suppose you want to delete user01, you use the userdel command:
Syntax: userdel [options] <username>
Options:
-f Forces deletion of the user even if he’s still logged in
-r Removes the user’s home directory and mail spool
# userdel -rf user01
Be careful when using this command because the important data may still in user’s home directory. Make sure that you have a backup before you delete it.
Do you wonder that I haven’t set the password for the user login? Be default, an account is locked until a password is assigned to it. For password management, you can use the following commands:
passwd Sets a password or resets a password for a user account
chage Enables you to modify the parameters surrounding passwords
pwck Verifies the consistency of passwords across database files
Now let’s assign a password for user01 to login to the system:
Some more examples for you to manage user account:
+ Find the user’s password information:
+ Set user01’s account to expire in one week (today is 06-11-2011)
Groups Management
Now if you have some users and they have passwords, let’s create some groups to put some of the users in. Create a group is similar to creating a user. Here are the commands for group creation and management:
id Show UID/GID for the group of a given user
groupadd Creates a group
groupmod Modifies the properties of a group
groupdel Deletes a group
Let’s create a group called Sales for user01:
Much like users are contained within the /etc/password file, groups are maintained with /etc/group file.
Have fun!