To change directory permissions in a Unix-like operating system, you can use the chmod command. Here’s how it works:
Basic Syntax:
chmod [options] mode directory_name
Common Modes:
- Numeric Mode: Use numbers to set permissions.
7: Read, write, and execute (rwx)6: Read and write (rw-)5: Read and execute (r-x)4: Read only (r--)3: Write and execute (wx-)2: Write only (w--)1: Execute only (x--)0: No permissions (---)
Example:
To set the permissions of a directory named mydir to read, write, and execute for the owner, and read and execute for the group and others, you would use:
chmod 755 mydir
Symbolic Mode:
You can also use symbolic notation:
u: User (owner)g: Groupo: Othersa: All (user, group, others)
To add execute permission for the group:
chmod g+x mydir
Recursively Change Permissions:
To change permissions for a directory and all its contents, use the -R option:
chmod -R 755 mydir
Feel free to ask if you need more details or examples!
