Presentation is loading. Please wait.

Presentation is loading. Please wait.

UNIX Files and Security Software Tools. Slide 2 File Systems l What is a file system? A means of organizing information on the computer. A file system.

Similar presentations


Presentation on theme: "UNIX Files and Security Software Tools. Slide 2 File Systems l What is a file system? A means of organizing information on the computer. A file system."— Presentation transcript:

1 UNIX Files and Security Software Tools

2 Slide 2 File Systems l What is a file system? A means of organizing information on the computer. A file system is a logical view, not necessarily a physical view. l What does the file system provide: n ways to create, move, and remove files n ways to order files n security l Examples of file systems: n DOS, Macintosh, CD-ROM, UNIX, NFS (networked file system)

3 Slide 3 l Hierarchical Organization l Root of tree is at top denoted by ‘/’ l Kinds of files: n Directory files (the branches in the tree) n Regular files (leaves in the tree) UNIX File Systems / binlibhomes horner.mailrctop10111 jbond...

4 Slide 4 Home and Working Directories l Home directory n The directory you are in when you first login in n This is your space; you control security n Place to put your personalized.startup files Your working directory after typing cd with no arguments l Working directory n Can access files in your working directory by simply typing the filename n To access files in other directories, must use a pathname pwd command prints the working directory cd command changes the working directory

5 Slide 5 Directory Shorthands l “.” is the directory itself l “..” is the parent directory l In most shells “~” means your home directory) l ~user means user’s home directory, so: $ more ~jbond/.plan looks at the file.plan in /homes/jbond, which is jbond’s home directory.

6 Slide 6 Special Directories “ / ” (pronounced “slash” and also called “the “root”) is the ancestor of all files in the file system /bin and /usr/bin contain UNIX utilities (e.g., cat ) /dev contains files which describe “devices” such as terminals and printers /etc has administrative programs like password files /tmp is for temporary files; periodically deleted l Every directory has at least two entries: “.” is the directory itself, and “..” is the directory’s parent

7 Slide 7 Naming Files l Files in the same directory can’t have the same name Case sensitive: secret and Secret are different Files are sometimes named with an extension (e.g., bond.cpp, 007.jpg ) to show the file’s content. l You cannot create a file named “.” or “..” “Invisible” files and directories (those that don’t appear using ls ) have a period as the first character (e.g.,.plan ). Some programs use invisible files to store information.

8 Slide 8 Pathnames l Simple filenames Can only be used if files are in working directory l Relative pathname A string of directory references, beginning with the working directory. Examples:./secret1../007/names top10/LG7soBad l Absolute pathname A pathname beginning at the root. e.g.,: /homes/jbond/.plan /etc/passwd

9 Slide 9 Directory Commands mkdir makes a new directory (if you have permission to do so). With a simple pathname, mkdir makes a new directory in your working directory. $ pwd /homes/jbond/111 $ ls -l total 6 -rw-r--r-- 1 jbond cs 154 Feb 4 15:00 letter3 -rw-r--r-- 1 jbond cs 64 Feb 4 15:00 names drwxr-xr-x 2 jbond cs 512 Feb 4 15:00 secret/ $ mkdir newdir $ ls -l total 8 -rw-r--r-- 1 jbond cs 154 Feb 4 15:00 letter3 -rw-r--r-- 1 jbond cs 64 Feb 4 15:00 names drwxr-xr-x 2 jbond cs 512 Feb 4 15:26 newdir/ drwxr-xr-x 2 jbond cs 512 Feb 4 15:00 secret/

10 Slide 10 Directory Commands rmdir deletes a directory (if you have permission). $ rmdir newdir $ ls -l total 6 -rw-r--r-- 1 jbond cs 154 Feb 4 15:00 letter3 -rw-r--r-- 1 jbond cs 64 Feb 4 15:00 names drwxr-xr-x 2 jbond cs 512 Feb 4 15:00 secret/ $ rmdir /usr rmdir: directory "/usr": Search or write permission needed

11 Slide 11 Directory Commands mv can be used to move a file to another directory. $ ls letter3names newdir/secret/ $ mv letter3 secret $ ls names newdir/ secret/ $ ls secret letter3 mv can be used to move a directory into a directory. $ ls namesnewdir/secret/ $ mv newdir secret $ ls namessecret/ $ ls secret letter3newdir/

12 Slide 12 Directory Commands You can also move several files at once using mv $ ls letter1letter2namessecret/ $ mv letter* secret $ ls namessecret/ $ ls secret letter1letter2

13 Slide 13 Security and Access Permissions l There are three types of users: n The owner of the file (user) n The group of the file (group) n Anyone else (other) l There are three types of permission (independent of each other): n Read permission n Write permission Execute permission

14 Slide 14 Use ls -l to see file permissions -rw-r--r-- 1 jbond cs 154 Feb 4 15:00 letter3 There are four sets of items in the permissions: -rw-r--r-- n The type is: “ - ” regular files, “ d ” directories, “ l ” symbolic links. n The next nine characters indicate if the file is readable, writable, or executable for the file owner, the file group, or other users, respectively. Security and Access Permissions Permissions User Group Byte size Last modification Name #links user group other type

15 Slide 15 Security and Access Permissions Examples: $ ls -l total 34 -r-xr-xr-x 1 jbond cs 9388 Feb 4 16:31 cat* -rw-r--r-- 1 jbond cs 154 Feb 4 15:00 letter1 -rw------- 1 jbond cs 64 Feb 4 15:00 names drwxr-xr-x 2 jbond cs 512 Feb 4 15:41 newdir/ drwxr-xr-x 2 jbond cs 512 Feb 4 16:38 secret/ d--------- 2 jbond cs 512 Feb 4 16:39 secret1/ dr--r--r-- 2 jbond cs 512 Feb 4 16:39 secret2/ d--x--x--x 2 jbond cs 512 Feb 4 16:38 secret3/

16 Slide 16 Directory Permissions Can use ls -ld to lists a directory’s information (instead of its contents): $ ls -l secret total 4 -rw-r--r-- 1 jbond cs 154 Feb 4 16:38 letter1 -rw-r--r-- 1 jbond cs 34 Feb 4 15:00 letter4 $ ls -ld secret drwxr-xr-x 2 jbond cs 512 Feb 4 16:38 secret/

17 Slide 17 Directory Permissions l Directory read permission means that you can see what files are in the directory. l Directory write permission means that you can add/remove/rename files in the directory. l Directory execute permission means that you can search the directory (i.e., you can use the directory name when accessing files inside it).

18 Slide 18 Directory Permissions $ ls -ld secret* drwxr-xr-x 2 jbond cs 512 Feb 4 16:38 secret/ d--------- 2 jbond cs 512 Feb 4 16:39 secret1/ dr--r--r-- 2 jbond cs 512 Feb 4 16:39 secret2/ d--x--x--x 2 jbond cs 512 Feb 4 16:38 secret3/ $ ls -l secret* secret: total 2 -rw-r--r-- 1 jbond cs 1054 Feb 4 16:38 letter1 secret1 unreadable ls: secret2/letter1: Permission denied secret2: total 0 secret3 unreadable

19 Slide 19 Directory Permissions Directory execute permission means that you can do ls and cp on individual files in the directory. $ ls -l secret*/letter1 -rw-r--r-- 1 jbond cs 154 Feb 4 16:38 secret/letter1 -rw-r--r-- 1 jbond cs 154 Feb 4 16:39 secret3/letter1 n Real-life Example: What if you want your friend to get a file and no one else? Solution: Set the directory execute permission to “on” and read permission to “off” (like directory secret3 ), and the file read permission to “on”. Tell your friend the filename (the complete path). This allows your friend to access the file by typing the exact filename. Others will not know that the file exists. drwxr-xr-x secret/ d--------- secret1/ dr--r--r-- secret2/ d--x--x--x secret3/

20 Slide 20 Changing Permissions The chmod command is used to modify permissions. chmod can only be used by the owner of a file/dir. l The arguments are: chmod [ugoa] [+-=] [rwx] [file/dir] In other words: n Optionally, one of the characters: u (user/owner), g (group), o (other), or a (all). n Optionally, one of the characters: + (add permission), - (remove permission), or = (set permission). n Any combination of the characters r (read), w (write), or x (execute).

21 Slide 21 Permission Example To let everybody read or write the file letter1 $ chmod a+rw letter1 $ ls -l letter1 -rw-rw-rw- 1 jbond cs 154 Feb 4 15:00 letter1 To allow user to execute file letter1 $ chmod u+x letter1 $ ls -l letter1 -rwxrw-rw- 1 jbond cs 154 Feb 4 15:00 letter1* To not let “other” to read or write file letter1 $ chmod o-rw letter1 $ ls -l letter1 -rwxrw---- 1 jbond cs 154 Feb 4 15:00 letter1* To let “group” only read the file letter1 $ chmod g=r letter1 $ ls -l letter1 -rwxr----- 1 jbond cs 154 Feb 4 15:00 letter1*

22 Slide 22 Permission Shortcut chmod allows you to use 3 decimal digits to set the permissions, where user is the 1 st digit, group is the 2 nd digit, and other is the 3 rd digit. l Each of these decimal digits represents a 3-digit binary number for read permission (1 st binary digit), write permission (2 nd binary digit), and execute permission (3 rd binary digit). For example, with the file letter1, to allow user to read, write, and execute (binary 111 = decimal 7), group to read and write (110=6), other to read only (100=4): $ chmod 764 letter1 $ ls -l letter1 -rwxrw-r-- 1 jbond cs 154 Feb 4 15:00 letter1 As another example, with the file letter1, to allow n user to execute only (001=1), n group to write and execute (011=3), other to read and execute (101=5): $ chmod 135 letter1 $ ls -l letter1 ---x-wxr-x 1 jbond cs 154 Feb 4 15:00 letter1


Download ppt "UNIX Files and Security Software Tools. Slide 2 File Systems l What is a file system? A means of organizing information on the computer. A file system."

Similar presentations


Ads by Google