How to use chmod in linux



  1. user (u), 
  2. group (g), 
  3. other (o)
  4. all (a) 


The permission

  1. r for read, 
  2. w for write and 
  3. x for execute

For example: Change mode a file as below, that group has not write, execute permission, the other is too

chmod go-wx filename


Example 1: The file should have read, write and execute permissions to user, read and execute permissions to group and read, and execute permissions to others.

read, write and execute permissions to user =7

read and execute permissions to group =5

read and execute permissions to others=5

So total permissions will be 755

chmod 755 filename


Example 2: Providing write access to a user

chmod u+w filename

Example 3: Adding write permissions to a group

chmod g+w filename


Example 4: Adding executable permissions to others

chmod o+x filename


Example 5: Adding executable and write permissions to all

chmod a+wx filename


Example 6: Replicating user permissions to a group

chmod u=g filename


Example 7: Removing execute permissions to a user

Chmod u-x filename


Example 8: Adding execute permissions to others

Chmod o+x






Ref: https://www.linuxnix.com/chmod-command-explained-linuxunix/

Comments

Popular posts from this blog

Fixing the DeepSpeed Import Error While Fine-Tuning the Qwen Model

Amazon Linux 2023 - User data configuration for launch templates to connect to the EKS cluster

How to create ISM policy and rotate logs in opensearch