O'Reilly logo

Practical UNIX and Internet Security, 3rd Edition by Alan Schwartz, Gene Spafford, Simson Garfinkel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

chmod: Changing a File’s Permissions

When you create a file, its initial permissions depend on your umask value (which is discussed later). You can change a file’s permissions with the chmod command or the chmod( ) system call. You can change a file’s permissions only if you are the file’s owner. The one exception to this rule is the superuser: if you are logged in as the superuser, you can change the permissions of any file.[67]

In its simplest form, the chmod command lets you specify which of a file’s permissions you wish to change. This usage is called symbolic form. The symbolic form of the chmod command[68] has the form:

chmod [-Rfh] [agou][+-=][rwxXstugol] filelist

This command changes the permissions of filelist, which can be either a single file or a group of files. The letters agou specify whose privileges are being modified. You may provide none, one, or more, as shown in Table 6-7.

Table 6-7. Whose privileges are being modified?

Letter

Meaning

a

Modifies privileges for all users

g

Modifies group privileges

o

Modifies others’ privileges

u

Modifies the owner’s privileges

The symbols specify what is supposed to be done with the privilege. You must type only one symbol, as shown in Table 6-8.

Table 6-8. What to do with privilege

Symbol

Meaning

+

Adds to the current privilege

-

Removes from the current privilege

=

Replaces the current privilege

The last letters specify which privilege will be modified, as shown in Table 6-9.

Table 6-9. Which privileges are being ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required