Linux command: chmod
Choose who can use a file
A file can be private, shared with a group, or open to other users. The chmod command changes the rules that decide who can read a file, change it, or run it. Linux keeps those rules in three groups: the owner, the file's group, and everyone else. Directory rules also decide who may list names, add or remove entries, or pass through that folder to reach an item inside it.
Use ls -l path or stat path to look at the current rules. In -rw-r-----, the first - marks a regular file. The owner can read and write it, the group can read it, and other users have no access. A leading d marks a directory; it is a file-type character, not a permission bit.
Set the rules with numbers or letters
The numeric form uses octal digits. In the usual three-digit form, the first digit sets owner access, the second group access, and the third access for others. Read has value 4, write 2, and execute 1; add values to combine permissions. For example, 640 gives the owner read and write, the group read, and others no permissions. Apply it to one file with:
chmod 640 ./report.txt
Symbolic modes name the class and the change. chmod u+x ./run-me adds execute permission for the owner. chmod go-rwx ./private.txt removes all permissions for the group and others. The class letters u, g, o, and a mean owner, group, other, and all. The operators +, -, and = add, remove, or set the named bits. Symbolic modes help change one rule while leaving unrelated bits alone.
On a directory, read permission lets a user list names and write permits name changes, subject to other checks. Execute means search: the user can traverse the directory when resolving a path. Making a file executable does not give search permission on its parent directories. Linux checks each directory in the path separately.
Check what changed
After changing a mode, inspect it again with ls -l or stat. Recursive chmod -R changes every matching object below the starting directory. Use it only when that scope is intended; it can remove execute bits needed on directories or change access to private files. GNU chmod follows a symbolic link given on the command line and changes the target's mode. A symbolic link's own mode bits generally do not control access. Check the local manual when portability matters.
Mode bits do not explain every denial. A group's permission applies to users in that group; someone outside it does not receive the group access. An access-control list (ACL) can add named-user or named-group entries, and its mask can reduce their effective permissions. getfacl shows those entries. chmod changes modes; chown changes ownership. If access still fails, inspect the path, ACL, and account the program uses before widening permissions.







