Linux: Directories, Users, Groups, and Permissions

Skylar Carter
4 min readMay 24, 2024

--

Things to know:

AWS (Amazon Web Services) Account is a console where you can build, deploy, and manage websites, apps or processes using AWS secured network.

Amazon EC2 (Elastic Compute Cloud) Instance is a widely used AWS service that offers users the ability to run applications on the public cloud. EC2 can be viewed as a virtual server.

Linux is a Unix-like operating system kernel that serves as the core component of many Linux distributions, which are complete operating systems based on the Linux kernel along with other software components.

I will provide an example in which I will create 3 directories. Each directory will have dummy files. Then I will create 3 groups. I will also create 3 users and assign the users to different groups. I will change the ownership of the directories to the perspective group so that each user will only have permission to access files in the group they are assigned. Owners of the groups will have read, write, and execute access. Users will not have access to any files if they are not in 1 of the groups.

Step by Step Tutorial:

Login to linux and create 3 directories by using the mkdir command. The syntax for mkdir followed by the dirctory name. You can create multiple directories by adding a space between directory names. It will look like this.

mkdir Development Operations Analytics
  • This will create 3 directories with the above names and now we can create dummy files in each directory. The touch command allows you to create files. We will access the appropriate directory with the cd (change directory) command. Below is an example to change to the perspective directories.
cd Development
cd Operations
cd Analytics

Once you change to the directory you will be able to use the touch command. Below is an example.

In the Analytics directory
In the Development Directory
In the Operations Directory

Now we have created our dummy files in their perspective directories. Next we will create our groups. The groupadd command allows you to create groups. See examples of the syntax below.

Now that we have created our groups we can assign our directories to their perspective groups. We will assign the Development directory to the Developers group, the Operations directory to the Operations group, Data_Analysts to the Analytics directory. See below.

Now we will create 3 users. See below.

The useradd command allows you to add users. When you add the -s you can specify the user login shell. The -c flag allows you to add comments for the user. This is where you put the user first and last name and email address or additional information. The -G allows you to assign the user to a group. Now we will set a password for each user by using the passwd command. See examples below.

Now we can use the su command and switch to each user and verify access to files. The switch user command allows you to switch users after entering the correct password. Now we have to assign the correct permissions to each file. See below.

Now you are able to switch users and verify access to the appropriate files. Great job!

--

--