File Permissions In Red Hat
Permission :
Permission has give in to two type.
We are showing symbolic method.
Read = r |
user = u |
add = + |
Write = w |
group = g |
remove = - |
Execute = x |
other = o |
replace = (=) |
Note : By defaults file do not has execute permission
View the permission by #ls-l
Command
#touch /root/Desktop/xyz
#ls –l /root/Desktop/xyz
- 1> is show file or directory.(file = -, dir = d)
- 2> user has read, write permission.
- 3> group has read permission.
- 4> other has read permission.
How to change the permission in red hat?
Command
#chmod u+rwx /root/Desktop/xyz (execute file color is green )
#ls –l /root/Desktop/xyz
-rwx r - - r - - 2 root root --------- xyz
How to replace the permission in red hat?.
Command
#chmod g=rw /root/Desktop/xyz
#ls –l /root/Desktop/xyz
-rwxrw- r - - 2 root root --------- xyz
How to remove the permission in red hat?
Command
#chmod g-rw,o-r /root/Desktop/xyz
#ls –l /root/Desktop/xyz
-rwx--- --- 2 root root --------- xyz
Numeric permission :
We have the three permission.
NO |
Read 2*2 |
Write 2*1 |
Execute 2*0 |
0 |
0 |
0 |
0 |
1 |
0 |
0 |
1 |
2 |
0 |
1 |
0 |
3 |
0 |
1 |
1 |
4 |
1 |
0 |
0 |
5 |
1 |
0 |
1 |
6 |
1 |
1 |
0 |
7 |
1 |
1 |
1 |
Command
#touch /root/Desktop/pqr
#ls –l /root/Desktop/pqr
- rw- r-- r-- 2 root root --------- pqr
#chmod 777 /root/Desktop/pqr
#ls –l /root/Desktop/pqr
-rwx rwr rwx 2 root root --------- pqr
#chmod 000 /root/Desktop/pqr
#ls –l /root/Desktop/pqr
--- --- --- 2 root root ------------- pqr
#chmod 472 /root/Desktop/pqr
#ls –l /root/Desktop/pqr
- r– - rwx –w- 2 root root -------- pqr
What is umask?
It is also related with permission.
Umask is used to display permission or set file creation mask permission applied to newly created file or directory.
Umask is set in two mode
1>> temporary mode
How to set temporary umask in red hat?
Command
#umask <umasknumber>
How to check umask?
Note : Reboot the pc then gate original umask.
2>> Permeated mode
Command
#echo “umask 077” >> /root/.bashrc
We also user vim editor for permeated umask.add “umask 077” it last line. In this file.
If you check current umask, then fallow the command.