SYS‐255 Linux File Permissions - aljimenez28/champlain GitHub Wiki
Objective
Gain hands-on experience creating Linux users, groups, and directories, then applying file and directory permissions to control access.
Key Notes
ls -ld /accounting/displays the long listing of the directory itself, showing owner, group, and their permissions.>>is the append operator, which adds text to the end of a file without overwriting existing content.
Steps Performed
- Elevate to root
sudo -i
Opens a root shell for administrative commands.
-
Create users
useradd bob passwd bob useradd alice useradd charlieAdds three new users and sets a password for Bob.
-
Inspect home directories and user database
ls /home ls -ld /home ls -ld /home/alice ls -l /etc/passwdLists user home directories and checks
/etc/passwdto confirm user creation. -
Add users to the accounting group
usermod -aG accounting alice usermod -aG accounting bobAppends Alice and Bob to the accounting group without removing existing group memberships.
-
Create the accounting directory
mkdir /accountingMakes the shared directory that will hold accounting files.
-
Switch to Alice to create a test file
su - alice echo alice > alice.txt cat alice.txt ls -lLogs in as Alice, creates a file, displays its contents, and lists details.
-
Verify directory ownership and group settings
ls -ld /accounting/Shows current permissions for
/accounting. -
Change group ownership of the directory
chgrp accounting /accountingAssigns the accounting group to the directory so group members can manage it.
-
Create a file inside accounting
echo "alice file" > /accounting/alicefile.txtCreates a file owned by Alice inside the shared directory.
-
Secure the directory
chmod o-rwx /accounting/Removes all permissions for others, restricting access to only the owner and accounting group.
-
Confirm current user and groups
idDisplays user identity and group memberships for verification.
Summary
This lab demonstrated how to:
- Create and manage users and groups.
- Control directory and file access using
chgrpandchmod. - Verify permissions with
ls -landid. By carefully setting group ownership and restricting “others,” only the intended team members can read or modify sensitive files.