1.1 File System Implementation A possible file system layout.

Slides:



Advertisements
Similar presentations
MORE FILE ATTRIBUTES. ls –l to display file attributes (properties) Listing of a specific directory Ownership and group ownership Different file permissions.
Advertisements

Links Learning Objectives: 1. To understand the basics of links & its usage 2. To learn the construction / removal of different types of links 3. To distinguish.
UNIX file systems Learning Objectives: 1. To understand the basics of file systems 2. To understand the hierarchical structure in Unix file system 3. To.
Introduction to Unix (CA263) File System
Exploring the UNIX File System and File Security
File security and Permissions A file is owned by the user who created it That user can then specify who can read, write and execute that file A file when.
Linux+ Guide to Linux Certification, Second Edition
Links Learning Objectives: 1. To understand the basics of links & its usage 2. To learn the construction / removal of different types of links 3. To distinguish.
More Shell Basics CS465 - Unix. Unix shells User’s default shell - specified in /etc/passwd file To show which shell you are currently using: $ echo $SHELL.
Linux Linux File System.
CS 497C – Introduction to UNIX Lecture 16: - File Attributes Chin-Chih Chang
Guide To UNIX Using Linux Third Edition
7/15/2015B.RamamurthyPage 1 File System B. Ramamurthy.
Links Software Tools. Lecture 4 / Slide 2 Links l A link is a pointer to a file. l In fact, in UNIX all filenames are just links to a file. Most files.
Linux Installation and Administration – Lesson 5 Tutor: George Papamarkos Topic: Devices in Linux.
Filesystem Hierarchy Standard (FHS) –Standard of outlining the location of set files and directories on a Linux system –Gives Linux software developers.
The file structure and related utilities CS240 Computer Science II.
Manage Directories and Files in Linux
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
1 File Management Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of Technology
Files & Directories Objectives –to be able to describe and use the Unix file system model and concepts Contents –directory structure –file system concepts.
1 Lecture 2 Working with Files and Directories COP 3344 Introduction to UNIX.
Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks.
Unix Basics Chapter 4.
Linux Un*x Overview Peter Norton’s Guide to Unix Running Linux (O’Reilly)
Linux Operations and Administration
File Permissions. What are the three categories of users that apply to file permissions? Owner (or user) Group All others (public, world, others)
Linux+ Guide to Linux Certification, Second Edition
Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2011 by the Trustees of Indiana University except as noted.
The UNIX File System. The UNIX File A file is a container for storing information and data. Filename limited to 255 characters. Can’t contain / or NULL.
Find Find basics. find ~ -name myfile –print find directory criteria This will search the home directory (~) looking for files.
Workbook 5 - Part 2 The Linux Filesystem RH030 Linux Computing Essentials.
Chapter Two Exploring the UNIX File System and File Security.
Lesson 9-Setting and Using Permissions. Overview Describing file permissions. Using execute permissions with a file. Changing file permissions using mnemonics.
Managing Files. Module 5 Managing Files ♦ Introduction “On a Linux system, everything is a file; if something is not a file, it is a process.” ♦ Topics.
Linux file system "On a UNIX system, everything is a file; if something is not a file, it is a process." Sorts of files (on a Linux system) Directories:
Chapter Two Exploring the UNIX File System and File Security.
ITR3 lecture 6: intoduction to UNIX Thomas Krichel
Project 6 Unix File System. Administrative No Design Review – A design document instead 2-3 pages max No collaboration with peers – Piazza is for clarifications.
Chapter 4: File Security & Permissions Also: Hard and Soft Links, see p77-80 &
E X C E E D I N G E X P E C T A T I O N S Basic LINUX Linux System Administration Dr. Hoganson Kennesaw State University Operating Systems Directory structure:
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification, Third Edition
1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem.
System Administration – Part 2. Devices in UNIX are files: A device can be accessed with different file names All device files are stored in /dev or its.
Managing Files CSCI N321 – System and Network Administration Copyright © 2000, 2007 by the Trustees of Indiana University except as noted.
Manage Directories and Files in Linux Part 2. 2 Identify File Types in the Linux System The file types in Linux referred to as normal files and directories.
Λειτουργικά Συστήματα – Lab2 Γιάννης Πετράκης. Directory Navigation and Control  The Unix file system is set up like a tree branching out from the root.
Linux Commands C151 Multi-User Operating Systems.
Slide: 1 UNIX FILE SYSTEM By:Qing Yang ID: Operating System Research Topic December, 2000.
1 Lecture 2 Working with Files and Directories COP 3353 Introduction to UNIX.
UNIX filesystem CS 2204 Class meeting 2 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
CSCI 330 UNIX and Network Programming Unit II Basic UNIX Usage: File System.
UNIX file systems Learning Objectives: 1. To understand the basics of file systems 2. To understand the hierarchical structure in Unix file system 3. To.
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.
BIF703 File Permissions. As you recall from our previous notes, that Unix/Linux recognizes everything as a file: Regular files to store data, programs,
ORAFACT The Linux File System. ORAFACT Filesystem Support Support for dozens of filesystem types including: Minix, ext2, MS-DOS, UMSDOS, VFAT, NTFS, NFS,
ULI101 Week 05. Week Overview ● File system links ● Hard and symbolic links ● Process management ● Storage quota information (quota) ● Printing.
Linux Filesystem Management
Getting Started with Linux
Introduction to Unix – CS 21
Chapter 4: Understanding Users and File Systems
Linux file system "On a UNIX system, everything is a file;
Linux Basic Commands Visit to more Learning Resources.
BIF703 File Permissions.
Exploring the UNIX File System and File Security
File System B. Ramamurthy B.Ramamurthy 11/27/2018.
Security and File Permission
Software I: Utilities and Internals
January 26th, 2004 Class Meeting 2
Presentation transcript:

1.1 File System Implementation A possible file system layout

1.2 Implementing Files Storing a file as a linked list of disk blocks

1.3 Index Node (inode) Each file of whatever type, stored in a disk partition, is allocated a number (called its inode number) which is actually the index number of an entry in an array stored on the disk. Each element of the array is an inode which stores the administrative information about a single file (such as, when it was created, who owns it and where the data blocks for this file are stored on the disk partition). This information can be displayed by using stat:  $ stat file1 File: `file1' Size: 123 Blocks: 8 IO Block: 4096 Regular File Device: 306h/774d Inode: Links: 2 Access:(0644/-rw-r--r--)Uid:(501/rinaldi)Gid:(501/docenti) Access: :58: Modify: :58: Change: :05:

1.4 Implementing Files An example i-node: it contains only the first 12 addresses of the blocks of the file.

1.5 A UNIX i-node

1.6 Index Node (inode) It is the inode number of a file that is stored in a directory alongside the file's name. So, essentially, directories are just tables that associate file names with inode numbers. Each file name and inode number pair in a directory is called a link. games mail news work inode

1.7 Linking Files A link is a pointer to another file. Remember that a directory is nothing more than a list of the names and i-numbers of files. A directory entry can be a hard link, in which the i-number points directly to another file. When a hard link is made, then the i- numbers of two different directory file entries point to the same inode. ln utility makes link between files.  $ cat > file Hello ! ^D $ ls -l file -rw-rw-r-- 1 rinaldi rinaldi 8 apr 7 14:22 file $ ln file fileln $ ls -li file* rw-rw-r-- 2 rinaldi rinaldi 8 apr 7 14:22 file rw-rw-r-- 2 rinaldi rinaldi 8 apr 7 14:22 fileln $ rm file $ ls -l fileln -rw-rw-r-- 1 rinaldi rinaldi 8 apr 7 14:22 fileln

1.8 Linking Files If the last argument is the name of a directory, then the hard link is made from the directory to all the specified filenames $ mkdir ~/didattica/corsi $ ln file* ~/didattica/corsi $ ls -l -rw-rw-r-- 2 rinaldi rinaldi 8 apr 7 14:22 fileln $ cd $ rm fileln $ ls -l ~/didattica/corsi/ -rw-rw-r-- 1 rinaldi rinaldi 8 apr 7 14:22 fileln A hard link may not be created from a file on one file system to a file on a different file system. To get around this problem, create a symbolic link instead.

1.9 Linking Files By default, ln makes hard links, with the “-s” option, it makes symbolic (or "soft") links.  $ ln -s /usr/include/stdio.h stdio.h $ ls -l stdio.h lrwxrwxrwx 1 rinaldi rinaldi 20 apr 7 14:46 stdio.h -> /usr/include/stdio.h  $ ln -s ~/didattica/corsi/fileln file $ ls -l file lrwxrwxrwx 1 rinaldi rinaldi 37 apr 7 14:50 file -> /home/rinaldi/didattica/corsi/fileln $ rm ~/didattica/corsi/fileln $ ls –l file lrwxrwxrwx 1 rinaldi rinaldi 37 apr 7 14:50 file -> /home/rinaldi/didattica/corsi/fileln $ cat fileln cat: fileln: No such file or directory

1.10 File Attributes The time stamp: each file has three dates associated with it:  The creation time  The last modification time  The last access time The owner: every file is owned by one user of the system The group: every file has also a group of users associated with it. The most common group for user files is called users which is usually shared by all the users account on the system The permissions: every file has permissions associated with it which tell who can access to that file, or change it, or in the case of programs, execute it. Each of this permission can be toggled separately for the owner, the group and all the other users.

1.11 File Attributes The information of the files can be obtained by means of the command ls –l $ ls -l totale 28 drwxrwxr-x 4 rinaldi rinaldi 4096 mar 27 16:52 Desktop/ drwxrwxr-x 2 rinaldi rinaldi 4096 mar 21 17:35 didattica/ drwxr-xr-x 2 rinaldi rinaldi 4096 mar 14 19:21 Documents/ -rwx rinaldi rinaldi 1999 mar 31 13:25 file* -rw-r--r-- 1 rinaldi rinaldi 123 mar 31 12:58 file1 drwxrwxr-x 2 rinaldi rinaldi 4096 mar 21 17:35 ricerca/ drwx rinaldi rinaldi 4096 mar 14 18:50 tmp/ In addition to the name of each file, print the file type, permissions, number of hard links, owner name, group name, size in bytes, and timestamp, normally the modification time.

1.12 Permissions Everything in UNIX is managed via files, even access to devices (via the device files in '/dev') like printers, modems, sound cards etc. If you do not have the permission on a file which represents a device, you can't use that device. The first concept of permissions is ownership. You either own a file or a directory you have created or that has been handed over to you by using the chown command. If you own a file, you can do whatever you want with it, usually. Often more than one account needs access to a file or device. Changing the ownership of this file every time someone else needs access to it would be very tedious to say the least. This is why ownership is not only provided for single accounts but also for groups. Groups are defined in /etc/group, an entry in this file looks like this:  group_name:x:group_ID:group_member

1.13 Permissions To see a list of groups your current account is a member of, use the command  $ groups So, if you are member of a group and that group has permissions on a file, you can do something with that file, even if you are not its owner. An average UNIX system has some files and more. A majority of them has to be accessible in some way by all the users on a system. One way to achieve this could be to create a 'catch-all' group which would unite all the accounts on a system and assign all these files to this group. So, we can divide file permissions into 3 categories:  Owner permissions  Group permissions  Other permissions

1.14 Permissions The output of the ls -l command shows the permissions of a file/directory $ ls -l drwxrwxr-x 4 rinaldi rinaldi 4096 mar 27 16:52 Desktop/ drwxr-xr-x 2 rinaldi rinaldi 4096 mar 14 19:21 Documents/ -rwx rinaldi rinaldi 1999 mar 31 13:25 file* -rw-r--r-- 1 rinaldi rinaldi 123 mar 31 12:58 file1 drwxrwxr-x 2 rinaldi rinaldi 4096 mar 21 17:35 ricerca/ drwx rinaldi rinaldi 4096 mar 14 18:50 tmp/ the flag 'r' is for reading, 'w' for writing, and 'x' is for executing. The first field has three options, d, l or -, where d indicates a directory, l a symbolic link, and - a file. The other nine fields indicate the owner permissions, group permissions and 'all others' permissions.  Owner | Group | Others = rw- | r-- | r-- (  file1)

1.15 Permissions on directories Permissions on directories are different from permissions on files. Here: drwxrwxr-x 4 rinaldi rinaldi 4096 mar 27 16:52 Desktop/ drwxr-xr-x 2 rinaldi rinaldi 4096 mar 14 19:21 Documents/ drwx rinaldi rinaldi 4096 mar 14 18:50 tmp/  r indicates that the contents of the directory can be listed  w indicates that the contents of the directory can be changed (copy, move, create new files)  x indicates that users can " cd " to that directory, read, write, execute programs and search in the directory.

1.16 Changing permission settings The command, chmod lets you change the permission mode settings of a file/directory. You also need to specify 3 digits with the chmod command. These digits dictate what permissions will be applied. The first digit determines the permissions for the owner, the second digit determines the permissions for the group, and the third for others. To change the permissions of the file “ file1 ” type:  chmod XYZ file1 where XYZ represents 3 digits e.g. 666 The first digit is the sum of 4 for read permission, 2 for write permission and 1 for execute permissions. user group others  chmod 640 file1 rw- r  chmod 754 file1 rwx r-x r--  chmod 664 file1 rw- rw- r--

1.17 Changing permission settings  chmod a+rw hello.c  chmod o-w hello.c  chmod og+rx prog*  chmod g=rw rep*  chmod +w * The option -R changes recursively the permissions of a directory and its contents WhoActionPermission u = user+ = addr = read g = group- = deletew = write o = other= = assignx = execute a = all

1.18 Changing Groups If you are member of several groups and you create a file, what is the group id of the file ? Although you may be a member of several groups, only one of them is your effective group at any given time. When a process creates a file, the group id of the file is set to the effective group id. The system administrator chooses which one of your groups is used as your login shell’s effective group id. However, you may create a shell with a different effective group id by using newgrp utility $ date > ~/test1 … creates “test1” from a “rinaldi” group shell $ newgroup informatica $ date > ~/test2 … creates “test2” from a “informatica” group shell ^D $ ls –lg test* -rw-r--r-- 1 rinaldi 30 mar 27 16:52 test1 -rw-r--r-- 1 informatica 30 mar 27 16:52 test1

1.19 The Linux Proc File System The proc file system does not store data, rather, it creates a directory for each process. The name of the directory is the PID of the process  $ cd /proc ; ls 1/1023/1089/1111/… 1839/ … 2289/ … $ ps PID TTYTIMECMD 1839pst/ bash 2289pst/ ps A proc directory collects the appropriate information about the process (command line, environ strings, status, …)  $ cd 1839 ; ls cmline cwd environ exe fd maps mem mounts stat statm status So, proc directories contain many information about the CPU, disk partitions, devices,... The user programs can obtain these information for learning many information about the behavior of the system in a safe way. pstree: shows the depencies between all the active processes kill: kills a process

1.20 Mounting The operating system attaches a physical file system to its virtual file system by means of the command mount. This operation is called mounting and its format is:  $ mount –t type device mount-point Examples: $ mount –t ext2 /dev/hda6 / The partition of ext2 is called hda6. ( hd for hard drive, a for the first of these, and 6 for the sixth partition). The documentation of the devices is in /usr/src/linux/Documentation/devices.txt.  $ mount –t vfat /dev/hda1 /mnt/windows  $ mount –t msdos /dev/fd0 /mnt/floppy  $ mount –t iso9660 /dev/hdc /mnt/cdrom The command mount is used by the super-user. The operating system performs mount –a during the boot. This command mounts the file systems listed in /etc/fstab. We can establish the mounted devices by typing in: $ mount We can unmount the file system by using umount  umount /mnt/floppy

1.21 Compressing Files The compressed file types in Linux are:  file.Z -- compressed with the compress : $ compress file1 $ uncompress file1.Z  file.z, file.gz -- compressed with the GNU zip program: zip, gzip. $ gzip –-best huge_file $ gunzip huge_file.gz  file.bz2 -- compressed with bzip2 $ bzip2 –9 huge_file $ bunzip2 huge_file.bz2 We can view a file in a compressed archive without extracting it, by means of zcat or bzcat  $ zcat huge_file.gz  $ bzcat huge_file.bz2

1.22 Archiving Files We can use tar to store files in an archive, to extract them from an archive, and to do other types of manipulation. The synopsis of tar is:  $ tar options tarfilename filelists  Some options are -c create an archive -x extract from an archive -t list the contents of an archive -v encourage verbose output -u update only files that are more recent than those archived -f use the “tarfilename” as filename of the archive (the name of “tarfilename” is /dev/rmt0 by default) Example:  tar -cvf logfile.tar logs.*  tar -tvf logfile.tar  tar -xvf logfile.tar  tar -cvzf logfile.tar.gz logs.*