As part of a security task, I was asked to review and correct the permissions of files and directories within the /home/researcher2/projects directory. This involved checking which users (owner, group, or others) had access to read, write, or execute files, and modifying permissions where needed to follow the principle of least privilege — giving only necessary access to the right people.
I started by using the command:
ls -l
This listed all files in the projects directory along with their current permissions. The permission string format looks like this:-rw-rw-r-- 1 researcher2 research_team ...
The first 10 characters tell you:
If it’s a file (-) or directory (d)
The read/write/execute rights for: user, group, and others
One of the files, project_k.txt, had the following permissions:-rw-rw-rw- This meant others (all users on the system) could write to the file, which is a security risk. I fixed it with:
chmod o-w project_k.txtNow only the user and group can write to it.
The file project_m.txt is considered restricted, and only the user should be able to read or write it. Originally, it had these permissions: -rw-r----- To remove group read access:
chmod g-r project_m.txtNow, only the file owner can read or write the file, which follows the principle of least privilege.
Check for hidden files
I used:
ls -laThis revealed a hidden file named .project_x.txt. Hidden files begin with a dot (.), and ls alone wouldn’t show them.
I changed the permissions of .project_x.txt to allow both the user and group to only read (no writing):
chmod u=r,g=r,o= .project_x.txtThis makes the file readable by user and group, but safe from accidental edits or misuse.
The drafts directory had the following permissions: drwx--x--- This meant the group had execute (x) access — meaning they could enter the directory, which wasn't necessary. The others already had no access, so I only needed to remove execute permission for the group:
chmod g-x draftsThis made the directory accessible only to the user.
The ls -l and ls -la commands are essential for reviewing file permissions and checking for hidden files. The chmod command lets you remove, add, or set permissions for user (u), group (g), and others (o). The principle of least privilege is critical: only give access where it’s needed.

