Gnuru.org
Productive Linux


Subscribe

 Subscribe via Feedburner in a reader

Enter your email address:

Delivered by FeedBurner


Login
Login:
Password:



Don't have an account?
Sign up to Gnuru.org
Forgot your password?

Octal File Permissions
7 May 2004 @ 18:23 BST
by Nomad

Getting file permissions right is essential for administering Linux systems. This is normally done with the [chmod] command. So, for example,

chmod +w

will make a file writable. Power users, though, usually prefer to use [chmod] with octal values. Octal values are numbers based on base 8. They work well with computers because they correspond exactly to three bit binary numbers so, octal 02 (octal numbers are usually written with a leading '0') corresponds to binary 010, and octal 07 corresponds to binary 111.

File permissions on Linux and Unix are usually made up of three values. 'r' allows a user to read the file, 'w' to write it, and 'x' indicates whether they may execute it. Octal numbers can match up exactly, the first bit indicating whether a file is readable, the second whether it is writable and the third whether it is executable.

There are three sets of permissions for files, the first for the author the second for the group and the third for others. So, a typical file permission might be rw-r--r--. This allows the author to read and write a file and group members and others only to read it. This set of permissions corresponds to binary 110100100 and therefore to octal 0644. To set the above file permissions using [chmod], you'd write:

chmod 0644 filename

where 'filename' is the name of the file your working on.

A more restrictive file permission might be binary 110000000 or octal 0600 this allows only the author to read and write the file.

Another example is:

chmod 0750 filename

This allows the file named 'filename' to be read, written and executed by the author, written and executed by members of the group and not accessed at all by anyone

Tags: files



Leave a comment:

Are you human?