Comentum Site Map
 
 

Comentum Corp.

 
 

Creative Services

Interactive Multimedia Concept Marketing Broadband Technology
 

 

:: COMPANY
:: CAREERS
:: CONTACT INFO
:: TERMS & PRIVACY

 

 


UNIX, LINUX & OS X File Permissions

To view permission information for all files and directories inside the current working directory, open a new terminal and type:
ls -l

Here is an example of the output:
drwxr-xr-x 6 user group 204 Dec 30 06:37 images
-rw-r--r-- 1 user group 5754 May 20 2005 index.html
-rw-r--r-- 1 user group 9482 Jan 16 16:29 mypage.html


To view permission information for a particular file (for example:myfile.txt), type:
ls -l myfile.txt

Here is an example of the output:
-rw-r--r-- 1 user group 9482 Jan 16 16:29 myfile.txt

Here is a quick reference and diagram of what "-rwxrw-r--" means:
"r" means: read permission
"w" means: write permission
"x" means: execute permission



Changing file and folder permissions:
Use the following commands to change file or folder permissions:
chmod (change file modes)
chown (change file owner)
chgrp (change file group owner)

The following letters represent:
"u"
- user/owner
"g" - group owner
"o" - all other users
"a" - for all: user/owner, group owner and all other users.

"r"
- read permission
"w" - write permission
"x" - execute permission

Examples of replacing and setting new permissions:
(Note: Do not use space between any of the statements (example DO NOT TYPE: u = rwx)
chmod u=rwx filename
chmod u=rwx directoryname
chmod -R u=rwx directoryname

chmod g=rx filename
chmod g=rx directoryname
chmod -R g=rx directoryname


chmod o=r filename
chmod o=r directoryname
chmod -R o=r directoryname


chmod u=rwx,g=rx,o=r filename
chmod u=rwx,g=rx,o=r directoryname
chmod -R u=rwx,g=rx,o=r directoryname
"-R"
- means recursively change permissions of directories and their contents.

chmod a=rwx filename
"a"
- for all: user/owner, group owner and all other users.

Examples of adding or taking away permissions from the current permissions:
chmod u+w filename
chmod u+w directoryname
chmod -R u+w directoryname

chmod g+w filename
chmod g+w directoryname
chmod -R g+w directoryname


chmod o-r filename
chmod o-r directoryname
chmod -R o-r directoryname


Modifying multiple permissions examples:
chmod u+w,g+x,o-r filename
chmod ug+rwx filename
chmod ugo+rwx filename
chmod u+w,g+x,o-r directoryname
chmod ug+rwx directoryname
chmod ugo+rwx directoryname
chmod -R u+w,g+x,o-r directoryname

chmod -R ug+w,o-r directoryname

chmod -R ugo+rwx directoryname

"-R"
- means recursively change permissions of directories and their contents.

Examples of changing user/owner:
chown username filename
chown -R username directoryname

Examples of changing group owner:
chgrp groupname filename
chgrp -R groupname directoryname

Examples of changing group owner and user owner:
chown username:groupname filename
chown -R username:groupname directoryname


"-R" - means recursively change permissions of directories and their contents.


Here is some more examples:
chmod u=rwx,g=rw,o=rx myfile.txt
Now view the result:
ls -l myfile.txt
-rwxrw-r-x 1 user group 9482 Jan 16 16:29 myfile.txt
------------------------------------------
chmod -R u=rwx,g=rx,o=r directoryname
Now view the result:
ls -l directoryname
drwxr-xr-- 6 user group 204 Dec 30 06:37 images
-rwxr-xr-- 1 user group 5754 May 20 2005 index.html
-rwxr-xr-- 1 user group 9482 Jan 16 16:29 mypage.html

------------------------------------------
chown -R www directoryname
Now view the result:
ls -l directoryname
drwxr-xr-- 6 www group 204 Dec 30 06:37 images
-rwxr-xr-- 1 www group 5754 May 20 2005 index.html
-rwxr-xr-- 1 www group 9482 Jan 16 16:29 mypage.html

------------------------------------------
chgrp -R www directoryname
Now view the result:
ls -l directoryname
drwxr-xr-- 6 www www 204 Dec 30 06:37 images
-rwxr-xr-- 1 www www 5754 May 20 2005 index.html
-rwxr-xr-- 1 www www 9482 Jan 16 16:29 mypage.html


Bernard Kohan © 2007
Website Design and Development - San Diego, Chicago, Austin, Irvine, Los Angeles, Ft Lauderdale, Jacksonville
Website Database Development - - San Diego, Chicago, Austin, Irvine, Los Angeles, Ft Lauderdale, Jacksonville
Website Design and Flash Animation - San Diego, Chicago, Austin, Irvine, Los Angeles, Ft Lauderdale, Jacksonville

 

 

  San Diego • Los Angeles • Chicago • 800-387-1920  


 

Comentum Corporation, Copyright © 1996-2007