WARNING: This site is intended for online use only; mass-downloading of pages degrades the server and is prohibited.
If you attempt to use tools to mass-download the site, you may be blocked permanently by automated software.
If you want to read this CertiGuide offline, please use one of the links on the left to purchase a convenient PDF copy. Thank you.

Read this whole guide offline with no ads, for a very low price!
Click Here!

Custom Search






Table Of Contents  CertiGuide to A+ (A+ 4 Real)
 9  Chapter 5: The Linux Operating System
      9  Basic Concepts and Procedures for Creating, Viewing and Editing Files and Directories
           9  Common Commands

Previous Topic/Section
rmdir - Remove Empty Directories
Previous Page
Pages in Current Topic/Section
1
Next Page
find - Search For Files In A Directory Hierarchy
Next Topic/Section

chmod - Change File Access Permissions

Remembering the access privileges shown by the ls command with the -l option, this command will allow either the user/owner of file or the system administrator (root) to change the permissions mask for a file or directory. File permissions can be specified with two different methods, symbolic mode or numeric (absolute) mode. Only the first mode, symbolic, will be covered here, information about the absolute (numeric) mode can be found in the man and info pages. Definitions are in order: the abbreviation u stands for the file’s user/owner, g stands for the file’s group user, and o stand for all other system users. The letters r, w, x represent read, write, and execute permissions and finally + means add a privilege and - means remove a privilege and are summarized as shown in Table 13.


Table 13: chmod Access Permissions

Option

Description

r

Read permission

w

Write permission

x

Execute permission

u

Permission for the file/directory’s user/owner

g

Permission for the file/directory’s group

o

Permission for all other system users

a

Permissions for all - user, group and other


First, the general form and then an example.

chmod [options] mode[, mode] filename

How this command changes privileges is probably best understood from a couple examples. A long directory listing of the file, example_file, might be:

---xrw-rw- 1 someuser somegrp 54 Apr.1 12:01 example_file

Here, the command:

chmod u+rw,go-w example_file

will add read and write privileges for the file example_file’s user/owner and remove write privileges for the file’s group user and all other system users.

Notice, first multiple privilege modes can be used simply separating them by a comma. This allows modifying the privilege mask for user, group, other all in one command, when different privileges are needed for each. Secondly, no privileges not referenced in this form are changed.

In this example the execute privilege for this file would not have been changed for user, group, or other and the read privileges for group and other would remain whatever they were before this command had been executed. Now, a long listing of this file would yield:

-rwxr--r-- 1 someuser somegrp 54 Apr.1 12:01 example_file

Then running:

chmod u-x example_file

would remove the execute privilege for the file’s user/owner. This could have been accomplished all in the first example. The final access privileges would now look like:

-rw-r--r-- 1 someuser somegrp 54 Apr.1 12:01 example_file


Previous Topic/Section
rmdir - Remove Empty Directories
Previous Page
Pages in Current Topic/Section
1
Next Page
find - Search For Files In A Directory Hierarchy
Next Topic/Section

If you find CertiGuide.com useful, please consider making a small Paypal donation to help the site, using one of the buttons below. You can also donate a custom amount using the far right button (not less than $1 please, or PayPal gets most/all of your money!) In lieu of a larger donation, you may wish to consider buying an inexpensive PDF equivalent of the CertiGuide to A+ (A+ 4 Real) from StudyExam4Less.com. Thanks for your support!
Donate $2
Donate $5
Donate $10
Donate $20
Donate $30
Donate: $



Home - Table Of Contents - Contact Us

CertiGuide to A+ (A+ 4 Real) (http://www.CertiGuide.com/apfr/) on CertiGuide.com
Version 1.0 - Version Date: March 29, 2005

Adapted with permission from a work created by Tcat Houser et al.
CertiGuide.com Version Copyright 2005 Charles M. Kozierok. All Rights Reserved.
Not responsible for any loss resulting from the use of this site.