To change permissions of a file or directory later in Linux, you can use the chmod command. Here’s how to do it:
Using chmod
-
Numeric Method: You can specify permissions using numeric (octal) values.
chmod 755 filenameThis sets the permissions to
rwxr-xr-x. -
Symbolic Method: You can also use symbolic notation to add or remove permissions.
- Add permissions: Use
+ - Remove permissions: Use
- - Set exact permissions: Use
=
Examples:
- To add execute permission for the owner:
chmod u+x filename - To remove write permission for the group:
chmod g-w filename - To set permissions to read and write for the owner only:
chmod u=rw,go= filename
- Add permissions: Use
Summary
The chmod command is flexible and allows you to change permissions either numerically or symbolically. If you have more questions or need examples, feel free to ask!
