In Linux and Unix, everything is a file. Directories are files, files are files and devices are files.

Devices are usually referred to as a node; however, they are still files.

All of the files on a system have permissions that allow or prevent others from viewing, modifying or executing. If the file is of type Directory then it restricts different actions than files and device nodes. The superuser "root" has the ability to access any file on the system. Each file has access restrictions with permissions, user restrictions with owner/group association. Permissions are referred to as bits.

 

ls -l shows three separate pieces of information on the first column:

The very first letter is either d or - where d stands for a directory and - means it's not a directory, therefore, a plain file(windows definition of file).

Then you would see something like the following:

-rw-r--r--

owner = Read & Write (rw-)
group = Read (r--)
other = Read (r--)

other just means everyone else in here.

Permission Numeric Value Meaning
r 4 Read
w 2 Write
x 1 Execute
- 0 No Permission
 

There are three types of access restrictions:

Permission

Action

chmod option

read

(view)

r or 4

write

(edit)

w or 2

execute

(execute)

x or 1

 

There are also three types of user restrictions:

 

User

ls output

owner

-rwx------

group

----rwx---

other

-------rwx

 

Folder/Directory Permissions

Directories have directory permissions. The directory permissions restrict different actions than with files or device nodes.

 

Permission

Action

chmod option

read

(view contents, i.e. ls command)

r or 4

write

(create or remove files from dir)

w or 2

execute

(cd into directory)

x or 1

 

Changing Permissions:

chmod with Letters

Usage: chmod {options} filename

Options

Definition

u

owner

g

group

o

other

a

all (same as ugo)

x

execute

w

write

r

read

+

add permission

-

remove permission

=

set permission

 

example:

chmod u+x file1

chmod with Numbers

 

 

Usage: chmod {options} filename

Options

Definition

#--

owner

-#-

group

--#

other

1

execute

2

write

4

read

Owner, Group and Other is represented by three numbers. To get the value for the options determine the type of access needed for the file then add.

For example if you want a file that has -rw-rw-rwx permissions you will use the following:

Owner

Group

Other

read & write

read & write

read, write & execute

4+2=6

4+2=6

4+2+1=7

Example

user@host:/home/user$ chmod 667 filename