How to use chmod

Posted on January 10th, 2009

Chmod is a command used to change file permissions. Given the right permissions, you can restrict or grant access to a file for specific groups or users. Here’s the basic format:

“chmod 755 myfile.txt”

A file can have the following permissions corresponding to these numbers:

Read = 4
Write = 2
Execute = 1

In order to combine permissions, you just have to add the numbers together (ie, READ & WRITE permission is a 6). A file has to give these permissions to three groups of people. For example, each digit in the “755″ of the chmod command above represents one of these groups:

Left-most Digit    = Owner
Middle Digit         = The file’s group
Right-most Digit = All other users

so in the command above, we gave the owner read, write, and execute permissions; the group of the file got read and execute permissions; and all other users got execute permissions.

Hope that helps.

Leave a reply