Академический Документы
Профессиональный Документы
Культура Документы
File
Permissions
Objectives
After completing this unit, students should be able to:
List the basic file permissions
Change the basic file permissions using both the
octal and symbolic formats
permission
bits
2
2
1
2
team01
team01
team01
team01
staff 1024
staff
512
staff
320
staff
144
Aug
Feb
Feb
Feb
12
18
22
22
10:16 c
09:55 doc
07:30 suba
16:30 test1
File Protection/Permissions
rwx
rwx
rwx
user
group
others
r = read
w = write
x = execute
For a directory:
r => Can find out what files are in the directory
w => Can create/remove files in the directory (x is needed)
x => Has permission to be in the directory
(that is, cd to the directory or access files from the
directory)
+ : add permissions
- : remove permissions
= : Clears permissions and sets to mode specified
$ ls -l newfile
-rw-r--r-1 team01
staff 58 Apr 21
16:06 newfile
staff 58 Apr 21
16:06 newfile
staff 58 Apr 21
16:06 newfile
staff 58 Apr 21
16:06 newfile
User
rwx
111
4+2+1
7
Group
rw110
4+2+0
6
Others
r-100
4+0+0
4
staff 58 Apr 21
16:06 newfile
staff 65 Apr 22
17:06 newfile
File
-rw-r--r--
644
Directory
drwxr-xr-x
755
umask
umask specifies what permission bits will be set on a
new file or directory when created. It is an octal
number that is used to determine what permission bits a
file or directory is created with:
New Directory: 777 - 022:
New File:
666 - 022:
755
644
=> rwxr-xr-x
=> rw-r--r--
Activity
July 29
9:40
team01
July 30
10:30 file1
$ whoami
team02
$ vi /home/team01/file1
file1: The file has read permission only
$ vi myfile1
Ha! Ha! I changed this file. Figure out how.
$ mv myfile1 /home/team01/file1
override protection 644 for file1? y
$ cat /home/team01/file1
Ha! Ha! I changed this file. Figure out how.
Function/Permissions Required
Command
Source Directory
Source File
Target Directory
cd
N/A
N/A
ls
N/A
N/A
ls -l
r, x
N/A
N/A
mkdir
N/A
N/A
N/A
N/A
x
w (parent)
x
w (parent)
x
N/A
mv
x, w
NONE
x, w
cp
x, w
touch
x, w *
NONE
N/A
rm
x, w
NONE
N/A
rmdir
Exercise 5
Unit 6: Checkpoint
The following questions are for a file called reporta which has the following
set of permissions: rwxr-x r-x
1. What is the mode in octal?
_________________________________________________________
2. Change mode to rwxr- - r- - using the symbolic format.
_________________________________________________________
3. Repeat the above operation using the octal format.
_________________________________________________________
4. Question four is based on the following listing. Assume that the directory
jobs contains the file joblog.
$ ls -lR
total 8
drwxr-xr-x
judy
finance
512
June 5
11:08
jobs
./jobs:
total 8
-rw-rw-r--
judy
finance
100
June 6
12:16
joblog
Can Fred, who is a member of the finance group, modify the file joblog?
judy
finance
512
June 5
11:08
jobs
./jobs:
total 8
drwxrw-r-x
judy
finance
512
June 5
11:10
work
./jobs/work:
total 8
-rw-rw-r-- 1
judy
finance
100
June 6
12:16
joblog
Can Fred, who is a member of the finance group, modify the file
joblog?
$ ls -lR
total 8
drwxr-xr-x
judy
finance
512
June 5
11:08
jobs
./jobs:
total 8
drwxrwxrwx
judy
finance
512
June 5
11:10
work
./jobs/work:
total 8
-rw-rw-r-- 1
judy
finance
100
June 6
12:16
joblog
Can Fred, who is a member of the finance group, copy the file joblog to
his home directory?
Summary
Basic file permissions can be listed using the ls -l
command
chmod grants or removes read, write and execute
permissions for three classes of users: user, group and
others
The permissions used with the chmod command can be
defined in symbolic or octal format
The umask specifies the permissions for new files and
directories