Unix File Permissions – An Introduction

Topic Basics

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

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 :

-R is used to recursively change the content of directory as well
* denotes everything in current directory
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…

16 comments… add one

  • Prakash

    Thanks for this explaination.
    Helped me a lot !!

  • Ryan

    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!

  • Raymon

    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.

  • Smith

    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. . . . . .

  • Saleem

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

  • Monty

    Thanks for this informative web site.

  • Mike

    Super-Duper website! I am loving it!! Will be back later to read some more.

  • Allegro

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

  • Puakzarve

    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.

  • Jamal

    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.

  • Kyle

    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!

  • Roderick

    Very good article.

  • Roy

    Thanks again for the post. Fantastic

  • Kody

    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!

  • Matt

    Fantastic!

  • Edee

    “Thanks a lot for the post. Much obliged.”

Leave a Comment