CM304
CM304
ANDHRA PRADESH
Name : Gandi Govinda Naidu
Designation : Head of Computer Engg Section
Branch : Computer Engg
Institute : Govt. Polytechnic for Women,
Bheemunipatnam
Year / Semester : III Semester
Subject : UNIX & C
Subject Code : CM-304
Topic : Basics of Unix
Duration : 50 Min
SubTopic : UNIX file protection methods
Teaching Aids : PPT, Animations, Photographs
CM304.8 1
Recap
CM304.8 2
Objectives
CM304.8 3
What is UNIX security?
CM304.8 4
Contd..
What is UNIX security?
c) There are read, write and execute permissions
for each file which decide who can access,
modify and execute a particular file.
CM304.8 5
Contd..
What is UNIX security?
e) A file encryption utility encodes your files into
the crypted format, so that even if someone gets
access to the file, they cannot read it. And only
when you want to read the contents of your file
you can decrypt it.
CM304.8 6
Permissions : r w x of Ordinary files
CM304.8 7
Permissions : r w x of Ordinary files
Contd..
Read permission:
Data can be accessed from the file, but file
contents cannot be changed or erased.
Write permission:
Addition, deletion, appending, insertion of
records or text from a file are permitted.
Execute permission:
Valid only for binary executable files or shell
scripts. These files can be executed like
commands.
CM304.8 8
Directory files
Read permission:
It permits one to read contents of the directory
through ls or other command but does not
permit addition or removal of files or
subdirectories.
Write permission:
It permits one to add or remove files or sub-
directories under the directory.
CM304.8 9
Directory files
Contd..
Execute permission:
It is possible to enter the directory through cd
command and search the directory or sub-
directories under it.
CM304.8 10
UNIX Users
CM304.8 11
UNIX Users
CM304.8 12
File Permissions
You “own” your files and directories
user-group-other read/write permissions
-rw-r--r-- 1 jsmith staff 164870 27 Feb 17:58
6.bmp
-rw-r--r-- 1 jsmith staff 164870 27 Feb 17:57
5.bmp
-rw-r--r-- 1 jsmith staff 164870 27 Feb 17:57
4.5.bmp
-rw-r--r-- 1 jsmith staff 164870 27 Feb 17:57
4.bmp CM304.8 13
File Permissions
CM304.8 14
chown command
CM304.8 15
Contd..
chown command
example:
$ls –l salary
-rw-rw-rw- 1 nag 37 123 jan 14
10:33 salary
$chown jani salary
$ls –l salary
-rw-rw-rw- 1 jani 37 123 jan 14
10:33 salary
now jani has become the owner of the file.
CM304.8 16
Contd..
chown Command
CM304.8 17
The chmod command
CM304.8 19
Contd..
The chmod command
CM304.8 21
chmod Examples
CM304.8 22
Contd..
chmod Examples
Absolute mode:
The absolute format is based on octal numbers
representing the three kinds of access
permission. The octal values for read, write and
execute modes are:
read write execute
4 2 1
CM304.8 23
The command format is
CM304.8 25
The command format is Contd..
CM304.8 26
The command format is Contd..
octal value=700
example
CM304.8 27
Contd..
The command format is
$ls –l salary
-rwxrw-rw- 1 nag 37 123 Jan 14
10:33 salary
$chmod 600 salary
$ls – salary
-rw- - - - - - - 1 nag 37 123 Jan 14
10:33 salary
CM304.8 28
The command format is Contd..
CM304.8 29
The chgrp command
Example:
$pwd
/usr/fac/jani
$ls –ld temp
drwxrwxrwx 1 jani 37 Jan 9 11:20 temp
$chgrp 38 temp
$ls –ld temp
drwxrwxrwx 1 jani 38 Jan 9 11:20 temp
Notice that the ls command given before chgrp
gives 37 as group-id and ls command given after
chgrp gives 38 as group-id.
CM304.8 31
Summary
CM304.8 32
Quiz
(a) root
(b) etc
(c) group
(d) none
CM304.8 33
Quiz
(a) root
(b) etc
(c) group
(d) none
CM304.8 34
Quiz
(a) copy
(b) move
(c) change
(d) protection
CM304.8 35
Quiz
(a) copy
(b) move
(c) change
(d) protection
CM304.8 36
Quiz
3.chown is used by --
(a) enduser
(b) manager
(c) @all
(d) owner
CM304.8 37
Quiz
3.chown is used by --
(a) enduser
(b) manager
(c) @all
(d) owner
CM304.8 38
Frequently asked questions
CM304.8 39