Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:1 Lesson 2: The File System By Simi.

Slides:



Advertisements
Similar presentations
A Guide to Unix Using Linux Fourth Edition
Advertisements

Pre-Assessment Questions
UNIX chapter 07 Files and File System Structure
5 Basic utilities When a user logs in to the Linux operating system the directory that they will start in is their home directory. Most users will have.
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
Linux+ Guide to Linux Certification, Second Edition
The UNIX File System.
Guide To UNIX Using Linux Third Edition
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.
Basic UNIX © McGraw Hill All rights reserved.
File System and Directory Structure in Linux. What is File System In a computer, a file system is the way in which files are named and where they are.
Guide To UNIX Using Linux Fourth Edition
1 THE UNIX FILE SYSTEM By Chokechai Chuensukanant ID COSC 513 Operating System.
The file structure and related utilities CS240 Computer Science II.
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
Chapter 9 Part II Linux Command Line Access to Linux Authenticated login using a Linux account is required to access a Linux system. The Linux prompt will.
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.
Unix Basics Chapter 4.
Linux+ Guide to Linux Certification, Second Edition
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.
Chapter Two Exploring the UNIX File System and File Security.
INTRODUCTION TO LINUX Jacob Chan. GNU/Linux Consists of Linux kernel, GNU utilities, and open source and commercial applications Works like Unix –Multi-user.
1 Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux Commands Some content in this lecture added.
Operating Systems and Using Linux CMSC 104, Lecture 3 John Y. Park 1.
1 Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux Commands Reading None.
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.
UNIX/LINUX OPERATING SYSTEM. Introduction to Linux Introduction to Unix History of UNIX What is Linux Linux Distributions Linux Installation Unix File.
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
Λειτουργικά Συστήματα - Lab1 Γιάννης Πετράκης. The Operating System  Unix is a layered operating system  The innermost layer is the hardware that provides.
1 © 2001 John Urrutia. All rights reserved. Chapter 4 The LINUX Filesystem.
Λειτουργικά Συστήματα – 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.
SUSE Linux Enterprise Desktop Administration Chapter 7 Manage Directories and Files.
UNIX filesystem CS 2204 Class meeting 2 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
UNIX/LINUX OPERATING SYSTEM
CSCI 330 UNIX and Network Programming Unit II Basic UNIX Usage: File System.
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.
Operating Systems and Using Linux Courtesy of John Y. Park 1.
File Management commands cat Cat command cat cal.txt cat command displays the contents of a file here cal.txt on screen (or standard out).
CMSC 104, Version 8/061L03OperatingSystems.ppt Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux.
CMSC 104, Version 9/011 Operating Systems and Using Linux Topics What is an Operating System? Linux Overview Frequently Used Linux Commands Reading None.
BILKENT UNIVERSITY DEPARTMENT OF COMPUTER TECHNOLOGY AND INFORMATION SYSTEMS CTIS156 INFORMATION TECHNOLOGIES II FILES AND FILE SYSTEM STRUCTURE.
Getting Started with Linux
LINUX SYSTEM AND NETWORK ADMINISTRATION created by:gaurav shrivastava contact:-
Chapter 6 File Systems CSNB113 SYSTEM ADMINISTRATION
Lecture 2 Working with Files and Directories
C151 Multi-User Operating Systems
Operating Systems and Using Linux
Operating Systems and Using Linux
Exploring the UNIX File System and File Security
Operating Systems and Using Linux
Operating Systems and Using Linux
Operating Systems and Using Linux
Operating Systems and Using Linux
Operating Systems and Using Linux
Operating Systems and Using Linux
Operating Systems and Using Linux
Module 6 Working with Files and Directories
Chapter 4: The Linux Filesystem
January 26th, 2004 Class Meeting 2
Presentation transcript:

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:1 Lesson 2: The File System By Simi

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:2 Files  A file is a sequence of bytes.  It can be created by a text editor (xemacs or pico) a computer program (such as a C program)

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:3 Files  It may contain a program, data, a document, or other information.  Files that contain other files are called directories (sometimes called folders).

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:4 Linux Filenames  Restrictions May not contain blanks or other reserved characters. Have a maximum length. Are case sensitive.  It is best to stick with filenames that contain letters (uppercase or lowercase), numbers, and the underscore ( _ ) for now.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:5 Organization of Files  Under Linux, files are organized in a tree-like structure.  The top of the tree is represented by the root directory, indicated by “/”, and each of the braches is a directory which can contain sub-directories, or files.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:6 Organization of Files  A directory is a special file. Each directory contains a catalogue of names of its files and sub-directories. Two particular entries exist in all directories:. (the directory itself) and.. (the parent directory)

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:7 Directories  Directories contain files or other directories called subdirectories. They may also be empty.  Directories are organized in a hierarchical fashion.  They help us to keep our files organized.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:8 Directories (con’t) /afs/umbc.edu/users/j/d/jdoe28 junkrecipes notes piescookies CMSC104 apple peach choc_chip apple peach choc_chip

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:9 Subdirectories  Are used for organizing your files  For example, make a subdirectory for CMSC104 make subdirectories for each projectCMSC104 project1 project2... project8 project1 project2... project8

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:10 File Types  The file type is used by the system in order to determine the use to which the file will be put.  Linux file types directory  a catalogue of file names normal files  designed to contain data belonging to users.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:11 File Types symbolic link  a pointer to another file  When a link is the subject of an action, the file pointed to is accessed. special file  assigned to a device controller embedded in the kernel.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:12 File Types  When a special file is accessed, the physical device associated to it is actually acted upon.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:13 Directories, Files and Inodes   In the case of the root directory, that parent is itself.   A directory is a file that contains a table listing the files contained within it, giving file names to the inode numbers in the list.   The information about all the files and directories is maintained in INODE TABLE

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:14 Inodes   An Inode (Index Nodes) is an entry in the table containing information about a file (metadata) including file permissions, UID, GID, size, time stamp, pointers to files data blocks on the disk etc.   Every directory and file is listed in its parent directory.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:15 UNIX File System

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:16 File System  Each node is either a file or a directory of files, where the latter can contain other files and directories.  You specify a file or directory by its path name, either the full, or absolute, path name or the one relative to a location.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:17 File System  The full path name starts with the root, /, and follows the branches of the file system, each separated by /, until you reach the desired file, e.g.:  /home/condron/source/xntp

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:18 File System  A relative path name specifies the path relative to another, usually the current working directory that you are at. Two special directories:. the current directory.. the parent of the current directory

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:19 File System  So if I'm at /home/frank and wish to specify the path above in a relative fashion I could use: ../condron/source/xntp  This indicates that I should first go up one directory level, then come down through the condron directory, followed by the source directory and then to xntp.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:20 Structure of Standard Directories in Unix/Linux  / The ancestor of all directories on the system; all other directories are subdirectories of this directory, either directly or through other subdirectories.  /boot It is a directory with the operating system kernel, loaded into memory during system startup, static files of the boot loader.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:21 Structure of Standard Directories in Unix/Linux  /bin Essential tools and other programs (or binaries).  /dev Files representing the system's various hardware devices. For example, you use the file `/dev/cdrom' to access the CD−ROM drive.  /etc Miscellaneous system configuration files, startup files, etc.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:22 Structure of Standard Directories in Unix/Linux  /home The home directories for all of the system's users.  /lib Essential system library files used by tools in `/bin'.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:23 Structure of Standard Directories in Unix/Linux  / proc Files that give information about current system processes.  /root The superuser's home directory, whose username is root. (In the past, the home directory for the superuser was simply `/'; later, `/root' was adopted for this purpose to reduce clutter in `/'.)

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:24 Structure of Standard Directories in Unix/Linux  sbin Essential system administrator tools, or system binaries.  /tmp Temporary files.  /usr Subdirectories with files related to user tools and applications.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:25 Pathnames  Pathnames provides a flexible method of identifying files and directories within the file system.  A pathname can be thought of as describing a route or “Path” through the file system hierarchy to the file or directory.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:26 Absolute and Relative Pathnames  There are two types of pathname: Absolute and relative. Absolute: An absolute pathname describes the path to the file or directory starting from the root (/) directory. /usr /bin /tty

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:27 Relative Pathname Relative: A relative pathname describes the path to the file or directory from the current directory. bin/tty The current directory is the reference point if the pathnames does not start with a /

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:28 Home directory  Every user on the system has a “home directory” It is a user’s start location when the user logs in Becomes the working (current) directory at login time

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:29 Home directory  Startup and configuration files reside here.  Session customization files, such as profile, login, kshrc  Application startup files, such as Xdefaults.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:30 Moving in the Directory Tree  (dot) is the current directory. .. (dot-dot) is the parent directory.  Use the Linux command cd to change directories.  Use dot-dot to move up the tree.  Use the directory name to move down.  Use the complete directory name (path name) to move anywhere.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:31 Wildcard Characters  You will find wildcard characters useful when manipulating files (e.g., listing or moving them).  The wildcard characters are * and ?  ? is used to represent any single character.  * is used to represent 0 or more characters.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:32 Directory Commands  cd Change directory  cd Change to home directory  pwd Print working directory

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:33 Listing directories  ls command is used to list directories, the commonly used options that can be given to the command are :  ls[options] [files]  Options are:  -llong (full) listing  -a list all files including hidden dot files.  -C/ -xlist in columns sorted down /across

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:34 List options  -Rrecursive listing of subdirectories  -tsort by time rather than name  -dlist directory itself, not it’s contents.  -sshow size of the files in blocks not in bytes  -hshow the size in human readable format (4K, 16M,1G etc). This option should be used in conjunction with the –s option.  $ls –al command is used for long listing of directories

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:35 Listing  It shows the Type of file: - plain file, d directory, / symbolic link  Permissions: r read, w write, x execute  Link count  File ownership: user and group  Size in bytes  Date and time of last modification  Filename

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:36 File List  Example: $ ls –l - rw-r--r-- 1 einstein metal may 10 13:45 chap01 -rw-r--r-- 1 einstein metal 4174 may 10 15:01 chap02 -rw-rw-rw- 1 einstein metal 84 feb 12 12:30 dept.lst -rw-r--r-- 3 dennis metal 9156 mar genie.sh drwxr-xr-x 2 einstein metal 64 may 9 10:31 helpdir drwxr-xr-r 2 einstein metal 320 may 9 09:57 progs Permissions Link countUser and group Size in bytes Date and time of last modification File name File Type

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:37 Making directory  Syntax # mkdir directory name  Example # mkdir hello

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:38 Removing directory  (i) To delete an empty directory Syntax # rmdir directory name Example # rmdir hello

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:39 To delete directory recursively  (ii) To delete a directory and all of it’s contents recursively, including subdirectories and their contents.  Syntax # rm -r directory name  Example # rm –r myfile

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:40 Copying files or directory  (i)Syntax: # cp source file target file  Example # cp myfile /home/Simi  (ii) To copy directory, subdirectory and files recursively # cp –r chat./rat # cp –r chat./rat

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:41 Renaming files or directory  Syntax # mv oldfilename/directory newfilename/directory  Example # mv ABC xyz

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:42 Looking File contents  (i) The command that is used to type a file to the screen is cat (for concatenation). It will copy the specified file to the screen. Example: Example:  # cat filename

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:43 Creating new file  (ii) The command used to create a new file with specified filename is Syntax # cat > filename Example: # cat > hello ….. ….. Ctrl+d - to save the file. Example: # cat > hello ….. ….. Ctrl+d - to save the file.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:44 Appending a file  To append an already existing file:  Syntax: # cat >> filename # cat >> filename  Example: # cat >> hello

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:45 More and Less commands  To show a file one screen full at a time, the more command can be used.  Syntax # more # more  To interactively scroll through a file, the less command should be used.  Syntax # less # less

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:46 WC command  The wc command counts words, lines, and characters in a file. –w, -l and –c options to restrict the count to the obvious parameters.  Syntax wc [-cwl] [file…] wc [-cwl] [file…]

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:47 Counting characters in file  To count the number of characters in file.  Syntax wc –c filename ( for characters) Example wc –c hello

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:48 To count number of lines  Syntax wc –l filename( for lines)  Example wc –l hello wc –l hello

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:49 File Linkages  Conventional link (hard link) It is possible to associate several names to the same file. Any operation may be carried out by citing arbitrarily any link name. The kernel maintains a count of the links assigned to each file.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:50 File Linkages  When a link is created, this number is incremented.  When a link is deleted, the number is decremented.  When the number becomes zero, the file contents are effectively deleted, and the space on the disk is made free

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:51 File Linkages Cons  It is impossible to create links to directories.  It is impossible to create links between files residing on different file systems

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:52 Symbolic link (soft link)  Symbolic link (soft link) While conventional links are additional names to a file, symbolic links are pointers to other files.  Can point to any sort of file, even non- existent ones.  A symbolic link is a special type of file whose contents specify the name of the target file.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:53 Creating Links  The ln command creates a link to a file  Syntax  ln [-snf] file target where [snf] are the options -ssymbolic or soft link -ndon’t overwrite existing filenames -fforce overwrite of existing filename

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:54 Symbolic links  symbolic link can be created with ln command:  $ ln –s /path/to/file1.txt file2.txt  $ ls –l

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:55 Symbolic links  Above command will create a symbolic link to file1.txt, file1.txt is target file name and file2.txt is symbolic filename.  Listing of all the link files with inode number is  $ls -il

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:56 Hard links  It must be within a file system, only root can link to directories.  Hard links cannot links directories, cannot cross file system boundaries.  Hard links always refer to the source, even if moved or removed.  Inodes are associated with precisely one directory entry at a time.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:57 Hard links  With hard links it is possible to associate multiple directory entries with a single inode.  In hard link one file is accessed by many files but inode number is same for all the files accessing the files.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:58 Hard links  To create a hard link ln command is used.  # ln /root/file1 /root/file2 # ls –l  Above commands create a link to file1.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:59 File Attributes  Attributes its size in bytes the owner identifier of the file, that is, the user who created the file the group identifier of users who own the file. the number of links. the access permissions. the dates of access and modification.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:60 File Attributes  Access permissions the permission to read/write/execute data for the owner, the owning group and the rest of users. For a directory  read permission: the contents of a file may be listed

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:61 Elements of a Block Group  write permission: entries in the directory may be added or deleted  execute permission: the directory may be examined. Super block Magic number: for ext2, 0xEF53 Revision Level Block group number Block size Blocks per group

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:62 Elements of a Block Group Free blocks Free inodes First inode: the inode number of the first inode in the file system ( the directory entry for the “/” directory)

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:63 Elements of a Block Group  Descriptors The block number of the block (allocation) bitmap The block number of the inode (allocation) bitmap The block number of the starting block for the inode table

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:64 Inode  Every file and directory in the file system is described by one and only one inode.  The inodes for each block group are kept in the inode table together with an inode (allocation) bitmap.  Elements mode: permissions owner information

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:65 Inode  The user and group identifiers size timestamps  The time that the inode was created Datablocks  Pointers to the blocks that contains the data  The first 12 are direct pointers to data blocks  The last three entries are for indirect blocks.

Copyrights© 2008 BVU Amplify DITM DATA BASE MANAGEMENT system Page:66 Thank You Thank You