Linux Permission

Linux Permission

ยท

2 min read

In Linux, file permissions are represented by three sets of permissions for three different categories: "User," "Group," and "Others."

These numeric values help quickly understand the permissions a file or directory has without reading the letters (r, w, x) individually. They are also used in numeric notation for setting permissions, where a single number represents all three permissions.

  1. User: The user who created the file/directory.

  2. Group: A collection of users who share certain privileges.

  3. Others: All remaining users who are not the owner or part of the group.


Changing file permissions

1. Numeric Notation:

Read (r) = 4,

Write (w) = 2,

Execute (x) = 1.

- To set specific permissions, add the corresponding numbers together.

- Example: chmod 400 filename

(User: read+write, Group: read, Others: read)

The sum of these values provides a three-digit number for each category (owner, group, others). For example:

  • Owner: rwx = 4 + 2 + 1 = 7

  • Group: rw- = 4 + 2 + 0 = 6

  • Others: r-- = 4 + 0 + 0 = 4

  1. Read (r): Allows viewing the content of a file or listing the contents of a directory.

  2. Write (w): Permits modifying the content of a file or adding/removing files within a directory.

  3. Execute (x): Grants the ability to execute a file as a program or access a directory's contents

2. Symbolic Notation:

- Use symbols to add (+) or remove (-) permissions.

u for the user/owner,

g for the group,

o for others.

+ to add,

- to remove,

= to set permissions.

- Example: chmod u+x filename (Add execute permission for the owner)

Remember, always use the appropriate permissions to ensure the security and integrity of your files and directories.

Understanding and properly setting file permissions are crucial for maintaining security and controlling access to files and directories on a Linux system.


Thanks for reading to the end; I hope you gained some knowledge.โค๏ธ๐Ÿ™Œ

Vishesh Ghule

ย