Unix File Permissions – An Introduction

Everything in Unix is considered to be a file, including physical devices such as USB devices, floppy drives, DVD-ROMs, etc.

Every file or directory is uniquely identified by its name, the directory in which it resides and a unique identifier, usually called an inode.

Unix File Permissions

There are several types of files available in Unix, each file type is different from another and have different purpose to serve.

Symbol

 File Type

 Represent a regular file in Unix/Linux.

d

 Represent a directory in Unix/Linux.

l

 Represent a symbolic link. Please note that with symbolic links, the remaining file attributes are always rwxrwxrwx and are dummy values.

c

 Represent a character special file. This file type refers to a device that handles data as a stream of  bytes, such as a terminal or modem.

s

 Represent a socket special file used for inter process communication. These allow communication between two processes.

b

 Represent a block special file. This file type refers to a device that handles data in blocks, such as a hard drive or CD-ROM drive.

Unix File Permissions

For every unix file or directory, mostly there are three kinds of permissions

     r   –   read    => Read/view the file

     w   –   write   => create, edit or delete              

     x   –   execute => run a script/program or enter a directory

There are three levels which defines who can access the file

     u   –    user  => owner of the file

     g   –    group => a bunch of people in the same project

     o   –    other => everyone on the system

Let’s take an example of the output of “ls -lt” command to explain the file permission

 -rwxr-xr-x 1 root quest 3743 Apr 30 2012 server.sh

File_Permissions

Setting up the file permissions

To setup the file permissions we can use “chmod” command, but first we should understand the meaning of different permissions

Symbolic Notation

Octal Notation

Meaning

———-

0000

no permissions
—x–x–x

0111

execute
–w–w–w-

0222

write
–wx-wx-wx

0333

write & execute
-r–r–r–

0444

read
-r-xr-xr-x

0555

read & execute
-rw-rw-rw-

0666

read & write
-rwxrwxrwx

0777

read, write, & execute

The number and letter represents :

Read      ==      r     ==     4

Write     ==     w    ==     2

Execute ==     x     ==     1

You can use chmod command in different ways :

Symbolic Example

Numeric

Explanation

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

chmod 775

       For world executables file/directory

 chmod u=rwx,g=rx,o=

chmod 750

       For read, executables by group only

 chmod u=rw,g=r,o=r

chmod 644

       For world readable file/directory
 chmod u=rw,g=r,o=

chmod 640

       For group readable file/directory
 chmod u=rw,go=

chmod 600

       For user readable file/directory
 chmod u=rwx,go=

chmod 700

       For user executables only

Examples :

chmod 755 file_name

-rwxr-xr-x    1      root   quest   3743   Apr  30  2012      file_name
chmod –R 755 directory_name

-rwxr-xr-x    1      root   quest   3743   Apr  30  2012      directory_name

-R is used to recursively change the content of directory as well

chmod 755 *

-rwxr-xr-x    1      root   quest   3743   Apr  30  2012      file_name

-rwxr-xr-x    1      root   quest   3743   Apr  30  2012      file1_name

-rwxr-xr-x    1      root   quest   3743   Apr  30  2012      file2_name

* denotes everything in current directory

chmod 777 file_name

-rwxrwxrwx     1     root   quest   3743   Apr  30  2012      file_name

Detailed description about chmod command can be found at wiki

This article is just to explain the Unix File System, We will cover several basic/advanced Unix commands in our next article.

So, till then please be tuned and enjoy reading…

20 thoughts on “Unix File Permissions – An Introduction”

  1. Wow, marvelous blog structure! How long have you been blogging for?
    you made running a blog glance easy. The total glance of your site is excellent, let alone the content!

  2. I’m so happy to read this. This is the kind of manual that needs to be given and not the random misinformation that’s at the other blogs. Appreciate your sharing this best doc.

  3. Hey very nice blog!! Guy .. Excellent .. Amazing .. I will bookmark your site. I am satisfied to search out so many useful info right here within the put up, we want work out more techniques in this regard, thank you for sharing. . . . . .

  4. Your means of explaining everything in this paragraph is really good, every one be capable of without difficulty understand it, Thanks a lot.

  5. Thank you a bunch for sharing this with all people you actually understand what you’re talking about! Bookmarked.

  6. Generally I don’t learn article on blogs, however I wish to say that this write-up very pressured me to try and do so! Your writing style has been surprised me. Thank you, quite great article.

  7. Very well written article. It will be beneficial to anybody who utilizes it, including me. Keep doing what you are doing – can’r wait to read more posts.

  8. I’m still learning from you, but I’m trying to reach my goals. I certainly liked reading everything that is written on your website.Keep the aarticles coming. I liked it!

  9. This is really interesting, You’re a very skilled blogger. I look forward to seeking more of your fantastic post. Also, I have shared your website in my social networks!

  10. Hello very nice site!! Man .. Excellent .. Amazing ..
    I will bookmark your site and take the feeds additionally?
    I am satisfied to find a lot of useful info
    here within the publish, we want develop extra strategies on this
    regard, thank you for sharing. . . . . .

Leave a Reply to Edee Cancel Reply

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

Scroll to Top
Scroll to Top