How to Set File and Directory Permissions using CHMOD

Must Read

Four Things You Most Likely Didn’t Know About Guest Post Service

Guest Posting is a great way to raise awareness and build links. However, before starting a guest...

How Does Blogger Outreach Help Your Brand Grow?

Bloggers are eager to promote their content and engage their readers, so building relationships with them are...

How To Get Your Startup Noticed

Being an entrepreneur is always a learning experience. That's because the rules are constantly changing. The change...

Privacy and personal space are two important things when it comes to interaction between humans. The level of these two parameters varies among person to person. We all have person(s) in our life to whom we share our private matters with, a group to which we hangout and others, to whom we would like to keep a distance and show some positive attitude. This is one among things which makes us feel human. Like this, it is important that we set some sort of curtailment to our files in the computer system. That is where I would like to introduce the CHMOD command comes into play.

https://goo.gl/photos/3y8Fy3B4EYLEiMWv8

chmod calculator

In simple words, CHMOD is a command used on Linus or Unix based systems to set file and directory access permissions. Why CHMOD? With the help of CHMOD command we can define which users can access the file and how can they access it. Let me show you how CHMOD works using a simple example.

How CHMOD works

To start, this is how the command syntax will look like;

chmod options permissions file name

We start by writing the ‘chmod’ and then options, you can specify list of users and their permissions under options, permissions are read, write and execute. Finally, the name of the file.

The type of people to whom we are going to assign permissions are generally classified into three; user (u), group (g) and others (o). Permissions can be specified by using letters read (r), write (w) and execute (x). You can also use octal numbers (0 to 7), this will be explained later.

Here is another example;

Let’s say my file name is helloworld. I want the following permissions to be set for the users;

  • I can read, write and execute the file. I mean, the user (u) can read (r), write (w) and execute (x).
  • Members of the group (g) can only read (r) and execute (x)
  • Finally, for others (o) only read (r) permission is allotted.

My command will look like;

chmod u=rwx,g=rx,o=r helloworld

In the above command; chmod is used to specify we are going to change mode. u, g, o represents user, group and others respectively. w, r, x represents write, read, execute permissions.

Octal Representation

Instead of writing the letters, octal representation of permissions is the widely-used command. To begin with;

  • The octal value for read is 4
  • Write is 2
  • Execute is 1
  • and, for no permission the octal value is 0

So, if you say 7 it means read, write and execute. How? Well, 7 is a combination of (4+2+1). You can create lot of combinations using 4,2,1 and 0. Some example combinations are;

Remember, if you say;

chmod 754 helloworld

The digits 7,5 and 4 represents permission for the user, group and others respectively. 7 is 4+2+1 means (read, write and execute) permission for the user. 5 is 4+0+1 means (read, no write and execute) permission for the group members and 4 is 4+0+0 means (read, no write, no execute) for others.

Extra chmod command options

Apart from the standard options read, write and execute, there are lot many command options which can be used along with chmod.

  • Verbose – outputs a diagnostic for every file processed
  • Changes – outputs a file whenever there is a change
  • Silent – to ignore the error messages
  • And more;

chmod calculator

If you are like me, definitely you would have searched for chmod generator online. Well, the folks at chmodcommand.com has made an amazing calculator which will generate the chmod command as per your selection of options. I find this really interesting and easy to use.

Chmod is a great command which always comes in handy especially, when you are dealing with sensitive information. It will only take a few minutes to get used to all the commands and then in no time you will be an expert in the same.

- Advertisement -

Latest News

Four Things You Most Likely Didn’t Know About Guest Post Service

Guest Posting is a great way to raise awareness and build links. However, before starting a guest...

How Does Blogger Outreach Help Your Brand Grow?

Bloggers are eager to promote their content and engage their readers, so building relationships with them are essential to growing your brand....

How To Get Your Startup Noticed

Being an entrepreneur is always a learning experience. That's because the rules are constantly changing. The change happens so subtly that you...

The Benefits of Treemapping for Data Analysis

Treemapping is a great tool for data analysis because it allows you to see the big picture and the details at the...

Tips for driving more traffic to your engineering blog

Over the last two decades, blogging has transformed from being a somewhat hobbyist pursuit to a fully-fledged sector of the internet that...

More Articles Like This

- Advertisement -