180 likes | 324 Views
Lecture 1. Security & permissions commands. Date: MON 18/03/1432. Umask(U ser Mask. Umask abbreviation of u ser mask Is a command to set the file mode creation mask ( Umask ) sets the file-creation permissions. Umask(U ser Mask. Symbolic mask: Umask -S
E N D
Lecture 1 Security & permissions commands Date: MON 18/03/1432 Ustaza. Imtithal Alnour Saeed & UstazaSana AL-Hwishel
Umask(User Mask • Umask abbreviation of user mask • Is a command to set the file mode creation mask • (Umask) sets the file-creation permissions Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel
Umask(User Mask Symbolic mask: Umask -S • displays the existing default value for new files • For example the result of the last command may be like: u=rwx,g=rwx,o=rx • This means creating new files with the mode: -rw-rw-r-- And directories with the mode: Drwxrwxr- x Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel
Umask(User Mask Notes: r:read w:write X:excute u:user g:group o:other • r=4 • w=2 • x=1 Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel
Umask(User Mask Octal mask: • 666 in the case of files, • 777 in the case of directories. • The octal notation is as follows: • 0 – read, write and execute • 1 – read and write • 2 – read and execute • 3 – read only • 4 – write and execute • 5 – write only • 6 – execute only • 7 – no permissions Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel
Umask(User Mask (Umask022) • causes files to be created with permissions of 644 (rw-r--r--) , • and directories to be created with permissions of 755 (rwxr-xr-x Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel
Umask(User Mask • 022 (masking out the write permission for the group and others), which ensures that new files are only writable for the owner (i.e. the user who created them). • Another common value is 002, which leaves the write permission for the file's group enabled. This can be used for files in shared workspaces, where several users work with the same files Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel
Umask(User Mask umask 0174 mkdir foo touch bar ls -l drw-----wx 2 dave dave 512 Sep 1 20:59 foo -rw----w- 1 dave dave 0 Sep 1 20:59 bar Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel
chmod (change mode) • (chmod) set permissions (modes) of files or directories Chmod +rwx file-name To add read write and execute for all Chmod -rwx file-name To remove read write and execute from all Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel
chmod (change mode) • Change mode of MYFILE to -rw-rw-r-- chmod 664 myfile ls -l myfile -rw-rw-r-- 1 57 Jul 3 10:13 myfile Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel
chmod (change mode) • Add the read and write permissions to the user and group classes of a directory: chmod ug+rw mydir ls -ld mydir drw-rw---- 2 unixguy uguys 96 Dec 8 12:53 mydir Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel
chmod (change mode) • remove write permissions for all classes: chmod a-w myfile ls -l myfile -r-xr-xr-x 2 unixguy uguys 96 Dec 8 12:53 myfile Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel
chmod (change mode) • Set the permissions for the user and the group to read and execute only (no write permission) on mydir: chmod ug=rx mydir ls -ld mydir dr-xr-x--- 2 unixguy uguys 96 Dec 8 12:53 mydir Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel
chgrp(change group) • (chgrp) changes group associated with file. chgrpgroupfiles Or chgrp -R group files . Note: Can be used to change the group associated with subdirectories and files of a directory. Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel
chgrp(change group) ls -l fu -rw-r--r-- 1 amani amani 545 Nov 04 2004 fu chgrp workfu ls -l fu -rw-r--r-- 1 amani work 545 Nov 04 2004 fu Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel
chown(change owner) • chown - changes ownership of a file. (chown userid files ) or: • chown -R userid files Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel
chown(change owner) chown root fu ls –l fu -rwxrwx--- 1 root work 0 Sep 27 19:30 fu Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel
End Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel