SlideShare a Scribd company logo
1 of 27
Download to read offline
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'
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
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
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
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
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
if it is a directory, d would have been shown.
The characters are pretty easy to remember.
• r = read permission
• w = write permission
• x = execute permission
• – = no permission
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
The first part of the code is ‘rw-‘.
This suggests that the owner ‘Home’ can:
• Read the file
• Write or edit the file
• He cannot execute the file since the execute bit is set to ‘-‘.
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
The second part is ‘rw-‘.
It for the user group ‘Home’ and group-members can:
• Read the file
• Write or edit the file
The third part is for the world which means any user.
It says ‘r–‘. This means the user can only:
• Read the file
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
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
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
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
Permissions in binary
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Octal Table
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
binary octal permissions
000 0 ---
001 1 --x
010 2 -w-
011 3 -wx
100 4 r--
101 5 r-x
110 6 rw-
111 7 rwx
777 = rwx rwx rwx
765 = rwx rw- r-x
654 = rw- r-x r--
Examples
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
In the above-given terminal window, we have changed the
permissions of the file ‘sample to ‘764’.
• ‘764’ absolute code says the following:
• Owner can read, write and execute
• Usergroup can read and write
• World can only read
This is shown as ‘-rwxrw-r–
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.
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
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
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
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
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
Linux
Laboratory
-
B.Tech.
6th
CSE
-
Dr.
D.
P.
Mishra,
BIT
Durg
chgrp group_name filename ‘chgrp’ stands for change group.
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
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
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
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
File Access Permission

More Related Content

What's hot

Files in c++ ppt
Files in c++ pptFiles in c++ ppt
Files in c++ ppt
Kumar
 

What's hot (20)

File permissions
File permissionsFile permissions
File permissions
 
Vim Vi Improved
Vim Vi ImprovedVim Vi Improved
Vim Vi Improved
 
Basics of shell programming
Basics of shell programmingBasics of shell programming
Basics of shell programming
 
Module 05 Preprocessor and Macros in C
Module 05 Preprocessor and Macros in CModule 05 Preprocessor and Macros in C
Module 05 Preprocessor and Macros in C
 
Process state in OS
Process state in OSProcess state in OS
Process state in OS
 
Boot process
Boot processBoot process
Boot process
 
Files in c++ ppt
Files in c++ pptFiles in c++ ppt
Files in c++ ppt
 
Unix - Filters
Unix - FiltersUnix - Filters
Unix - Filters
 
Control statements
Control statementsControl statements
Control statements
 
Control structures in c++
Control structures in c++Control structures in c++
Control structures in c++
 
Course 102: Lecture 19: Using Signals
Course 102: Lecture 19: Using Signals Course 102: Lecture 19: Using Signals
Course 102: Lecture 19: Using Signals
 
Intro to Linux Shell Scripting
Intro to Linux Shell ScriptingIntro to Linux Shell Scripting
Intro to Linux Shell Scripting
 
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programming
 
Multiprocessor
MultiprocessorMultiprocessor
Multiprocessor
 
Course 102: Lecture 26: FileSystems in Linux (Part 1)
Course 102: Lecture 26: FileSystems in Linux (Part 1) Course 102: Lecture 26: FileSystems in Linux (Part 1)
Course 102: Lecture 26: FileSystems in Linux (Part 1)
 
Function
FunctionFunction
Function
 
Pointers in c++
Pointers in c++Pointers in c++
Pointers in c++
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
 
Unix shell scripts
Unix shell scriptsUnix shell scripts
Unix shell scripts
 
Type conversion
Type conversionType conversion
Type conversion
 

Similar to File Access Permission

Linux files and file permission
Linux files and file permissionLinux files and file permission
Linux files and file permission
U.P Police
 
Lession1 Linux Preview
Lession1 Linux PreviewLession1 Linux Preview
Lession1 Linux Preview
leminhvuong
 
4_Users_and_File_Permission_and_Directory_Commands
4_Users_and_File_Permission_and_Directory_Commands4_Users_and_File_Permission_and_Directory_Commands
4_Users_and_File_Permission_and_Directory_Commands
Gautam Raja
 
Unit 4 user and group
Unit 4 user and groupUnit 4 user and group
Unit 4 user and group
root_fibo
 
Learning Linux v2.1
Learning Linux v2.1Learning Linux v2.1
Learning Linux v2.1
sdiviney
 
File handling and permisions.pptx
File handling and permisions.pptxFile handling and permisions.pptx
File handling and permisions.pptx
AkampaPhilomena
 
Unix fundamentals
Unix fundamentalsUnix fundamentals
Unix fundamentals
Dima Gomaa
 

Similar to File Access Permission (20)

Linux files and file permission
Linux files and file permissionLinux files and file permission
Linux files and file permission
 
Basic Linux
Basic LinuxBasic Linux
Basic Linux
 
Lession1 Linux Preview
Lession1 Linux PreviewLession1 Linux Preview
Lession1 Linux Preview
 
06 users groups_and_permissions
06 users groups_and_permissions06 users groups_and_permissions
06 users groups_and_permissions
 
FILE PERMISSION OR ACCESS MODE
 FILE PERMISSION OR ACCESS MODE FILE PERMISSION OR ACCESS MODE
