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.
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
Directories have directory permissions. The directory permissions restrict different actions than with files or device nodes.
(view contents, i.e. ls command)
(create or remove files from dir)
(cd into directory)
Usage: chmod {options} filename
Options
Definition
u
g
o
a
all (same as ugo)
x
w
r
+
add permission
-
remove permission
=
set permission
example:
chmod u+x file1
#--
-#-
--#
1
2
4
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 & execute
4+2=6
4+2+1=7
Example
user@host:/home/user$ chmod 667 filename