Sie sind auf Seite 1von 4

11/26/2014

chmodManPage|Bash|SS64.com

(SS64)

Bash

Syntax

Search

chmod
Changeaccesspermissions,changemode.
Syntax
chmod[Options]...Mode[,Mode]...file...
chmod[Options]...Numeric_Modefile...
chmod[Options]...reference=RFilefile...
Options
f,silent,quietsuppressmosterrormessages
v,verboseoutputadiagnosticforeveryfileprocessed
c,changeslikeverbosebutreportonlywhenachangeismade
reference=RFileuseRFile'smodeinsteadofMODEvalues
R,recursivechangefilesanddirectoriesrecursively
helpdisplayhelpandexit
versionoutputversioninformationandexit
chmodchangesthepermissionsofeachgivenfileaccordingtomode,wheremodedescribesthepermissions
tomodify.Modecanbespecifiedwithoctalnumbersorwithletters.Usinglettersiseasiertounderstandfor
mostpeople.
rwxrxx

Permissions: 751
Owner

Group

Other

Read
Write
Execute

Numericmode:
Fromonetofouroctaldigits
Anyomitteddigitsareassumedtobeleadingzeros.
Thefirstdigit=selectsattributesforthesetuserID(4)andsetgroupID(2)andsavetextimage(1)S
Theseconddigit=permissionsfortheuserwhoownsthefile:read(4),write(2),andexecute(1)
Thethirddigit=permissionsforotherusersinthefile'sgroup:read(4),write(2),andexecute(1)
Thefourthdigit=permissionsforotherusersNOTinthefile'sgroup:read(4),write(2),andexecute(1)
Theoctal(07)valueiscalculatedbyaddingupthevaluesforeachdigit
User(rwx)=4+2+1=7
Group(rx)=4+1=5
World(rx)=4+1=5
chmodemode=0755
Examples

http://ss64.com/bash/chmod.html

1/4

11/26/2014

chmodManPage|Bash|SS64.com

chmod400fileReadbyowner
chmod040fileReadbygroup
chmod004fileReadbyworld
chmod200fileWritebyowner
chmod020fileWritebygroup
chmod002fileWritebyworld
chmod100fileexecutebyowner
chmod010fileexecutebygroup
chmod001fileexecutebyworld
Tocombinethese,justaddthenumberstogether:
chmod444fileAllowreadpermissiontoownerandgroupandworld
chmod777fileAlloweveryonetoread,write,andexecutefile
SymbolicMode
Theformatofasymbolicmodeisacombinationoftheletters+=rwxXstugoa
Multiplesymbolicoperationscanbegiven,separatedbycommas.
Thefullsyntaxis[ugoa...][[+=][rwxXstugo...]...][,...]butthisisexplainedbelow.
Acombinationofthelettersugoacontrolswhichusers'accesstothefilewillbechanged:
User
Theuserwhoownsit
Otherusersinthefile'sGroup

letter
u
g

Otherusersnotinthefile'sgroup

Allusers

Ifnoneofthesearegiven,theeffectisasifaweregiven,butbitsthataresetintheumaskarenotaffected.
Allusersaiseffectivelyuser+group+others
Theoperator'+'causesthepermissionsselectedtobeaddedtotheexistingpermissionsofeachfile''causes
themtoberemovedand'='causesthemtobetheonlypermissionsthatthefilehas.
Theletters'rwxXstugo'selectthenewpermissionsfortheaffectedusers:
Permission
Read
Write
Execute(oraccessfordirectories)
Executeonlyifthefileisadirectory
(oralreadyhasexecutepermissionforsomeuser)
SetuserorgroupIDonexecution
Saveprogramtextonswapdevice
ThepermissionsthattheUserwhoownsthefilecurrentlyhasforit
Thepermissionsthatotherusersinthefile'sGrouphaveforit
PermissionsthatOtherusersnotinthefile'sgrouphaveforit

letter
r
w
x
X
s
t
u
g
o

Examples
http://ss64.com/bash/chmod.html

2/4

11/26/2014

chmodManPage|Bash|SS64.com

Denyexecutepermissiontoeveryone:
chmodaxfile
Allowreadpermissiontoeveryone:
chmoda+rfile
Makeafilereadableandwritablebythegroupandothers:
chmodgo+rwfile
Makeashellscriptexecutablebytheuser/owner
$chmodu+xmyscript.sh
Alloweveryonetoread,write,andexecutethefileandturnonthesetgroupID:
chmod=rwx,g+sfile
Notes:
Whenchmodisappliedtoadirectory:
read=listfilesinthedirectory
write=addnewfilestothedirectory
execute=accessfilesinthedirectory
chmodneverchangesthepermissionsofsymboliclinks.Thisisnotaproblemsincethepermissionsof
symboliclinksareneverused.However,foreachsymboliclinklistedonthecommandline,chmodchangesthe
permissionsofthepointedtofile.Incontrast,chmodignoressymboliclinksencounteredduringrecursive
directorytraversals.
ThispagedocumentstheGNUversionofchmod.
Itseasiertoaskforgivenessthanitistogetpermission~RearAdmiralGraceHopper
Related:
accessDeterminewhetherafilecanbeaccessed
lslListcurrentpermissions:u(owner)g(group)O(Other)
chgrpChangegroupownership
chownChangefileownerandgroup
statDisplayfileorfilesystemstatus
bashsyntaxPermissions
EquivalentWindowscommand:CACLSChangefilepermissions

Malaysian Authors
m.partridgepublishing.com/Singapore

Want To Be A Published Malaysian


Author? Submit Your Manuscript
Now!

http://ss64.com/bash/chmod.html

3/4

11/26/2014

chmodManPage|Bash|SS64.com

CopyrightSS64.com19992014
Somerightsreserved

http://ss64.com/bash/chmod.html

4/4

Das könnte Ihnen auch gefallen