Chapter 11 File Sharing Sharing Techniques Duplicate files

  • Slides: 19
Download presentation
Chapter 11 File Sharing

Chapter 11 File Sharing

Sharing Techniques • Duplicate files • Common login • Setting appropriate access permissions on

Sharing Techniques • Duplicate files • Common login • Setting appropriate access permissions on shared files • Common group for team members • Sharing via links

Sharing via Links • A link is a connection between the file to be

Sharing via Links • A link is a connection between the file to be shared and the directory entries of the users who want to have access to this file • 2 types of links exist: – hard links – soft (symbolic) links

Figure 11. 1 (a) Logical structure of current directory; (b) contents of current directory

Figure 11. 1 (a) Logical structure of current directory; (b) contents of current directory

Figure 11. 1 (c) relationship among a directory entry, inode, and file contents

Figure 11. 1 (c) relationship among a directory entry, inode, and file contents

Hard Links A hard link is a pointer to the inode of a file

Hard Links A hard link is a pointer to the inode of a file Established using the ln command The link count of the file is incremented Both the original file and the new entry point to the same inode • When deleted, the link count is decremented, and the file is only deleted if the resulting link count is zero • •

Figure 11. 2 Establishing a hard link ln Chapter 3. hard

Figure 11. 2 Establishing a hard link ln Chapter 3. hard

ln command Syntax ln [options] oldfile newfile ln [options] old-file-list directory Options -f force

ln command Syntax ln [options] oldfile newfile ln [options] old-file-list directory Options -f force creation (overwrite existing file) -n don’t force -s create soft(symbolic) link

Figure 11. 2 (c) hard link implementation by establishing a pointer to inode of

Figure 11. 2 (c) hard link implementation by establishing a pointer to inode of the file

Hard Link across directories ln memo 6. hard memos/memo 6

Hard Link across directories ln memo 6. hard memos/memo 6

Hard Link across accounts ln linuxbook/examples/demo 1. . /bob/dir 1 sarwar must have x-permission

Hard Link across accounts ln linuxbook/examples/demo 1. . /bob/dir 1 sarwar must have x-permission for bob and wx-permission for dir 1

Limitations of Hard Links • Links cannot be established across file systems • If

Limitations of Hard Links • Links cannot be established across file systems • If one of the files is moved to a different file system, it is copied instead, and the link counts of both files adjusted accordingly • Only superusers can create hard links to directories

Soft (Symbolic) Links • Established using the ln -s command • The link count

Soft (Symbolic) Links • Established using the ln -s command • The link count of the file is not incremented • The created file is of the special type “link” denoted by “l” in directory listings • The linked file is an actual file that contains the path to the original file • Symbolic links can be created across file systems • Symbolic links to directories can be created by any user

Figure 11. 5 Establishing a soft link ln -s Chapter 3. soft

Figure 11. 5 Establishing a soft link ln -s Chapter 3. soft

Soft links in directory listing ln -s Chapter 3. soft ls – il 52473

Soft links in directory listing ln -s Chapter 3. soft ls – il 52473 -rwxr--r-- 1 sarwar faculty 9352 May 28 23: 09 Chapter 3 52479 lrwxr--r-- 2 sarwar faculty 8 Oct 13 14: 24 Chapter 3. soft --> Chapter 3

Figure 11. 5 (c) soft link implementation by establishing a “pointer” to (pathname of)

Figure 11. 5 (c) soft link implementation by establishing a “pointer” to (pathname of) the existing file in the link file

Soft Link across accounts

Soft Link across accounts

Types of Symbolic Links • absolute • relative • other_fs • messy • lengthy

Types of Symbolic Links • absolute • relative • other_fs • messy • lengthy • dangling symlinks command used for examining and repairing links

Drawbacks of Soft Links • If the original file is moved to a different

Drawbacks of Soft Links • If the original file is moved to a different location, it can no longer be accessed via the symbolic link (dangling link) • Extra space on disk and extra inode to store the link file • Extra time required for access to the original file: the link file has to be read first, then path followed to target file