The Linux File System
The Linux File System
1 2
Figure 3-3
3 4
Figure 3-4
5 6
5 6
1
05-Mar-19
File System
Figure 3-12
7 8
Figure 3-14
9 10
9 10
Figure 3-15
11 12
2
05-Mar-19
13 14
13 14
Figure 3-17
15 16
15 16
17 18
3
05-Mar-19
Figure 3-18
19 20
File System
Remove Directories
Exercises
• To remove an empty directory – a directory that
does not contain user-created files, use the • In your home directory (example
command named “rmdir” /home/students/2017xxxx) create directory dir1 then dir2
Example: To remove a directory called “test”, inside dir1
which does not contain user-created files. • List the contents of dir1, dir2
ux% rmdir test • Move to dir2
• Getback to your home directory
• To remove a non-empty directory, use the command • Remove dir1 and dir2
named “rm –r”
Example: To remove a non-empty directory called
“old-data”
ux% rm –r old-data
21
21 22
23 24
23 24
4
05-Mar-19
25 26
25 26
Figure 3-31
27 28
27 28
Figure 3-30
29 30
29 30
5
05-Mar-19
31 32
31 32
34
33 34
• The command named “find” can be used to locate Example 1: Find all files, in your directory hierarchy,
a file or a directory. that have a name ending with “.bak”.
• Syntax: find pathname-list expression ux% find ~ “*.bak” –print
• “find” recursively descends through pathname-list
and applies expression to every file. Example 2: Find all files, in your directory hierarchy,
• Expression that were modified yesterday.
• -name file_name
ux% find ~ –mtime –1 -print
• -perm permission_mod
• -type d/f/...
• -size N: N is the minimum number of block (512B)
• -atime N, -mtime N, -ctime N, where is by defaut the number of
day. 35 36
35 36
6
05-Mar-19
38
37 38
Figure 3-5
39 40
39 40
Figure 3-6
41 42
41 42
7
05-Mar-19
File System
– 1 address of a block that contains addresses of blocks Access, Links, and other
information
11 double indirect
block blocks
12
blocks
13
blocks
43
triple indirect 42
block
43 44
File System
Data blocks
on disk
44
45
45 46
File System
I-node
47 46
47 48
8
05-Mar-19
• To share a single file with multiple users, a link can Advantages Disadvantages
be used. Allow access to original file name
via the file name or the I-node Cannot link to a file in a different
• A link is: number file system
– A reference to a file stored elsewhere on the system. The original file continues to exist
as long as at least one directory
– A way to establish a connection to a file to be shared. contains its I-node Prevents owner from truly deleting
it, and it counts against his/her disk
• Two types: Checks for the existence of the quota
– Hard link original file
– Symbolic link (a.k.a. “soft link”)
49 50
49 50
Figure 3-32
Hard
Hard Link
Link The ln Command
z036473
From dir3, link to the file ‘aa’ in dir1
name it ‘bb’:
dir1 dir2
% ln /home/z036473/dir1/aa bb
aa dir3
bb
54
51 52
51 52
Contents of dir1
.
home 1076
. 2406
2083 2407
z036473 ..
2408
aa 2407
dir1 dir2 .
aa Contents of dir3 .
dir3
1070
.
bb
2050
..
bb 2407
57
53 54
53 54
9
05-Mar-19
55 56
55 56
Figure 3-10
57
57 58
59
59
10