Chmod useful to give limited access (security) a file or directory, so not all users can read, write or execute (except root).
And it's also useful to change the permissions on a file or directory.
File and directory permissions are divided into three kinds of access :
READ (r) : read a file or directory.
WRITE (w) : write and create a file or directory.
EXECUTE (x) : executing a file or entering a directory.
For example, we create a file tr45h.txt in /home/cr45h using touch commands (create a empty file).
By the user the file can not be read (r), written (w) and executable (x) .
By the group can be read (r) and written (w).
But, by the other only can be read (r)
To make the licenses there are two methods, letter method and number method.
LETTER METHOD
Imperative :
#chmod [ugoa] [= + -] [rwx] [the name of file or directory]
u : user
g : group
o : other
a : all
= : set as the only license held
+ : add permission
- : disable a permission
r : read access
w : write access
x : execute access
The steps are :
$cd /home/cr45h
$touch tr45h.txt
$chmod u+rxw, g+rw, o+r tr45h.txt
To see the results, run the command :
$ls -l /home/cr45h/tr45h.txt
-r w x r w -r - - 1 cr45h users 0 2013-04-10
5:53 tr45h.txt
Other group user
NUMBER METHOD
Imperative :
#chmod [number of license] [file or directory]
4 : read (r)
2 : write (w)
1 : execute (x)
Because the user will be given access to read (4). write (2) and execute (1), then the licenses are 4+2+1=7
Group read (4) and write (2), then the licenses are 4+2=6
Other read (4), then the license is 4
So, the command is like this :
#chmod 764 tr45h.txt
0 comments:
Post a Comment