date: mon 18/03/1432

18
1 Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel Date: MON 18/03/1432 Lecture 1 Security & permissions command

Upload: judah-william

Post on 30-Dec-2015

22 views

Category:

Documents


0 download

DESCRIPTION

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 - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Date: MON 18/03/1432

1Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel

Date: MON 18/03/1432

Lecture 1

Security & permissions commands

Page 2: Date: MON 18/03/1432

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

Page 3: Date: MON 18/03/1432

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

Page 4: Date: MON 18/03/1432

Umask(User Mask

Notes:r:readw:writeX:excuteu:userg:groupo:other r=4w=2x=1

Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel4

Page 5: Date: MON 18/03/1432

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

Page 6: Date: MON 18/03/1432

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

Page 7: Date: MON 18/03/1432

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

Page 8: Date: MON 18/03/1432

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

Page 9: Date: MON 18/03/1432

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

Page 10: Date: MON 18/03/1432

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

Page 11: Date: MON 18/03/1432

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

Page 12: Date: MON 18/03/1432

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

Page 13: Date: MON 18/03/1432

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

Page 14: Date: MON 18/03/1432

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

Page 15: Date: MON 18/03/1432

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

Page 16: Date: MON 18/03/1432

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

Page 17: Date: MON 18/03/1432

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

Page 18: Date: MON 18/03/1432

End

Ustaza. Imtithal Alnour Saeed & Ustaza Sana AL-Hwishel 18