Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Unix File System R Bigelow. The UNIX File System The file system refers to the way in which UNIX implements files and directories. The UNIX file system.

Similar presentations


Presentation on theme: "The Unix File System R Bigelow. The UNIX File System The file system refers to the way in which UNIX implements files and directories. The UNIX file system."— Presentation transcript:

1 The Unix File System R Bigelow

2 The UNIX File System The file system refers to the way in which UNIX implements files and directories. The UNIX file system has the following features Hierarchical structure (support for directories) Files are expandable (may grow as required) Files are treated as byte streams (can contain any characters)

3 The UNIX File System Security rights are associated with files and directories (read/write/execute privileges) for (owner/group/others) Files may be shared (concurrent access) Hardware devices are treated just like files

4 File System Unix provides a hierarchical, or tree-like, file system There are 4 Types of files Ordinary Files Directory Files Links Special Files (device files) From Unix’s view, there is no difference between the different types.

5 Files and Directories

6 File Names Every file has a filename Unix allows up to 255 characters Almost any character can be used in a filename Sticking with the following will save many problems Uppercase letters (A-Z) Comma (, ) Lowercase letters (a-z) Dash ( - ) Numbers (0-9) Underscore ( _ ) Period (. ) can be used as any other character and may denote special files(hidden)

7 Other File Name Rules Other characters may be used by “escaping” them with a “\” character Willie\*Weasel - displays as Willie*Weasel or \”hello\” -displays “hello” File\ name – is really File name Much confusion can result from this therefore its better not to use these characters File names are case sensitive my_file, My_File, and MY_FILE are all unique names

8 Changing directory What will the following commands do. cd / cd ~/ cd cd ~/bobo cd../../bobo cd /bobo

9 Solution Change current directory to the / (root) directory Change current directory to the user’s home directory Same as above Change to the directory bobo in the user’s home directory Change to the bobo director that is 2 levels up in the directory tree Change to the bobo directory that is right under the root directory.

10 Creating a directory To create a directory one would use the mkdir IE) mkdir ~/bobo To remove a directory one would use the rmdir command (does not work if the directory is not empty.) IE) rmdir ~/bobo

11 Wildcards * - represents any number of characters including 0, and periods (but not leading periods) ? - represents any single character

12 Using Wildcards ls *cnt cnt Bobo.cnt A.really.big.file-ending_in.cnt fkjsldkfjlkewrkthewbewkjcnt ls c*cnt cool.cnt command.cnt cnt

13 multiple wildcards[] ls cnt[abc] Shows any of the following files cnta cntb cntc

14 Multiple Wildcards[] ls salary.[1990-2000] shows any file ending with the word salary then a period then a number between 1990 and 2000. IE) marketing.salary.1999

15 List 5 filenames that match the following. ls ?[0-9]*.[oc] 10.c A9-sectormeltdown.o A2.c 222.o 1000000.o

16 Moving and Copying using wildcards cp /home/* /backup/home/ Copies all files from the /home directory to the /backup/home directory cp *[0-9] /backup/ Copies any file in the current directory ending in a number to the /backup directory

17 File Information -rw-r--r-- 1 bigelow users 10 Dec 13 10:51 bobo File # of File Group Size Date &File Permissions Links Owner Owner Time Name to File Modified

18 File Permissions Unix provides file security with access levels and permissions Access levels define who specific permissions belong to. user (u)  (AKA file owner) group (g)  (AKA Group owner) other (o)  (AKA Everyone Else) Permissions define what the members of an access level are allowed to do. execute (x) read (r) write (w)

19 File Permissions drwxrwxrwx – The first character specifies the type of file. d- directory -Ordinary file L- Link B- Block Specific File (device files) C – Character Specific (device files)

20 File Permissions drwxrwxrwx The remaining characters represent the file permissions that is set for the file. The first set (wrx) belong to the file owner The Second set (wrx) belong to the group The third set (wrx) belong to everyone else who does not fall into the first category.

21 chmod –(Change file Mode) Changes access permissions (mode) of a file. Syntax: chmod [-R] mode filename -R Means recursively on subdirectories

22 Examples of chmod chmod +x bobo Would add the x flag or make it executable (for user,group,everyone else) chmod –x bobo Would remove the execute permission from the file(for user,group,everyone else)

23 Examples of chmod chmod +rw bobo Would make the file read and writeable chmod –w +r bobo Would remove the write permission and set the read permission

24 Setting specific rights There may be times where you may wish to set different right for each of the three groups. (user,group,other) This can be done by using the following; chmod u=rw,g=r,o=r filename This will set the file permissions such that the file owner has read/write access. The group has r and everyone else has read.

25 Permissions Examples chmod o-w file remove write permission from other chmod g+x fileadd execute permission to group chmod u=wr fileExplicitly make permissions for user read and write only All other bits for that access level (owner,group,other) are reset when = is used.

26 Permissions Examples What does the following mean? chmod u=rwx g+rw o-w file explicitly gives user all permissions, adds read and write to group and removes write from other.

27 Using Octal Access Permissions Octal notation consists of the numbers 0-7 In bit positions, the values of the bits are 4 2 1 this represents r w x To determine the octal value, multiply the bit position value by its contents and add them up 101 = 1*4 + 0*2 + 1*1 = 5 110 = 1*4 + 1*2 + 0*1 = 6

28 Using Octal Access Permissions To use octal access permissions, you do the same thing for each level of permissions. Assuming you want to set the following permissions; -rwxrw-r- - -111110100 (1*4+1*2+1*1) (1*4+1*2+0*1) (1*4+0*2+0*1) =764 chmod 764

29 Group and Owner To set ownership of a file chown user file chown ross /etc/passwd To set group ownership of a file chgrp group file chgrp users /etc/passwd -R Recursive (all files and subdirectories)

30 Absolute Pathnames Every file has a pathname A pathname is built by tracing a path from the root directory, through all intermediate directories, to the file String all the filenames (include directories) in the path together, separating them with slashes ( / ) and proceeding them with the root directory ( / ) Example: /usr/src/cmd/date.c

31 Path Names

32 Relative Pathnames Every directory has two intrinsic directories. (this directory).. (the parent directory) These make using relative pathnames easy

33 Relative Pathnames cd../../bobo  takes the user two directories up in the tree then in to the bobo directory. cd./bobo  means from your current directory enter the bobo directory

34 inode inodes (or index nodes) contain information about files inodes do not contain path or file name information inodes contain the following information owner 1000 group 300 type regular file permissions rwxr-xr-x last accessed Aug 23 1999 1:45 PM last modified Jul 4 1999 9:17 AM size 6030 bytes number of links 2 disk addresses

35 inode inodes are essentially entries in a lookup table These are similar to FAT tables

36 LiNk - ln Create a pseudonym (shortcut) for an existing file Syntax: ln [-fs] filename [linkname] f - force a hard link to a directory, only available to supersuser s - create a symbolic (soft) link Hard links are default, they create a pointer to the file Symbolic, or soft links, create an indirect pointer to the file via the pathname Although only the superuser can create a hard link to a directory, any user can create a soft link Soft links also work across file systems

37 Why Hard and Soft Links? Hard links all have equal status When a file with hard links is deleted, the actual file remains until all of the hard links have been deleted When soft links have the original file deleted links will remain but be broken. Soft links can also be confusing when used to change directories Suppose you have a soft link called My_Dir that points to your home directory, /home/bobo and you cd My_Dir Then, if you execute pwd, it shows /home/bobo! pwd shows the name of the linked-to directory rather than the name of the link

38 Why Not Just cp? ln creates a pseudonym for the given file No new inode(sector) is created Only one copy of the actual file exists Modifications via either filename affect the file cp creates a new copy of the given file A new inode is created Twice as much disk space is used Modifications to the copy are not reflected in the original


Download ppt "The Unix File System R Bigelow. The UNIX File System The file system refers to the way in which UNIX implements files and directories. The UNIX file system."

Similar presentations


Ads by Google