How to change directory permissions?

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 : group
    • o : others
    • r : read
    • w : write
    • x : execute

Example Commands

  1. Add Execute Permission for Everyone:

    chmod +x directory_name
  2. Remove Write Permission for Group:

    chmod g-w directory_name
  3. 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.

0 Comments

no data
Be the first to share your comment!