What are other chmod options?

0115

The chmod command has several options for changing file permissions. Here are some commonly used options:

  1. Add Permissions:

    • +r: Add read permission.
    • +w: Add write permission.
    • +x: Add execute permission.

    Example:

    chmod +r file.txt  # Adds read permission to file.txt
  2. Remove Permissions:

    • -r: Remove read permission.
    • -w: Remove write permission.
    • -x: Remove execute permission.

    Example:

    chmod -x script.sh  # Removes execute permission from script.sh
  3. Set Exact Permissions:
    You can set permissions explicitly using numeric values:

    • 0: No permission
    • 1: Execute
    • 2: Write
    • 4: Read

    You can combine these values for user, group, and others. For example:

    • chmod 755 file.txt: Sets read, write, and execute for the owner, and read and execute for group and others.
    • chmod 644 file.txt: Sets read and write for the owner, and read for group and others.
  4. Recursive Change:
    Use the -R option to change permissions recursively for directories and their contents.

    chmod -R 755 directory_name  # Changes permissions for all files and subdirectories
  5. Symbolic Mode:
    You can specify permissions using symbolic notation:

    • u: User (owner)
    • g: Group
    • o: Others
    • a: All (user, group, and others)

    Example:

    chmod u+x file.txt  # Adds execute permission for the user
    chmod go-w file.txt  # Removes write permission for group and others

These options allow you to customize file permissions according to your needs.

0 Comments

no data
Be the first to share your comment!