CS155 Permissions
% date >now % mkdir zulu % ls -l total 4 -rw------- 1 cs155 class 29 Dec 22 02:05 now drwx------ 2 cs155 class 40 Dec 22 02:05 zulu
d | rwx | rwx | rwx |
directory or file | user | group | other |
The permissions can be different for user, group and other (everyone else). Typically, the user gets the most permissions, and others get very little.
r
: gives permission to read a a file or directory
w
: gives you permission to write a file or directory
x
: gives you permission to execute (run) a file
or cd
into a directory
Note that w
for a directory means that you can change the directory,
not the files it contains. Changing the files underneath it depends
on their w
bits.
drwxr-x---
rwx
: list, modify (add or remove files), and cd
r-x
: list and cd
---
: no access
-r--r--r--
-rw-rw-r--
chmod
: change mode
chmod
mode[,mode]… file…mode is formed by combining:
u
, g
, or o
(or combination thereof), or a
for “all”
+
, -
, or =
r
, w
, x
chmod ug+wx
gives user and group write and execute permissions.
It doesn’t change the other permissions.
chmod ugo=r chewbacca
chewbacca
.
(-r--r--r--
)
chmod go+xw darth
darth
.
(-????wx?wx
)
chmod o-rwx han
-??????---
)
chmod u=rwx luke
-rwx??????
)
% touch chewbacca darth luke han % ls -l total 0 -rw------- 1 cs155 class 0 Dec 22 02:05 chewbacca -rw------- 1 cs155 class 0 Dec 22 02:05 darth -rw------- 1 cs155 class 0 Dec 22 02:05 han -rw------- 1 cs155 class 0 Dec 22 02:05 luke % chmod ugo=r chewbacca % chmod go+xw darth % chmod o-rwx han % chmod u=rwx luke % ls -l total 0 -r--r--r-- 1 cs155 class 0 Dec 22 02:05 chewbacca -rw--wx-wx 1 cs155 class 0 Dec 22 02:05 darth -rw------- 1 cs155 class 0 Dec 22 02:05 han -rwx------ 1 cs155 class 0 Dec 22 02:05 luke
Command | Result |
---|---|
chmod a=r,go+w ackbar | -r--rw-rw- |
chmod a=rwx,g-w,o-x ewok | -rwxr-xrw- |
chmod a=rw,go-w,o-r yoda | -rw-r----- |
chmod u=rw boba | -rw-?????? |
chmod a=rw,go= lando | -rw------- |
chmod og=r,u=rw r2d2 | -rw-r--r-- |