DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Directory and file management

How to change existing permissions

After you have determined what permissions are in effect, you can change them by calling the chmod command in the following format:

   chmod who+permission file(s)
or
   chmod who-permission file(s)
The following list defines each component of this command line.

chmod name of the program
who one of three user groups:
user
group
ohers
+ or - instruction that grants (+) or denies (-) permission
permission any combination of three authorizations:
read
write
execute
file(s) file (or directory) name(s) listed; assumed to be branches from your current directory, unless you use full pathnames


NOTE: The chmod command will not work if you type a space(s) between who, the instruction that gives (+) or denies (-) permission, and the permission.

The following examples show a few possible ways to use the chmod command. As the owner of display, you can read, write, and run this executable file. You can protect the file against being accidentally changed by denying yourself write (w) permission. To do this, type the command line:

   chmod u-w display
After receiving the prompt, type ls -l and press the <Return> key to verify that this permission has been changed, as shown in the following screen.

$ chmod u-w display
$ ls -l
total 35
-r-xr-xr-x 1 starship project 9346 Nov 1 08:06 display
rw-r--r-- 1 starship project 6428 Dec 2 10:24 list
drwx--x--x 2 starship project 32 Nov 8 15:32 tools
$

As you can see, you no longer have permission to write changes into the file. You will not be able to change this file until you restore write permission for yourself.

Now consider another example. Notice that permission to write into the file display has been denied to members of your group and other system users. However, they do have read permission. This means they can copy the file into their own directories and then make changes to it. To prevent all system users from copying this file, you can deny them read permission by typing:

   chmod go-r display
The g and o stand for group members and all other system users, respectively, and the -r denies them permission to read or copy the file. Check the results with the ls -l command.

$ chmod go-r display
$ ls -l
total 35
-rwx--x--x 1 starship project 9346 Nov 1 08:06 display
rw-r--r-- 1 starship project 6428 Dec 2 10:24 list
drwx--x--x 2 starship project 32 Nov 8 15:32 tools
$

For more information, refer to ls(C) and chmod(C).


Next topic: A note on permissions and directories
Previous topic: Directory access permissions

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005