- Lab
- A Cloud Guru
Working with Linux Directory Permissions
In this lab, we'll be working with directory permissions on a Linux host. We'll start by creating some groups and directories, and then set up permissions to only allow each group to access its own directory.
Path Info
Table of Contents
-
Challenge
Create user groups.
-
There are four groups to be created:
- accounting
- engineering
- management
- hr
-
Use the
sudo groupadd -g #### [groupname]
command:sudo groupadd -g 1111 accounting
sudo groupadd -g 2222 engineering
sudo groupadd -g 3333 management
sudo groupadd -g 4444 hr
-
-
Challenge
Create directories.
- There are four directories to be created:
- accounting
- engineering
- management
- hr
- Create each group using the
sudo mkdir /directoryname
command:sudo mkdir /accounting
sudo mkdir /engineering
sudo mkdir /management
sudo mkdir /hr
- There are four directories to be created:
-
Challenge
Add each of the newly created directories to its associated group.
- Use the command
sudo chgrp groupname /directoryname
to add each of the newly created directories to its associated group:sudo chgrp accounting /accounting
sudo chgrp engineering /engineering
sudo chgrp management /management
sudo chgrp hr /hr
- Use the command
-
Challenge
Set group permissions on each of the newly created directories.
- For each of the newly created directories, use the command
sudo chmod g+rwx /directoryname
to give the group owner read, write, and execute permissions to the directory:sudo chmod g+rwx /accounting
sudo chmod g+rwx /engineering
sudo chmod g+rwx /management
sudo chmod g+rwx /hr
- For each of the newly created directories, use the command
-
Challenge
Prevent non-group members from accessing files.
- In order to prevent other non-group members from reading and executing files in each of the newly created directories, use
sudo chmod o-rx /directoryname
command:sudo chmod o-rx /accounting
sudo chmod o-rx /engineering
sudo chmod o-rx /management
sudo chmod o-rx /hr
- In order to prevent other non-group members from reading and executing files in each of the newly created directories, use
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.