top of page

Oracle Linux Basic Administration Series - Part 4 - How to Manage Users and Groups in Oracle Linux

  • Jason Beattie
  • 19 hours ago
  • 2 min read

User and group management is one of the most important skills for any Linux system administrator.It’s essential for controlling who can access the system, what permissions they have, and how they interact with files and services.


In this blog, we’ll cover how to create, modify, and delete users and groups, set passwords, and manage privileges on Oracle Linux.



Step 1: Understanding Users and Groups


Linux:

  • A user represents a person or process that can log in and execute tasks.

  • A group is a collection of users that share permissions.

User and group details are stored in:

  • /etc/passwd → user account info

  • /etc/shadow → encrypted passwords

  • /etc/group → group info

To view these files:

cat /etc/passwd
cat /etc/group
ree

Step 2: Creating a New User

Use the useradd command:

sudo useradd username

Example:

Now, set a password for the new user:


ree

You’ll be prompted to enter and confirm the password.


Step 3: Creating a User with Custom Options

You can customize the user’s home directory, shell, and UID (user ID).

Example:

sudo useradd -d /data/joe_home -s /bin/bash joe

Explanation:

  • -d → custom home directory

  • -s → specifies login shell

ree

Step 4: Modifying an Existing User

Change the username:

sudo usermod -l newname oldname

Change the home directory:

sudo usermod -d /new/home/path username

Add a user to an existing group:

sudo usermod -aG groupname username

Example:


ree

(The “wheel” group allows administrative privileges using sudo.)



Step 5: Deleting Users

To delete a user but keep their files:

sudo userdel username

To delete the user and their home directory:


ree

Step 6: Managing Groups


Create a new group:

sudo groupadd developers

Add a user to a group:

sudo usermod -aG developers joe

View group membership:

groups joe
ree

Delete a group:

sudo groupdel developers

Step 7: Granting Sudo (Admin) Privileges


Users in the wheel group can run administrative commands with sudo.

Add a user to the wheel group:

sudo usermod -aG wheel joe

Verify:

groups joe

To test:

su - joe
ree


ree

Step 8: Understanding Important Files

File

Description

/etc/passwd

Basic user info (username, UID, GID, home dir, shell)

/etc/shadow

Encrypted passwords and expiration data

/etc/group

Group names and member lists

/etc/sudoers

Who can run admin commands

To safely edit sudoers:

sudo visudo

Add a line like:

joe   ALL=(ALL)   ALL
ree

Step 9: Check User and Group Details


Display current logged-in user:

whoami

Show user details:

id username

Example:

uid=1001(joe) gid=1001(joe) groups=1001(joe),10(wheel)
ree

Step 10: Locking and Unlocking Accounts

To temporarily lock a user:

sudo passwd -l joe

To unlock:

sudo passwd -u joe

Conclusion


You now know how to manage users and groups — one of the cornerstones of Linux administration. With these commands, you can securely manage access and assign the right privileges to each user.

In the next post, we’ll move on to file permissions and ownership, where we’ll control what users and groups can do with files and directories.

 
 
 

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
Post: Blog2 Post
  • LinkedIn

©2023 Proudly created with Wix.com

bottom of page