Living in the Shell #24; chmod (Modify file/directory permissions)

Living in the Shell #24; chmod (Modify file/directory permissions)

ยท

2 min read

chmod ๐Ÿ”

Modifies file/directory permissions (See here or here for more details).

Permission expressions are mostly formatted as [ugoa][+-=][rwx]:

SymbolMeaning
rRead
wWrite
xExecute
SymbolMeaning
uUser (owner of the file/directory)
gGroup (of the file/directory)
oOther users/groups
aAll users/groups

Grant all permissions to everyone; a+rwx or 777

chmod a+rwx some-file
# or
chmod 777 some-file

Make a file executable for everyone +x

chmod +x some-file
# or
chmod a+x some-file

Make a file executable only for the User (owner) u+x

chmod u+x some-file

Disallow Group and Others to read/write/execute go-rwx

chmod go-rwx some-file

Apply the same User (owner) permissions to the Group =u

chmod g=u some-file

Rewrite permissions for the Group and Others =

chmod go=rw some-file

Clear permissions for the Group and Others =

chmod go= some-file

Clear all permissions =

chmod a= some-file

About Living in the Shell
Obsessed with doing things in the shell, Iโ€™ve decided to share my daily struggles on living in the shell as terse but informative posts.

ย