Read = r = 4
Write = w = 2
Execute = x = 1
There are three types that can get to a file if you allow them to, The Owner, The Group, and Everyone.
So let's assume myfile.cgi requires the owner, to be able to do everything (read it, write to it, and execute it), and requires the group (people/machines with the same access as the owner) to be able to read it and execute it but we do not want them to write to it, and requires the same permissions that the group has given to everyone else.
User = rwx or 7 (since 4 + 2 + 1 = 7)
Group = r-x or 5 (since 4 + 0 + 1 =
5)
All = r-x or 5 (since 4 + 0 + 1 = 5)
The above equals chmod 755 or chmod u=rwx,go=rx
When you realize that setting the permissions on a script to mode 777 means you are giving yourself and the group and EVERYONE else permission to do things to your file, it's easy to see why mode 777 is not always a wise idea.
Default modes if you upload a file to the server and change nothing are:
r | read the file or directory |
w | write to the file or directory |
x | execute the file or search the directory |
Each of these permissions can be set for any one of three types of user:
u | the user who owns the file (usually you) |
g | members of the group to which the owner belongs |
o | all other users |
The access permissions for all three types of user can be given as a string of nine characters:
user | group | others |
r w x | r w x | r w x |
Permission | File | Directory |
r read | read a file | list files in ... |
w write | write a file | create file in ... rename file in ... delete file ... |
x execute | execute a shell script |
read a file in ... write to a file in ... execute a file in ... execute a shell script in ... |
There is a shorthand way of setting permissions by using octal numbers. Read permission is given the value 4, write permission the value 2 and execute permission 1.
r | w | x |
4 | 2 | 1 |
These values are added together for any one-user category:
1 | = | execute only |
2 | = | write only |
3 | = | write and execute (1+2) |
4 | = | read only |
5 | = | read and execute (4+1) |
6 | = | read and write (4+2) |
7 | = | read and write and execute (4+2+1) |
So access permissions can be expressed as three digits. For example:
user | group | others | |
chmod 640 file1 | rw- | r-- | --- |
chmod 754 file1 | rwx | r-x | r-- |
chmod 664 file1 | rw- | rw- | r-- |
Read = r = 4
Write = w = 2
Execute = x = 1
There are three types that can get to a file if you allow them to, The Owner, The Group, and Everyone.
So let's assume myfile.cgi requires the owner, to be able to do everything (read it, write to it, and execute it), and requires the group (people/machines with the same access as the owner) to be able to read it and execute it but we do not want them to write to it, and requires the same permissions that the group has given to everyone else.
User = rwx or 7 (since 4 + 2 + 1 = 7)
Group = r-x or 5 (since 4 + 0 + 1 =
5)
All = r-x or 5 (since 4 + 0 + 1 = 5)
The above equals chmod 755 or chmod u=rwx,go=rx
When you realize that setting the permissions on a script to mode 777 means you are giving yourself and the group and EVERYONE else permission to do things to your file, it's easy to see why mode 777 is not always a wise idea.
Default modes if you upload a file to the server and change nothing are:
r | read the file or directory |
w | write to the file or directory |
x | execute the file or search the directory |
Each of these permissions can be set for any one of three types of user:
u | the user who owns the file (usually you) |
g | members of the group to which the owner belongs |
o | all other users |
The access permissions for all three types of user can be given as a string of nine characters:
user | group | others |
r w x | r w x | r w x |
Permission | File | Directory |
r read | read a file | list files in ... |
w write | write a file | create file in ... rename file in ... delete file ... |
x execute | execute a shell script |
read a file in ... write to a file in ... execute a file in ... execute a shell script in ... |
There is a shorthand way of setting permissions by using octal numbers. Read permission is given the value 4, write permission the value 2 and execute permission 1.
r | w | x |
4 | 2 | 1 |
These values are added together for any one-user category:
1 | = | execute only |
2 | = | write only |
3 | = | write and execute (1+2) |
4 | = | read only |
5 | = | read and execute (4+1) |
6 | = | read and write (4+2) |
7 | = | read and write and execute (4+2+1) |
So access permissions can be expressed as three digits. For example:
user | group | others | |
chmod 640 file1 | rw- | r-- | --- |
chmod 754 file1 | rwx | r-x | r-- |
chmod 664 file1 | rw- | rw- | r-- |
Read = r = 4
Write = w = 2
Execute = x = 1
There are three types that can get to a file if you allow them to, The Owner, The Group, and Everyone.
So let's assume myfile.cgi requires the owner, to be able to do everything (read it, write to it, and execute it), and requires the group (people/machines with the same access as the owner) to be able to read it and execute it but we do not want them to write to it, and requires the same permissions that the group has given to everyone else.
User = rwx or 7 (since 4 + 2 + 1 = 7)
Group = r-x or 5 (since 4 + 0 + 1 =
5)
All = r-x or 5 (since 4 + 0 + 1 = 5)
The above equals chmod 755 or chmod u=rwx,go=rx
When you realize that setting the permissions on a script to mode 777 means you are giving yourself and the group and EVERYONE else permission to do things to your file, it's easy to see why mode 777 is not always a wise idea.
Default modes if you upload a file to the server and change nothing are:
r | read the file or directory |
w | write to the file or directory |
x | execute the file or search the directory |
Each of these permissions can be set for any one of three types of user:
u | the user who owns the file (usually you) |
g | members of the group to which the owner belongs |
o | all other users |
The access permissions for all three types of user can be given as a string of nine characters:
user | group | others |
r w x | r w x | r w x |
Permission | File | Directory |
r read | read a file | list files in ... |
w write | write a file | create file in ... rename file in ... delete file ... |
x execute | execute a shell script |
read a file in ... write to a file in ... execute a file in ... execute a shell script in ... |
There is a shorthand way of setting permissions by using octal numbers. Read permission is given the value 4, write permission the value 2 and execute permission 1.
r | w | x |
4 | 2 | 1 |
These values are added together for any one-user category:
1 | = | execute only |
2 | = | write only |
3 | = | write and execute (1+2) |
4 | = | read only |
5 | = | read and execute (4+1) |
6 | = | read and write (4+2) |
7 | = | read and write and execute (4+2+1) |
So access permissions can be expressed as three digits. For example:
user | group | others | |
chmod 640 file1 | rw- | r-- | --- |
chmod 754 file1 | rwx | r-x | r-- |
chmod 664 file1 | rw- | rw- | r-- |