Chmod Calculator for Linux File Permission

Chmod Calculator for Linux File Permission

Use this online tool to convert the file permission for the owner, group and public to the numeric value and symbolic notation. You can use these converted notations to know or to change the file permission using chmod Linux command.


Do you want to learn how to calculate the file permission values? You should be familiar with the ownership, permission, notations and basic Linux commands. We will see them one-by-one. In the later part, I will describe you to calculate Linux file permission.

Let’s dive in.

Ownership

There are three types of ownership for each file in the Linux.

  1. User– One who owns the file. By default, the user who creates the file becomes the owner of the file.
  2. Group– The owner can create the group and assign the file permission to the file. One can simply add any user to the group to access the file.
  3. Other– All the users apart from the owner and group members, become part of the other.

You can set the different file permissions for different types of ownership.

Permissions

Each file or directory has three permissions or mode of accessing it.

  1. Read mode (r)– Read mode gives you permission to read the file.
  2. Write mode (w)– Write mode gives you permission to write and update the file.
  3. Execute mode (x)– Execute mode gives the ability to execute the file.

[Example] How to Calculate Linux File Permission?

Calculate Linux File Permission Example

For sake of simplicity and to calculate the numeric value for file permission, consider

r=4 (2^2)
w=2 (2^1)
x=2 (2^0)
-=0

By adding them, you get the numeric value for file permission.

For example:

rwx = 4+2+1 = 7
r-x = 4+0+1 = 5

You can use symbolic as well as numeric mode for getting and setting file and directory permission in Linux.

How to get the file permission in Linux?

Use ls command:

 ls -l <file_name>

If you don’t provide the file name, it list out all the files and directories in the current directory.

ls -l

Sample output for the ls command:

Linux command to read file permission

You can see the symbolic notation with prefix ‘-‘ or ‘d’.

  • The prefix ‘-‘ in symbolic notation represents a file.
  • The prefix ‘d’ in symbolic notation represents a directory.

ls and chmod are two very useful Linux commands.

How to set the file permission using Linux chmod command?

Use chmod command:

chmod <numeric_mode> <file_name>

It is convenient to use numeric mode value for setting up the file permission.

Leave a Reply

Your email address will not be published. Required fields are marked *