0% found this document useful (0 votes)
9 views30 pages

Understanding chmod File Permissions

Uploaded by

logithaa
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views30 pages

Understanding chmod File Permissions

Uploaded by

logithaa
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

• We have three categories and three permissions for each category, so

three octal digits can describe a file’s permissions completely. The most
significant digit represents user and the least one represents others.
chmod can use this three-digit string as the expression.
• Using relative permission, we have, chmod a+rw xstart
• Using absolute permission, we have, chmod 666 xstart
• chmod 644 xstart
• chmod 761 xstart
• will assign all permissions to the owner, read and write permissions for the
group and only execute permission to the others.
• To give yourself and your group members full access, you use:
chmod 770 participants
• If you want to keep full access for yourself, but want to keep other people
from modifying the file, you can use:
• chmod 755 participants
• Use option -R to change the permission recursively as shown below.

chmod -R 755 directory-name/


• 777 signify all permissions for all categories, but still we can prevent a file
from being deleted.
• 000 signifies absence of all permissions for all categories, but still we can
delete a file. It is the directory
The chmod Commands:
The text shows two ways of removing all permissions from the file:
(a) Using symbolic mode:
chmod u-rw,go-r xstart
•u-rw → remove read & write from the user (owner).
•go-r → remove read from group and others.
•After this, nobody has any permission.
b) Using numeric (absolute) mode:
•(

•chmod 000 xstart


•000 means:
•Owner: 0 → no permissions.
•Group: 0 → no permissions.
•Others: 0 → no permissions.
•Same result as above: no one can read, write, or execute the file.
1. Normal chmod vs Recursive chmod
•Normally, chmod only changes the permission of a single file or directory.
•With -R (recursive), chmod goes down into all subdirectories and applies the same permission change to every file and directory it finds.

Usage in Home Directory

chmod -R 755 .
Applies permission 755 (rwxr-xr-x) to the current directory (.) and all its contents.

Works on hidden files (like .bashrc, .git, etc.) too.


• chmod -R a+x *
• Applies execute permission to all visible files/directories in the current
folder.
• Hidden files (starting with .) are skipped.

The difference between . and *:


•. → includes everything in the directory (including hidden files).
•* → includes only visible files (hidden ones excluded).
Directory Permissions
• It is possible that a file cannot be accessed even though it has read
permission, and can be removed even when it is write protected. The
default permissions of a directory are,
By default, new directories should be 755 (rwxr-xr-x). This ensures only the owner can write, while group and others can only read/enter. If group/others have w, your files are at risk even if file permissions look correct

• Even if individual files inside seem protected, the


directory permissions would allow tampering.
The shell
rm chap*

→ It will delete all files starting with chap (dangerous!).

To only delete the literal file chap*, use escaping:

rm chap\*

You might also like