FILE PERMISSION OR ACCESS MODE
 
Ai module
Ai module Ai module
Ai module
 
Introduction to linux day3
Introduction to linux day3Introduction to linux day3
Introduction to linux day3
 
4_Users_and_File_Permission_and_Directory_Commands
4_Users_and_File_Permission_and_Directory_Commands4_Users_and_File_Permission_and_Directory_Commands
4_Users_and_File_Permission_and_Directory_Commands
 
OS Unit IV.ppt
OS Unit IV.pptOS Unit IV.ppt
OS Unit IV.ppt
 
Basic Linux day 2
Basic Linux day 2Basic Linux day 2
Basic Linux day 2
 
04-1-Linux.ppt
04-1-Linux.ppt04-1-Linux.ppt
04-1-Linux.ppt
 
Course 102: Lecture 14: Users and Permissions
Course 102: Lecture 14: Users and PermissionsCourse 102: Lecture 14: Users and Permissions
Course 102: Lecture 14: Users and Permissions
 
intro unix/linux 09
intro unix/linux 09intro unix/linux 09
intro unix/linux 09
 
Unit 4 user and group
Unit 4 user and groupUnit 4 user and group
Unit 4 user and group
 
Learning Linux v2.1
Learning Linux v2.1Learning Linux v2.1
Learning Linux v2.1
 
Linux Security
Linux SecurityLinux Security
Linux Security
 
File handling and permisions.pptx
File handling and permisions.pptxFile handling and permisions.pptx
File handling and permisions.pptx
 
Unix fundamentals
Unix fundamentalsUnix fundamentals
Unix fundamentals
 
Linux day 2.ppt
Linux day  2.pptLinux day  2.ppt
Linux day 2.ppt
 
101 4.5 manage file permissions and ownership v3
101 4.5 manage file permissions and ownership v3101 4.5 manage file permissions and ownership v3
101 4.5 manage file permissions and ownership v3
 

More from BIT DURG

Understanding WWW
Understanding WWWUnderstanding WWW
Understanding WWW
BIT DURG
 

More from BIT DURG (20)

HTML_DOM
HTML_DOMHTML_DOM
HTML_DOM
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Understanding WWW
Understanding WWWUnderstanding WWW
Understanding WWW
 
Computer Networks
Computer NetworksComputer Networks
Computer Networks
 
Computer Basics
Computer Basics Computer Basics
Computer Basics
 
ISDN & ATM
ISDN & ATMISDN & ATM
ISDN & ATM
 
Transport Control Protocol
Transport Control ProtocolTransport Control Protocol
Transport Control Protocol
 
Routing Protocols
Routing ProtocolsRouting Protocols
Routing Protocols
 
Internet Protocol.pdf
Internet Protocol.pdfInternet Protocol.pdf
Internet Protocol.pdf
 
Intternetworking With TCP/IP
Intternetworking With TCP/IPIntternetworking With TCP/IP
Intternetworking With TCP/IP
 
Computer Network Basics
Computer Network BasicsComputer Network Basics
Computer Network Basics
 
MySQL
MySQL MySQL
MySQL
 
Types of Linux Shells
Types of Linux Shells Types of Linux Shells
Types of Linux Shells
 
Control flow and related shell cripts
Control flow and related shell criptsControl flow and related shell cripts
Control flow and related shell cripts
 
Basic Shell Programs
Basic Shell ProgramsBasic Shell Programs
Basic Shell Programs
 
Filters & Vi Editor
Filters & Vi EditorFilters & Vi Editor
Filters & Vi Editor
 
Basic Linux Commands
Basic Linux CommandsBasic Linux Commands
Basic Linux Commands
 
Linux Installation
Linux InstallationLinux Installation
Linux Installation
 
Basics of GNU & Linux
Basics of GNU & LinuxBasics of GNU & Linux
Basics of GNU & Linux
 
National youth day
National youth dayNational youth day
National youth day
 

Recently uploaded

VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Dr.Costas Sachpazis
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
Tonystark477637
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
rknatarajan
 

Recently uploaded (20)

Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 

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
  • 6. Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg if it is a directory, d would have been shown. The characters are pretty easy to remember. • r = read permission • w = write permission • x = execute permission • – = no permission
  • 7. Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg The first part of the code is ‘rw-‘. This suggests that the owner ‘Home’ can: • Read the file • Write or edit the file • He cannot execute the file since the execute bit is set to ‘-‘.
  • 8. Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg The second part is ‘rw-‘. It for the user group ‘Home’ and group-members can: • Read the file • Write or edit the file The third part is for the world which means any user. It says ‘r–‘. This means the user can only: • Read the 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
  • 14. Octal Table Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg binary octal permissions 000 0 --- 001 1 --x 010 2 -w- 011 3 -wx 100 4 r-- 101 5 r-x 110 6 rw- 111 7 rwx 777 = rwx rwx rwx 765 = rwx rw- r-x 654 = rw- r-x r--
  • 15. Examples Linux Laboratory - B.Tech. 6th CSE - Dr. D. P. Mishra, BIT Durg In the above-given terminal window, we have changed the permissions of the file ‘sample to ‘764’. • ‘764’ absolute code says the following: • Owner can read, write and execute • Usergroup can read and write • World can only read This is shown as ‘-rwxrw-r–
  • 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