date: mon 18/03/1432
Post on 30-Dec-2015
22 Views
Preview:
DESCRIPTION
TRANSCRIPT
1Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel
Date: MON 18/03/1432
Lecture 1
Security & permissions commands
Umask(User Mask
Umask abbreviation of user maskIs a command to set the file mode creation
mask(Umask) sets the file-creation permissions
Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel 2
Umask(User Mask
Symbolic mask:Umask -Sdisplays the existing default value for new filesFor 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 3
Umask(User Mask
Notes:r:readw:writeX:excuteu:userg:groupo:other r=4w=2x=1
Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel4
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 5
Umask(User Mask
(Umask 022)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-Hwishel6
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 7
Umask(User Mask
umask 0174 mkdir footouch 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-Hwishel8
chmod (change mode)
(chmod) set permissions (modes) of files or directories
Chmod +rwx file-nameTo add read write and execute for all
Chmod -rwx file-nameTo remove read write and execute from all
Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel9
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-Hwishel10
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 11
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-Hwishel12
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 13
chgrp(change group)
(chgrp) changes group associated with file. chgrp group files
Orchgrp -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 14
chgrp(change group)
ls -l fu-rw-r--r-- 1 amani amani 545 Nov 04 2004 fuchgrp work fuls -l fu-rw-r--r-- 1 amani work 545 Nov 04 2004 fu
Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel 15
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 16
chown(change owner)
chown root fuls –l fu-rwxrwx--- 1 root work 0 Sep 27 19:30 fu
Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel 17
End
Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel 18
top related