Monday, June 18, 2012

Linux File Permissions



The "umask" command can be used to read or set default file permissions for the current user.
root> umask 022
The umask value is subtracted from the default permissions (666) to give the final permission.
666 : Default permission
022 : - umask value
644 : final permission
The "chmod" command is used to alter file permissions after the file has been created.
root> chmod 777 *.log

Owner      Group      World      Permission
=========  =========  =========  ======================
7 (u+rwx)  7 (g+rwx)  7 (o+rwx)  read + write + execute
6 (u+wx)   6 (g+wx)   6 (o+wx)   write + execute
5 (u+Rx)   5 (g+Rx)   5 (o+Rx)   read + execute
4 (u+r)    4 (g+r)    4 (o+r)    read only
2 (u+w)    2 (g+w)    2 (o+w)    write only
1 (u+x)    1 (g+x)    1 (o+x)    execute only
Character eqivalents can be used in the chmod command.
root> chmod o+rwx *.log
root> chmod g+r   *.log
root> chmod -Rx   *.log
The "chown" command is used to reset the ownership of files after creation.
root> chown -R oinstall.dba *
The "-R" flag causes the command ro recurse through any subdirectories.

No comments: