SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Downloaden Sie, um offline zu lesen
Chapter 2Chapter 2
File PermissionFile Permission
Ref. Pge. 194
Listing a file permissionListing a file permission
●
ls -l 1.txtls -l 1.txt
-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt
File TypeFile Type
-- : Regular File: Regular File
ASCII textASCII text
executableexecutable
datadata
dd : Directory: Directory
ll : Symbolic Link: Symbolic Link
cc : Character Device: Character Device
bb : Block Device: Block Device
ss : Socket: Socket
pp : Named Pipe(FIFO): Named Pipe(FIFO)
-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt
Permission ModePermission Mode
rw-r--r--rw-r--r--
rw-rw- : owner permission: owner permission
r--r--: group permission: group permission
r--r--: others permission: others permission
-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt
Link CounterLink Counter
11 :: Only one name for this fileOnly one name for this file
-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt
OwnershipOwnership
kennykenny :: user(owner) nameuser(owner) name
usersusers :: group namegroup name
-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt
File SizeFile Size
4141 :: 41 bytes41 bytes
-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt
Time StampTime Stamp
Jan 25 07:53Jan 25 07:53 : Modification time: Modification time
-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt
File NameFile Name
1.txt1.txt : File Name: File Name
-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt
Permission DeterminationPermission Determination
1st:1st: u (owner):u (owner):
While the UID matches the owner,While the UID matches the owner,
using theusing the first THREE characters.first THREE characters.
2nd:2nd: g (group):g (group):
WWhile one of the GID(s) matches the group,hile one of the GID(s) matches the group,
using the middle THREE characters.using the middle THREE characters.
3rd:3rd: o (others)o (others)
Neither of above,Neither of above,
using the last THREE characters.using the last THREE characters.
-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt
Permission DeterminationPermission Determination
rr : read: read
ww : write: write
xx : execute: execute
-- : off: off
Meaning of PermissionMeaning of Permission
rr ww xx
FileFile
Can read theCan read the
content ofcontent of
file.file.
Can modifyCan modify
the contentthe content
of file.of file.
Can run theCan run the
program orprogram or
script.script.
DirectoryDirectory
Can list fileCan list file
names innames in
directory.directory.
Can create,Can create,
delete, anddelete, and
rename filesrename files
in directory.in directory.
Can accessCan access
into theinto the
directory.directory.
Ref. Pge. 197
Permission ModePermission Mode
●
Binary mode:Binary mode:
9 bits9 bits: 110100100: 110100100
11 : on: on
00 : off: off
Permission ModePermission Mode
●
Text mode:Text mode:
9 characters : rw-r--r--9 characters : rw-r--r--
1 :1 : rwxrwx
0 :0 : --
Permission ModePermission Mode
●
Octal mode:Octal mode:
3 digits3 digits : 644: 644
OctalOctal ValueValue TextText
0 0 00 0 0
0 0 10 0 1
0 1 00 1 0
0 1 10 1 1
1 0 01 0 0
1 0 11 0 1
1 1 01 1 0
1 1 11 1 1
00
11
22
33
44
55
66
77
­­­­­­
­­x­­x
­w­­w­
­wx­wx
r­­r­­
r­xr­x
rw­rw­
rwxrwx
Ref. Pge. 196
Changing Permission ModeChanging Permission Mode
●
Octal mode:Octal mode:
chmod 644 1.txtchmod 644 1.txt
Ref. Pge. 199
Changing Permission ModeChanging Permission Mode
●
Text mode:Text mode:
chmod u=rw,go=r 1.txtchmod u=rw,go=r 1.txt
WhomWhom HowHow WhatWhat
uu
gg
oo
aa
++
--
==
rr
ww
xx
Special PermissionSpecial Permission
Ref. Pge. 197
SUIDSUID
(100)(100)
SGIDSGID
(010)(010)
Sticky BitSticky Bit
(001)(001)
FileFile
(binary only)(binary only)
The process UIDThe process UID
will not get fromwill not get from
user, it inheritsuser, it inherits
from the file'sfrom the file's
owner instead.owner instead.
The process GIDThe process GID
will not get fromwill not get from
user's group, butuser's group, but
from the group offrom the group of
file.file.
--
DirectoryDirectory --
Any new file or subAny new file or sub
directory will getdirectory will get
the same group asthe same group as
directory. New subdirectory. New sub
directory inheritsdirectory inherits
the SGID as well.the SGID as well.
Only root andOnly root and
the owner ofthe owner of
file orfile or
directory anddirectory and
remove file inremove file in
directory.directory.
Changing Special PermissionChanging Special Permission
●
Octal mode:Octal mode:
chmod <Nnnn> filechmod <Nnnn> file
Text mode:Text mode:
chmod [ug][+-][s] filechmod [ug][+-][s] file
chmod o[+-]t filechmod o[+-]t file
Ref. Pge. 193
Determination ofDetermination of
Special PermissionSpecial Permission
        rwxrws­­Trwxrws­­T
  011111111000 011111111000 
( 6  7  7  0 )( 6  7  7  0 )
[st] : replace x[st] : replace x
[ST] : replace -[ST] : replace -
Ref. Pge. 193
Changing OwnershipChanging Ownership
●
Changing a File's Owner:Changing a File's Owner:
chown alex 1.txtchown alex 1.txt
●
Requirement:Requirement:
●
root onlyroot only
Ref. Pge. 193
Changing OwnershipChanging Ownership
●
Changing a File's Group:Changing a File's Group:
chown :group1 1.txtchown :group1 1.txt
chgrp group1 1.txtchgrp group1 1.txt
●
Requirement:Requirement:
●
root, orroot, or
●
file owner, must belongs to the target groupfile owner, must belongs to the target group
Changing OwnershipChanging Ownership
●
Changing both Owner and Group:Changing both Owner and Group:
chown alex:group1 1.txtchown alex:group1 1.txt
●
Requirement:Requirement:
●
root onlyroot only
Default PermissionDefault Permission
●
Default permission for new file:Default permission for new file:
06660666
●
Default permission for new directory:Default permission for new directory:
07770777
Ref. Pge. 202
Changing Default PermissionChanging Default Permission
●
Using theUsing the umaskumask command:command:
umaskumask : list the current umask value: list the current umask value
umask nnnumask nnn : change the umask value: change the umask value
Meaning of umask valueMeaning of umask value
●
To remove specified permissionTo remove specified permission
from default:from default:
file default:file default: 000 110 110 110000 110 110 110
mask value:mask value: 000 000 010 010000 000 010 010
file result:file result: 000 110 100 100000 110 100 100
11 : removed: removed
00 : unchanged: unchanged
dir result:dir result: 000 111 101 101000 111 101 101

Weitere ähnliche Inhalte

Was ist angesagt?

101 3.3 perform basic file management
101 3.3 perform basic file management101 3.3 perform basic file management
101 3.3 perform basic file management
Acácio Oliveira
 
101 2.1 design hard disk layout
101 2.1 design hard disk layout101 2.1 design hard disk layout
101 2.1 design hard disk layout
Acácio Oliveira
 
101 4.3 control mounting and unmounting of filesystems
101 4.3 control mounting and unmounting of filesystems101 4.3 control mounting and unmounting of filesystems
101 4.3 control mounting and unmounting of filesystems
Acácio Oliveira
 
101 2.4 use debian package management
101 2.4 use debian package management101 2.4 use debian package management
101 2.4 use debian package management
Acácio Oliveira
 
Some basic unix commands
Some basic unix commandsSome basic unix commands
Some basic unix commands
aaj_sarkar06
 

Was ist angesagt? (20)

Rpm Introduction
Rpm IntroductionRpm Introduction
Rpm Introduction
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 
Linux basics and commands - from lynxbee.com
Linux basics and commands - from lynxbee.comLinux basics and commands - from lynxbee.com
Linux basics and commands - from lynxbee.com
 
Encoding errors
Encoding errorsEncoding errors
Encoding errors
 
4.1 create partitions and filesystems
4.1 create partitions and filesystems4.1 create partitions and filesystems
4.1 create partitions and filesystems
 
101 3.3 perform basic file management
101 3.3 perform basic file management101 3.3 perform basic file management
101 3.3 perform basic file management
 
3.3 perform basic file management
3.3 perform basic file management3.3 perform basic file management
3.3 perform basic file management
 
101 2.1 design hard disk layout
101 2.1 design hard disk layout101 2.1 design hard disk layout
101 2.1 design hard disk layout
 
101 3.3 perform basic file management
101 3.3 perform basic file management101 3.3 perform basic file management
101 3.3 perform basic file management
 
101 3.3 perform basic file management
101 3.3 perform basic file management101 3.3 perform basic file management
101 3.3 perform basic file management
 
1.2 boot the system v2
1.2 boot the system v21.2 boot the system v2
1.2 boot the system v2
 
Linux_commands
Linux_commandsLinux_commands
Linux_commands
 
101 2.1 design hard disk layout v2
101 2.1 design hard disk layout v2101 2.1 design hard disk layout v2
101 2.1 design hard disk layout v2
 
101 4.1 create partitions and filesystems
101 4.1 create partitions and filesystems101 4.1 create partitions and filesystems
101 4.1 create partitions and filesystems
 
Raj linux
Raj linux Raj linux
Raj linux
 
Linux training
Linux trainingLinux training
Linux training
 
Ha opensuse
Ha opensuseHa opensuse
Ha opensuse
 
101 4.3 control mounting and unmounting of filesystems
101 4.3 control mounting and unmounting of filesystems101 4.3 control mounting and unmounting of filesystems
101 4.3 control mounting and unmounting of filesystems
 
101 2.4 use debian package management
101 2.4 use debian package management101 2.4 use debian package management
101 2.4 use debian package management
 
Some basic unix commands
Some basic unix commandsSome basic unix commands
Some basic unix commands
 

Andere mochten auch

Using Selenium to Test Native Apps (Wait, you can do that?)
Using Selenium to Test Native Apps (Wait, you can do that?)Using Selenium to Test Native Apps (Wait, you can do that?)
Using Selenium to Test Native Apps (Wait, you can do that?)
Sauce Labs
 
Ras pioverview
Ras pioverviewRas pioverview
Ras pioverview
Alec Clews
 

Andere mochten auch (20)

Linux network monitoring hands-on pratice
Linux network monitoring hands-on praticeLinux network monitoring hands-on pratice
Linux network monitoring hands-on pratice
 
Linux fundamental - Chap 13 account management
Linux fundamental - Chap 13 account managementLinux fundamental - Chap 13 account management
Linux fundamental - Chap 13 account management
 
Linux fundamental - Chap 05 filter
Linux fundamental - Chap 05 filterLinux fundamental - Chap 05 filter
Linux fundamental - Chap 05 filter
 
Linux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkgLinux fundamental - Chap 09 pkg
Linux fundamental - Chap 09 pkg
 
Importance of linux system fundamental in technical documentation reading
Importance of linux system fundamental in technical documentation readingImportance of linux system fundamental in technical documentation reading
Importance of linux system fundamental in technical documentation reading
 
Docker on Windows
Docker on WindowsDocker on Windows
Docker on Windows
 
Windows7 Vs Linux
Windows7 Vs LinuxWindows7 Vs Linux
Windows7 Vs Linux
 
Linux fundamental - Chap 08 proc
Linux fundamental - Chap 08 procLinux fundamental - Chap 08 proc
Linux fundamental - Chap 08 proc
 
Linux CLI
Linux CLILinux CLI
Linux CLI
 
The linux command line for total beginners
The linux command line  for total beginnersThe linux command line  for total beginners
The linux command line for total beginners
 
Linux fundamental - Chap 06 regx
Linux fundamental - Chap 06 regxLinux fundamental - Chap 06 regx
Linux fundamental - Chap 06 regx
 
Using Selenium to Test Native Apps (Wait, you can do that?)
Using Selenium to Test Native Apps (Wait, you can do that?)Using Selenium to Test Native Apps (Wait, you can do that?)
Using Selenium to Test Native Apps (Wait, you can do that?)
 
Linux fundamental - Chap 07 vi
Linux fundamental - Chap 07 viLinux fundamental - Chap 07 vi
Linux fundamental - Chap 07 vi
 
Unix tutorial-08
Unix tutorial-08Unix tutorial-08
Unix tutorial-08
 
Linux pipe & redirection
Linux pipe & redirectionLinux pipe & redirection
Linux pipe & redirection
 
Chap 18 net
Chap 18 netChap 18 net
Chap 18 net
 
Linux fundamental - Chap 16 System Rescue
Linux fundamental - Chap 16 System RescueLinux fundamental - Chap 16 System Rescue
Linux fundamental - Chap 16 System Rescue
 
Ras pioverview
Ras pioverviewRas pioverview
Ras pioverview
 
Chap 17 advfs
Chap 17 advfsChap 17 advfs
Chap 17 advfs
 
Basics of-linux
Basics of-linuxBasics of-linux
Basics of-linux
 

Ähnlich wie Linux fundamental - Chap 02 perm

Unix fundamentals
Unix fundamentalsUnix fundamentals
Unix fundamentals
Dima Gomaa
 
Lession1 Linux Preview
Lession1 Linux PreviewLession1 Linux Preview
Lession1 Linux Preview
leminhvuong
 
Advanced file permissions in linux
Advanced file permissions in linuxAdvanced file permissions in linux
Advanced file permissions in linux
Mohit Singh
 
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
 

Ähnlich wie Linux fundamental - Chap 02 perm (20)

FILE PERMISSION OR ACCESS MODE
 FILE PERMISSION OR ACCESS MODE FILE PERMISSION OR ACCESS MODE
FILE PERMISSION OR ACCESS MODE
 
Unix fundamentals
Unix fundamentalsUnix fundamentals
Unix fundamentals
 
Basic Linux
Basic LinuxBasic Linux
Basic Linux
 
Lession1 Linux Preview
Lession1 Linux PreviewLession1 Linux Preview
Lession1 Linux Preview
 
Linux
LinuxLinux
Linux
 
File permission in Linux
File permission in LinuxFile permission in Linux
File permission in Linux
 
012-File-And-Directory-Permissions-Explained.pdf
012-File-And-Directory-Permissions-Explained.pdf012-File-And-Directory-Permissions-Explained.pdf
012-File-And-Directory-Permissions-Explained.pdf
 
Special permission in linux.
Special permission in linux.Special permission in linux.
Special permission in linux.
 
Advanced file permissions in linux
Advanced file permissions in linuxAdvanced file permissions in linux
Advanced file permissions in linux
 
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
 
File Access Permission
File Access PermissionFile Access Permission
File Access Permission
 
Sticky bit suid sgid
Sticky bit suid sgidSticky bit suid sgid
Sticky bit suid sgid
 
Unix Basics Commands
Unix Basics CommandsUnix Basics Commands
Unix Basics Commands
 
04-1-Linux.ppt
04-1-Linux.ppt04-1-Linux.ppt
04-1-Linux.ppt
 
Linux for CS Majors
Linux for CS MajorsLinux for CS Majors
Linux for CS Majors
 
Lesson 3 Working with Files in Linux
Lesson 3 Working with Files in LinuxLesson 3 Working with Files in Linux
Lesson 3 Working with Files in Linux
 
Linux ppt
Linux pptLinux ppt
Linux ppt
 
Rhel 6.2 complete ebook
Rhel 6.2 complete ebookRhel 6.2 complete ebook
Rhel 6.2 complete ebook
 
Most frequently used unix commands for database administrator
Most frequently used unix commands for database administratorMost frequently used unix commands for database administrator
Most frequently used unix commands for database administrator
 
2023comp90024_linux2.pdf
2023comp90024_linux2.pdf2023comp90024_linux2.pdf
2023comp90024_linux2.pdf
 

Mehr von Kenny (netman)

Mehr von Kenny (netman) (14)

rpi_audio configuration steps
rpi_audio configuration stepsrpi_audio configuration steps
rpi_audio configuration steps
 
Rpi audio
Rpi audioRpi audio
Rpi audio
 
Chap 19 web
Chap 19 webChap 19 web
Chap 19 web
 
About the Course
About the CourseAbout the Course
About the Course
 
Linux fundamental - Chap 15 Job Scheduling
Linux fundamental - Chap 15 Job SchedulingLinux fundamental - Chap 15 Job Scheduling
Linux fundamental - Chap 15 Job Scheduling
 
Linux fundamental - Chap 14 shell script
Linux fundamental - Chap 14 shell scriptLinux fundamental - Chap 14 shell script
Linux fundamental - Chap 14 shell script
 
Linux fundamental - Chap 12 Hardware Management
Linux fundamental - Chap 12 Hardware ManagementLinux fundamental - Chap 12 Hardware Management
Linux fundamental - Chap 12 Hardware Management
 
Linux fundamental - Chap 11 boot
Linux fundamental - Chap 11 bootLinux fundamental - Chap 11 boot
Linux fundamental - Chap 11 boot
 
Linux fundamental - Chap 00 shell
Linux fundamental - Chap 00 shellLinux fundamental - Chap 00 shell
Linux fundamental - Chap 00 shell
 
Linux system security
Linux system securityLinux system security
Linux system security
 
Linux Network Monitoring
Linux Network MonitoringLinux Network Monitoring
Linux Network Monitoring
 
加密應用(GPG)
加密應用(GPG)加密應用(GPG)
加密應用(GPG)
 
金鑰管理 (PKI)
金鑰管理 (PKI)金鑰管理 (PKI)
金鑰管理 (PKI)
 
Linux firewall
Linux firewallLinux firewall
Linux firewall
 

Kürzlich hochgeladen

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
MateoGardella
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 

Kürzlich hochgeladen (20)

Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 

Linux fundamental - Chap 02 perm

  • 1. Chapter 2Chapter 2 File PermissionFile Permission Ref. Pge. 194
  • 2. Listing a file permissionListing a file permission ● ls -l 1.txtls -l 1.txt -rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt
  • 3. File TypeFile Type -- : Regular File: Regular File ASCII textASCII text executableexecutable datadata dd : Directory: Directory ll : Symbolic Link: Symbolic Link cc : Character Device: Character Device bb : Block Device: Block Device ss : Socket: Socket pp : Named Pipe(FIFO): Named Pipe(FIFO) -rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt
  • 4. Permission ModePermission Mode rw-r--r--rw-r--r-- rw-rw- : owner permission: owner permission r--r--: group permission: group permission r--r--: others permission: others permission -rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt
  • 5. Link CounterLink Counter 11 :: Only one name for this fileOnly one name for this file -rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt
  • 6. OwnershipOwnership kennykenny :: user(owner) nameuser(owner) name usersusers :: group namegroup name -rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt
  • 7. File SizeFile Size 4141 :: 41 bytes41 bytes -rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt
  • 8. Time StampTime Stamp Jan 25 07:53Jan 25 07:53 : Modification time: Modification time -rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt
  • 9. File NameFile Name 1.txt1.txt : File Name: File Name -rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt
  • 10. Permission DeterminationPermission Determination 1st:1st: u (owner):u (owner): While the UID matches the owner,While the UID matches the owner, using theusing the first THREE characters.first THREE characters. 2nd:2nd: g (group):g (group): WWhile one of the GID(s) matches the group,hile one of the GID(s) matches the group, using the middle THREE characters.using the middle THREE characters. 3rd:3rd: o (others)o (others) Neither of above,Neither of above, using the last THREE characters.using the last THREE characters. -rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt-rw-r--r-- 1 kenny users 41 Jan 25 07:52 1.txt
  • 11. Permission DeterminationPermission Determination rr : read: read ww : write: write xx : execute: execute -- : off: off
  • 12. Meaning of PermissionMeaning of Permission rr ww xx FileFile Can read theCan read the content ofcontent of file.file. Can modifyCan modify the contentthe content of file.of file. Can run theCan run the program orprogram or script.script. DirectoryDirectory Can list fileCan list file names innames in directory.directory. Can create,Can create, delete, anddelete, and rename filesrename files in directory.in directory. Can accessCan access into theinto the directory.directory. Ref. Pge. 197
  • 13. Permission ModePermission Mode ● Binary mode:Binary mode: 9 bits9 bits: 110100100: 110100100 11 : on: on 00 : off: off
  • 14. Permission ModePermission Mode ● Text mode:Text mode: 9 characters : rw-r--r--9 characters : rw-r--r-- 1 :1 : rwxrwx 0 :0 : --
  • 15. Permission ModePermission Mode ● Octal mode:Octal mode: 3 digits3 digits : 644: 644 OctalOctal ValueValue TextText 0 0 00 0 0 0 0 10 0 1 0 1 00 1 0 0 1 10 1 1 1 0 01 0 0 1 0 11 0 1 1 1 01 1 0 1 1 11 1 1 00 11 22 33 44 55 66 77 ­­­­­­ ­­x­­x ­w­­w­ ­wx­wx r­­r­­ r­xr­x rw­rw­ rwxrwx Ref. Pge. 196
  • 16. Changing Permission ModeChanging Permission Mode ● Octal mode:Octal mode: chmod 644 1.txtchmod 644 1.txt Ref. Pge. 199
  • 17. Changing Permission ModeChanging Permission Mode ● Text mode:Text mode: chmod u=rw,go=r 1.txtchmod u=rw,go=r 1.txt WhomWhom HowHow WhatWhat uu gg oo aa ++ -- == rr ww xx
  • 18. Special PermissionSpecial Permission Ref. Pge. 197 SUIDSUID (100)(100) SGIDSGID (010)(010) Sticky BitSticky Bit (001)(001) FileFile (binary only)(binary only) The process UIDThe process UID will not get fromwill not get from user, it inheritsuser, it inherits from the file'sfrom the file's owner instead.owner instead. The process GIDThe process GID will not get fromwill not get from user's group, butuser's group, but from the group offrom the group of file.file. -- DirectoryDirectory -- Any new file or subAny new file or sub directory will getdirectory will get the same group asthe same group as directory. New subdirectory. New sub directory inheritsdirectory inherits the SGID as well.the SGID as well. Only root andOnly root and the owner ofthe owner of file orfile or directory anddirectory and remove file inremove file in directory.directory.
  • 19. Changing Special PermissionChanging Special Permission ● Octal mode:Octal mode: chmod <Nnnn> filechmod <Nnnn> file Text mode:Text mode: chmod [ug][+-][s] filechmod [ug][+-][s] file chmod o[+-]t filechmod o[+-]t file Ref. Pge. 193
  • 20. Determination ofDetermination of Special PermissionSpecial Permission         rwxrws­­Trwxrws­­T   011111111000 011111111000  ( 6  7  7  0 )( 6  7  7  0 ) [st] : replace x[st] : replace x [ST] : replace -[ST] : replace - Ref. Pge. 193
  • 21. Changing OwnershipChanging Ownership ● Changing a File's Owner:Changing a File's Owner: chown alex 1.txtchown alex 1.txt ● Requirement:Requirement: ● root onlyroot only Ref. Pge. 193
  • 22. Changing OwnershipChanging Ownership ● Changing a File's Group:Changing a File's Group: chown :group1 1.txtchown :group1 1.txt chgrp group1 1.txtchgrp group1 1.txt ● Requirement:Requirement: ● root, orroot, or ● file owner, must belongs to the target groupfile owner, must belongs to the target group
  • 23. Changing OwnershipChanging Ownership ● Changing both Owner and Group:Changing both Owner and Group: chown alex:group1 1.txtchown alex:group1 1.txt ● Requirement:Requirement: ● root onlyroot only
  • 24. Default PermissionDefault Permission ● Default permission for new file:Default permission for new file: 06660666 ● Default permission for new directory:Default permission for new directory: 07770777 Ref. Pge. 202
  • 25. Changing Default PermissionChanging Default Permission ● Using theUsing the umaskumask command:command: umaskumask : list the current umask value: list the current umask value umask nnnumask nnn : change the umask value: change the umask value
  • 26. Meaning of umask valueMeaning of umask value ● To remove specified permissionTo remove specified permission from default:from default: file default:file default: 000 110 110 110000 110 110 110 mask value:mask value: 000 000 010 010000 000 010 010 file result:file result: 000 110 100 100000 110 100 100 11 : removed: removed 00 : unchanged: unchanged dir result:dir result: 000 111 101 101000 111 101 101