To change directory permissions in Unix-like systems, you can use the chmod command, similar to changing file permissions. Here’s how to do it:
Basic Syntax
chmod [options] mode directory
Common Options
+: Adds a permission-: Removes a permission=: Sets the permission and overrides existing ones
Modes
You can specify permissions using:
- Symbolic notation:
u: user (owner)g: groupo: othersr: readw: writex: execute
Example Commands
-
Add Execute Permission for Everyone:
chmod +x directory_name -
Remove Write Permission for Group:
chmod g-w directory_name -
Set Permissions to Read, Write, and Execute for User, and Read and Execute for Group and Others:
chmod 755 directory_name
Recursive Changes
To change permissions for a directory and all its contents, use the -R option:
chmod -R 755 directory_name
This command sets the specified permissions for the directory and all files and subdirectories within it.
