Understanding File & Folder Permissions - Tech Support
In this comprehensive guide, we will discuss file and folder permissions in detail, with a specific focus on protecting files and folders from deletion, renaming, or modification by users, including the owner or an admin (admin privileges are ideally kept for admin abilities only).
File Permissions
To manage file permissions, Linux and Unix-based systems use the chmod command and provide three types of access: read (r), write (w), and execute (x).
Here's an example for changing file permissions:
$ chmod 755
The permission code 755 has the following structure:
owner: = 4 + 2 + 1 = 7
group: = 4 + 0 + 1 = 5
others: = 4 + 0 + 1 = 5
The above command grants the owner full permissions allowing admin abilities while providing read and execute access for the group and others.
Folder Permissions
Folder permissions are similar to file permissions, but the execute permission behaves differently. Here's a table explaining folder permission behavior:
| Permission | Behavior |
|---|---|
| Read (r) | List files (contents) of a folder |
| Write (w) | Create, modify or delete files inside a folder |
| Execute (x) | Navigate inside a folder or execute files within it |
Preventing Deletion and Renaming by Users
To prevent users from deleting or renaming files or folders, the write permission must be denied for the users group. However, it is impossible to do this for the owner (or admin) as they need write access to manage files effectively.
Consider the following command:
$ chmod 555
This command provides read and execute permissions to the owner, group, and others. However, it removes write permissions.
Note:
- Even with the above permissions, an admin can still delete files and folders due to the ownership.
- This method should be applied to sensitive files or folders requiring a higher level of security and preventing accidental modifications.
Recommended Resources
- Book: "Linux Command Line Bible" by Rich Bowen
- Article: "File Permissions and What They Mean" by MTE
- Online Resource: "Learn Linux Permissions - User, Group, and Other" by DigitalOcean