9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
File Access Permission
1. Dr. D. P.
Mishra
Digitally signed by Dr. D. P.
Mishra
DN: cn=Dr. D. P. Mishra, o=durg,
ou=BIT,
email=dpmishra@bitdurg.ac.in,
c=IN
Date: 2023.03.20 13:20:44 +05'30'
2. File access permission
• In Unix-like operating systems such as Linux, file access permissions
are used to determine who can access a file and what actions they can
perform on it.
• There are three types of access permissions:
• read (r),
• write (w), and
• execute (x).
• These permissions can be set for three groups of users:
• the file owner,
• the group owner, and
• others.
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
3. FAP
• The access permissions for a file can be viewed using the ls -l
command,
• It displays the file permissions as a string of ten characters.
• The first character indicates the type of file (e.g., "-" for a regular file,
"d" for a directory),
• and the next three characters indicate the owner's permissions,
• the following three indicate the group's permissions, and the
• final three indicate the permissions for others.
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
5. Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Let’s see file permissions in Linux with examples:
Type ls – l on terminal gives
$ ls - l
Here, we have highlighted ‘-rw-rw-r–‘and this is permissions given to the owner, user group and the world.
Here, the first ‘–‘ implies that we have selected a file
9. Changing FAP with chmod
• Say you do not want your colleague to see your personal images.
• This can be achieved by changing file permissions.
• We can use the ‘chmod’ command which stands for ‘change mode’.
• Using the command, we can set permissions (read, write, execute) on
a file/directory for the owner, group and the world.
Syntax: chmod permissions filename
There are 2 ways to use the command
1. Absolute mode
2. Symbolic mode
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
10. Absolute(Numeric) Mode in Linux
• In this mode, file permissions
are not represented as
characters but a three-digit octal
number.
• The table below gives numbers
for all for permissions types.
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Number Permission Type Symbol
0 No Permission —
1 Execute –x
2 Write -w-
3 Execute + Write -wx
4 Read r–
5 Read + Execute r-x
6 Read +Write rw-
7
Read + Write
+Execute
rwx
11. Permission in numeric mode
• The above way of changing permissions will work fine but you may
also need to know how to change permissions in numeric mode.
• chmod is used in much the same way
• instead of r, w, or x you will use numbers.
• What are the numbers?
• 0 = No Permission
• 1 = Execute
• 2 = Write
• 4 = Read
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
12. The various owners are represented as –
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
User Denotations
u user/owner
g group
o other
a all
16. Symbolic Mode in Linux
• In the Absolute mode, you
change permissions for all 3
owners.
• In the symbolic mode, you can
modify permissions of a
specific owner.
• It makes use of mathematical
symbols to modify the Unix file
permissions.
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Operator Description
+
Adds a permission to a file
or directory
– Removes the permission
=
Sets the permission and
overrides the permissions
set earlier.
17. Examples
• chmod 777 workfolder
• Will give read, write, and execute permissions for everyone.
• chmod 700 workfolder Will give read, write, and execute permission
for the user, but nothing to everyone else.
• chmod 327 workfolder Will give write and execute (3) permission for
the user, w (2) for the group, and (7) read, write, and execute for other
users.
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
18. Task
1. create 3 files with touch command: files1, files2, files3.
2. Write the command line by using letters with chmod to set the
following permissions:
- rwxrwxr-x for file1
- r-x—x—x for file2
- ——xrwx for file3
3. Write the command line by using numbers with chmod to set the
following permissions:
- rwxrwxrwx for file4 (you have to prepare this file)
- -w------- for file5 (you have to prepare this file)
- rwx--x—x for folder1 (you have to prepare this folder)
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
19. We will not be using permissions in numbers like 755 but
characters like rwx. Let’s look into an example
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
20. FAP ..
• For changing the ownership of a file/directory, you can use the
following command:
$ chown user filename
In case you want to change the user as well as group for a file or
directory use the command
$ chown user:group filename
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
23. Examples.
1. Change the file permissions to read, write, and execute for the owner, and
only read for others:
chmod 755 myfile.txt
2. Change the file permissions to read and write for the owner, and read
only for others:
chmod 644 myfile.txt
3. Add execute permission for the owner of the file:
chmod +x myfile.txt
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
24. Examples..
4. Remove write permission for others from a file:
chmod o-w myfile.txt
5. Change the ownership of a file to a specific user:
chown username myfile.txt
6. Change the ownership of a file to a specific user and group:
chown username:groupname myfile.txt
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
25. Examples…
4. Remove write permission for others from a file:
chmod o-w myfile.txt
5. Change the ownership of a file to a specific user:
chown username myfile.txt
6. Change the ownership of a file to a specific user and group:
chown username:groupname myfile.txt
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
26. FAP Summary
• Linux being a multi-user system uses permissions and ownership for
security.
• There are three user types on a Linux system viz. User, Group and Other
• Linux divides the file permissions into read, write and execute denoted by
r,w, and x
• The permissions on a file can be changed by ‘chmod’ command which can
be further divided into Absolute and Symbolic mode
• The ‘chown’ command can change the ownership of a file/directory. Use the
following commands: chown user file or chown user:group file
• The ‘chgrp’ command can change the group ownership chrgrp group
filename
• What does x – eXecuting a directory mean? A: Being allowed to “enter” a dir
and gain possible access to sub-dirs.
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg