chmod Examples

Let’s change some of the permissions as we discussed a couple of pages ago. Here’s the way our files are now:

-rwxr-xr-x  joe  acctg  archive.sh 
-rw-rw-r--  joe  acctg  orgchart.gif
-rw-rw-r--  joe  acctg  personnel.txt
-rw-r--r--  joe  acctg  publicity.html
drwxrwxr-x  joe  acctg  sales
-rw-r-----  joe  acctg  topsecret.inf
-rwxr-xr-x  joe  acctg  wordmatic

First, let’s prevent outsiders from executing archive.sh

Before: -rwxr-xr-x  archive.sh
Command: chmod o=r archive.sh
After: -rwxr-xr--  archive.sh

Take away all permissions for the group for topsecret.inf We do this by leaving the permissions part of the command empty.

Before: -rw-r-----  topsecret.inf
Command: chmod g= topsecret.inf
After: -rw-------  topsecret.inf

Open up publicity.html for reading and writing by anyone.

Before: -rw-r--r--  publicity.html
Command: chmod og=rw publicity.html
After: -rw-rw-rw-  publicity.html
 << The chmod Command Index Try it >>