How to change existing directory permissions?

To change the permissions of an existing directory, you can use the chmod command. The chmod command allows you to modify the permissions for the owner, group, and others.

Syntax

chmod <permissions> <directory_name>

Example

  1. Using Numeric Mode:

    To set the permissions of a directory named mydir to 755, you would use:

    chmod 755 mydir
    

    This gives the owner read, write, and execute permissions, while the group and others get read and execute permissions.

  2. Using Symbolic Mode:

    You can also use symbolic notation to change permissions. For example, to add execute permission for the group on mydir, you would use:

    chmod g+x mydir
    

    To remove write permission for others, you would use:

    chmod o-w mydir
    

Checking Permissions

To verify the changes, you can use the ls -ld command:

ls -ld mydir

This will display the current permissions of the directory.

0 Comments

no data
Be the first to share your comment!