Mastering User Management and Permissions in Linux.

Welcome back to my series, "Mastering Linux Basics for Cloud Security." In this third post, we'll dive into managing users and permissions in a Linux environment. We'll cover how to create shared folders, user groups, verify group memberships, and remove groups. Understanding these concepts is crucial for managing access control and ensuring security within your cloud infrastructure.

Creating and Managing Users

Adding New Users:

To add a new user in Linux, you can use the adduser command followed by the username.

Creating a New Group

Groups in Linux are used to manage permissions for multiple users simultaneously. To create a new group, use the addgroup command.

Verify Group Membership

To confirm a user is in the correct group, switch to that user and use the groups command. The command will list all groups the user peter belongs to.

Remove a Group

If you need to remove a group, use the delgroup command. For example, to remove the users group.

The users group shown in the example as a default group created during the user setup. Removing default groups should be done with caution as it can affect system functionality.

You will be prompted to enter your password to confirm the removal.

Once the group is removed, you can verify it by checking the user's groups again. If the users group is removed, it won't appear in the list.

Setting Up a Shared Folder and Managing Permissions

1. Create the Shared Folder

Open your terminal and run the following command to create a directory named Shared in the /home directory:

2. Create the New User Group

Next, create a new group called newgroup. This group will be used to manage access to the shared folder:

3. Change Ownership of the Shared Folder to the New Group

Now, change the group ownership of the shared folder to newgroup. This ensures that members of newgroup have access to the folder:

Group Membership

You can use cd /home/Shared to navigate directory and verified its permissions.

Explanation of the output:

  • d: indicates that this is a directory.

  • rwxrwxrwx: means that the owner, group, and others have read, write, and execute permissions.

Understanding File Permissions

Absolute (Numeric) Mode

In numeric mode, permissions are represented by an octal (base-8) number. Here’s a table explaining the numeric values and their corresponding permission types.

if a file has the permission 755, it means:

  • The owner has 7 (read, write, execute: rwx)

  • The group has 5 (read, execute: r-x)

  • Others have 5 (read, execute: r-x)

You can set these permissions using the chmod command followed by the numeric value

By following these steps, you've learned how to manage users and groups, verify group memberships, remove groups, and set up a shared folder with the right permissions in Linux.

0
Subscribe to my newsletter

Read articles from Rabiatu Mohammed directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Rabiatu Mohammed
Rabiatu Mohammed

CLOUD ENGINEER | DEVOPS | SECURITY