Introduction
Linux permissions decide who can read, change, or execute files. RHCSA tasks commonly require you to inspect permission strings, set numeric and symbolic modes, change ownership, and configure directories so files are usable by the intended group.
In this lab, you will work directly inside /home/labex/project. You will inspect prepared files, apply standard file modes with chmod, enable a script safely, take ownership of a root-owned handoff file, and configure a setgid shared directory.
Inspect File Permission Fields
In this step, you will inspect permissions before changing them. The first field in ls -l output shows file type and permissions; the owner and group fields show who controls the file.
Move into the standard LabEx project directory.
cd /home/labex/project
List the prepared lab tree.
ls -l permissions-lab
Inspect the prepared configuration files. The mode, owner, and group are visible in the long listing.
ls -l permissions-lab/configs
Use stat for a compact view of one file. %a prints the numeric mode, %U prints the owner name, and %G prints the group name.
stat -c '%n %a %U %G' permissions-lab/configs/private.conf
Inspect the root-owned handoff file. Notice that the owner and group are currently root.
ls -l permissions-lab/shared/handoff.txt
Set File Modes with Numeric chmod
In this step, you will use numeric modes with chmod. The three digits describe user, group, and other permissions. For example, 600 means user read/write only, and 644 means user read/write while group and others can read.
Start from the project directory.
cd /home/labex/project
Make private.conf readable and writable only by its owner. This is appropriate for a file that contains sensitive settings.
chmod 600 permissions-lab/configs/private.conf
Make readme.txt readable by everyone but writable only by the owner.
chmod 644 permissions-lab/configs/readme.txt
Inspect the modes with stat.
stat -c '%n %a' permissions-lab/configs/private.conf permissions-lab/configs/readme.txt
You should see 600 for private.conf and 644 for readme.txt.
Enable Script Execution with Symbolic chmod
In this step, you will use symbolic permissions. Symbolic mode lets you add or remove a specific permission without rewriting the entire numeric mode.
Start from the project directory.
cd /home/labex/project
Inspect the script before changing it. It should be readable but not executable.
ls -l permissions-lab/scripts/check-inventory.sh
Add execute permission for the owner and group. In u+x,g+x, u means user, g means group, and +x means add execute permission.
chmod u+x,g+x permissions-lab/scripts/check-inventory.sh
Run the script from its path.
permissions-lab/scripts/check-inventory.sh
Expected output:
inventory check ok
Inspect the final mode. It should now include execute bits for user and group.
stat -c '%n %a' permissions-lab/scripts/check-inventory.sh
Change Ownership of a Handoff File
In this step, you will take ownership of a root-owned file using sudo chown. Changing ownership usually requires administrative privilege, so sudo is appropriate for this practice file.
Start from the project directory.
cd /home/labex/project
Inspect the current owner and group. The file starts as root:root.
stat -c '%n %U:%G %a' permissions-lab/shared/handoff.txt
Change the owner and group to labex:labex. The user:group form sets both fields in one command.
sudo chown labex:labex permissions-lab/shared/handoff.txt
Restrict the file to owner read/write and group read access.
chmod 640 permissions-lab/shared/handoff.txt
Append one operational line now that labex owns the file.
printf 'Handled by labex after ownership update.\n' >> permissions-lab/shared/handoff.txt
Inspect the final owner, group, mode, and content.
stat -c '%n %U:%G %a' permissions-lab/shared/handoff.txt
cat permissions-lab/shared/handoff.txt
Configure a Shared Directory with setgid
In this step, you will configure a shared directory. Directories need execute permission to enter and search them. The setgid bit on a directory makes new files inherit the directory group, which helps teams keep shared content grouped consistently.
Start from the project directory.
cd /home/labex/project
Inspect the current directory mode.
stat -c '%n %a %U:%G' permissions-lab/teamdrop
Set the directory mode to 2775. The leading 2 enables setgid, 775 gives full access to owner and group, and gives read/execute access to others.
chmod 2775 permissions-lab/teamdrop
Create a file inside the shared directory.
printf 'team handoff ready\n' > permissions-lab/teamdrop/status.txt
Set the file mode so owner and group can read and write it.
chmod 664 permissions-lab/teamdrop/status.txt
Inspect the directory and new file.
stat -c '%n %a %U:%G' permissions-lab/teamdrop permissions-lab/teamdrop/status.txt
cat permissions-lab/teamdrop/status.txt
Summary
You practiced standard Linux permissions and ownership for RHCSA preparation. You inspected permission fields, applied numeric file modes, used symbolic chmod to enable script execution, changed ownership with sudo chown, set secure file modes, and configured a setgid shared directory so new files inherit the intended group.



