68
chmod u+rw foo.txt
Use the command
cat foo.txt
Here are some common examples of settings that can be used with
— adds write access for the group
•
g+w
— removes all permissions for others
•
o-rwx
— allows the file owner to execute the file
•
u+x
— allows everyone to read and write to the file
•
a+rw
— allows the owner and group to read the file
•
ug+r
— allows only the group to read and execute (not write)
•
g=rx
By adding the
option, you can change permissions for entire directory trees.
-R
Because you can not really "execute" a directory as you would an application, when you add (or
remove) the execute permission for a directory, you are really allowing (or denying) permission to
search through that directory.
Examine the dir1/ directory you created in section FIXME by listing all of the files in your home
directory.
user
ls -l /home/
>
The permissions on this directory are:
drwxrwxr-x
2 mgoldin mgoldin
If you do not allow others to have execute permission on the
has read or write access. No one can access the directory unless they know the exact file name.
For example, type
chmod a-x dir1/
to remove everyone's execute permissions.
Here is what happens when you try to change directories using the
ing everyone's execute permissions:
bash: dir1/: Permission denied
Next, restore your own and your group's access:
chmod ug+x dir1/
If you check your work with
directory.
4.11.2. Changing Permissions With Numbers
Another way to change permissions uses numeric representations.
Go back to the original permissions for
-rw-rw-r--
1 user user
to verify that you, the file owner, can read the file again.
/
<
4096 Jan
, you can see that only others are denied access to the
ls -l
foo.txt
150 Mar 19 08:08 foo.txt
Chapter 4. Shell Prompt Basics
chmod
6 15:05 dir1
directory, it does not matter who
dir1/
cd dir1/
:
:
command after remov-
/dir1/
Need help?
Do you have a question about the ENTERPRISE LINUX 4 - STEP BY STEP GUIDE and is the answer not in the manual?
Questions and answers