Published May 18th, 2007 by admin

Linux Commands - Permissions

This is Part 3 in a multi-part series. You can also view Part 1 and Part 2.

In Linux, more so than Windows, everything deals with and listens to file ownership and permissions. If a directory is set for only root access, only root can access it.

To change it to be any other way you must be root (or sudo).

Lets do just that. First let’s create a directory in the root called test:

sudo mkdir /test

and then:

sudo chown root test

This changes the owner of the test directory to root. Now if you try:

touch /test/test.txt

It will fail with a ‘permission denied’ error. That is because you are not root and root owns the directory.


Lets grab the group ownership of the directory for all users with:

sudo chgrp users test

We still can’t create a file inside (touch /test/test.txt) because by default the ‘group’ permissions on the directory only allow the access of files, not write capabilities. Let’s change that:

sudo chmod 775 test

This will allow both the owner and the group owner of the directory to read and write files while leaving all others with read only access.

The 755 is the confusing part to many. To break it down is rather simple. The first digit (7) is the access level of the owner of the file/directory. The second digit (7) is the access level of the group owner of the file and the last digit (5) is the access level for everyone else.

The breakdown of the numbers and their values is below:

no permissions — 0
execute only –x 1
write only -w- 2
write and execute -wx 3
read only r– 4
read and execute r-x 5
read and write rw- 6
read, write and execute rwx 7

r = read access

w = write access

x = execute access

That’s pretty much it. It is rather simple once you know how it works. Now you can secure all your directories and folders from the prying eyes of other users on your computer!

Technorati Tags: , , , ,


0 Responses to “Linux Commands - Permissions”

Feed for this Entry Trackback Address
  1. No Comments

Leave a Reply

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Related Posts from the Past: