Presentation is loading. Please wait.

Presentation is loading. Please wait.

BILKENT UNIVERSITY DEPARTMENT OF COMPUTER TECHNOLOGY AND INFORMATION SYSTEMS CTIS156 INFORMATION TECHNOLOGIES II FILES AND FILE SYSTEM STRUCTURE.

Similar presentations


Presentation on theme: "BILKENT UNIVERSITY DEPARTMENT OF COMPUTER TECHNOLOGY AND INFORMATION SYSTEMS CTIS156 INFORMATION TECHNOLOGIES II FILES AND FILE SYSTEM STRUCTURE."— Presentation transcript:

1 BILKENT UNIVERSITY DEPARTMENT OF COMPUTER TECHNOLOGY AND INFORMATION SYSTEMS CTIS156 INFORMATION TECHNOLOGIES II FILES AND FILE SYSTEM STRUCTURE

2 Files And File System Structure ● Objectives – To explain the Linux file concept – To discuss various types of files supported by Linux – To describe the attributes of a file – To explain the notion of pathnames – To explain the user view of a linux file system – To discuss representation of a file inside the Linux file system – To describe how a Linux file is stored on the disk 2 CTIS156 INFORMATION TECHNOLOGIES II

3 Files And File System Structure ● Introduction: – Most computer system users work with the file system structure: ● Creating, ● reading, ● writing/modifying and ● executing files – Therefore the user needs to understand: ● What a file in Linux ● How files can be organized and managed ● How they are represented inside the OS ● How they are stored on the disk 3 CTIS156 INFORMATION TECHNOLOGIES II

4 Files And File System Structure ● The Linux File Concept – In Linux, a file is a sequence of bytes – Everything (including all devices) is treated as a file in Linux ● A simple file (text/executable) ● A directory ● A keyboard ● A printer ● A disk drive ● A network interface card, etc.. 4 CTIS156 INFORMATION TECHNOLOGIES II

5 Files And File System Structure ● Types of Files – Linux supports five file types: ● Simple/ordinary files ● Directory ● Symbolic(soft) link ● Special file ● Named pipe 5 CTIS156 INFORMATION TECHNOLOGIES II

6 Files And File System Structure ● Types of Files (cont) – Simple/ordinary files: ● Used to store information and data on a secondary storage device (a disk) ● Can contain a – C, C++, Java source code – an executable program (a compiler, a text editor, etc.) – Pictures, audio, graphics, etc ● They are not treated differently by Linux ● However they are treated differently by application programs (e.g. a C compiler treats.c file as a source file) 6 CTIS156 INFORMATION TECHNOLOGIES II

7 Files And File System Structure ● Types of Files (cont) – Simple/ordinary files (cont): ● File names can be up to 255 characters ● Any characters can be used in a filename ● Nonprintable characters are not recommended (e.g. A space character) ● File extensions mean nothing to Linux ● Certain file extensions are given and may be required by the applications (e.g..c file extension is required by C compilers) 7 CTIS156 INFORMATION TECHNOLOGIES II

8 Files And File System Structure ● Types of Files (cont) – Simple/ordinary files (cont): ● Commonly used extensions for some applications: 8 CTIS156 INFORMATION TECHNOLOGIES II

9 Files And File System Structure ● Types of Files (cont) – Directory: ● Contains the names of files and/or other directories ● A directory file contains an array of directory entries. – Structure of a directory entry: 9 CTIS156 INFORMATION TECHNOLOGIES II

10 Files And File System Structure ● Types of Files (cont) – Directory: (cont) ● Inode number (unique number) is a four byte long, index value of an array on the disk ● An element of this array, known as an index node (or inode) contains file attributes: – File size – File owner – Time created – Time last modified – Access permissions, etc. ● Linux allocates and inode, whenever a new file is created 10 CTIS156 INFORMATION TECHNOLOGIES II

11 Files And File System Structure ● Types of Files (cont) – Link File: ● Contains a symbolic link to a file in another directory ● Can have a different name than the original file ● Allows multiple access points (or names) to the original file 11 CTIS156 INFORMATION TECHNOLOGIES II

12 Files And File System Structure ● Types of Files (cont) – Special File (Device): ● Every hardware device (screen, keyboard, harddisk, Cdrom, etc) is associated a special file in Linux ● All hardware devices are accessed through those special files ● Special files reside in /dev directory ● Two types of special files: – Character special files: For character-oriented devices (keyboard) – Block special files: For block-oriented devices (a harddisk) 12 CTIS156 INFORMATION TECHNOLOGIES II

13 Files And File System Structure ● Types of Files (cont) – Special File (Device)(cont): ● Some special files are: – fd0 (for floppy drive 0) – hda (for harddisk a) – lp0 ( for line printer 0) – tty (for teletype terminal) 13 CTIS156 INFORMATION TECHNOLOGIES II

14 Files And File System Structure ● Types of Files (cont) – Named Pipe (FIFO): ● A file used by the two processes to communicate with each other (IPC) ● File System Structure: 14 CTIS156 INFORMATION TECHNOLOGIES II

15 Files And File System Structure 15 CTIS156 INFORMATION TECHNOLOGIES II

16 Files And File System Structure ● File System Structure (cont): – Home and Present Working Directories: ● When you logon, you are placed in a special directory, called your home directory (To see enter “echo $HOME”) ● Home directory is denoted ~ (tilda) character ● The directory that you are in at a particular time is called your present working directory (or current directory) (To see enter “pwd”) ● Present working directory is denoted by. (dot) ● The parent of the present directory is denoted.. (dotdot) 16 CTIS156 INFORMATION TECHNOLOGIES II

17 Files And File System Structure ● File System Structure (cont): – Pathnames: Absolute And Relative ● A file or directory in a hierarchical file system is specified by a pathname ● Pathnames can be specified in three ways: – Starting with the root directory – Starting with the present working directory – Starting with the users home directory ● Pathnames that start with the root directory is called absolute pathname ● Pathnames that start with the home or present directories are called relative pathnames 17 CTIS156 INFORMATION TECHNOLOGIES II

18 Files And File System Structure ● File System Structure (cont): – Pathnames: Absolute And Relative (cont) ● Examples: /home/faculty/sarwar/courses/ee446/exams/mid1 (absolute pathname for file mid1) ~/courses/ee446/exams/mid1 (relative pathname: user sarwar's home directory is /home/faculty/sarwar) If the user is in ee446 directory (present directory), the relative pathname can be./exams/mid1 or just exams/mid1 18 CTIS156 INFORMATION TECHNOLOGIES II

19 Files And File System Structure ● File System Structure (cont): – Some Standard Directories and Files: ● Every Linux system contains a set of standard files and directories according to the File System Standard (FSSTND) proposed in 1994. ● The purposes of each directory: Root Directory (/): At the top of the file system hierarchy. It is the master cabinet that contains all directories and files /bin : Contains binary (executable) images of most essential Linux commands for system administrators and users 19 CTIS156 INFORMATION TECHNOLOGIES II

20 Files And File System Structure ● File System Structure (cont): /boot : Contains all the files needed to boot the Linux system, including the binary image of the LINUX kernel (e.g. vmlinuz-2.6.8.1-10mdk) /dev : Contains special files corresponding to the devices (terminals, disk drives, cdrom, printer, etc) /etc : Contains system configuration files (text files) All these files can only be edited by system administrators. /etc/passwd contains user information /home : Contains users' home directories 20 CTIS156 INFORMATION TECHNOLOGIES II

21 Files And File System Structure ● File System Structure (cont): /lib : Contains shared libraries for C, C++, and Fortran programming languages /lost+found : Contains all files that are not connected to a directory. These files are found by a Linux tool fsck. /mnt : It is used by the system administrators to mount file systems to devices (disk, cdrom, floopy, etc.) temporarily 21 CTIS156 INFORMATION TECHNOLOGIES II

22 Files And File System Structure ● File System Structure (cont): /proc : Contains process and system information. Used by the kernel /root : It is the home directory of the root user /sbin : /usr/sbin : /usr/local/sbin : Contains system administration command files that can only be run by the root user /tmp : Contains temporary files and directories. The contents are deleted periodically set by the administrator 22 CTIS156 INFORMATION TECHNOLOGIES II

23 Files And File System Structure ● File System Structure (cont): /usr : One of the largest sections in Linux file system. Contains all shared add-on software packages, libraries and documents. A new software package should be installed here /var : Contains the variable data. / var/spool/mail contains incoming mail of users, /var/log contains all system logs. 23 CTIS156 INFORMATION TECHNOLOGIES II

24 Files And File System Structure ● Navigating The File Structure – Commands : ● echo $HOME (to see the home dir) ● pwd (to see the present working dir) ● cd(to change dir) ● ls (to display the contents of a dir) ls -a (to display all files) ls -l (to display in long format) ls -i (to display the inode of a file or dir) ls -F(to display the file types) ● mkdir (to create directories) ● rmdir (to remove an empty directory) ● mount(to see which device is mounted to which directory in the file system) 24 CTIS156 INFORMATION TECHNOLOGIES II

25 Files And File System Structure ● Navigating The File Structure – Determining File Attributes : ● You can see the file attributes by “ ls -l ” command 25 CTIS156 INFORMATION TECHNOLOGIES II

26 Files And File System Structure ● Navigating The File Structure – Determining File Attributes : ● Using shell metacharacters with ls command: ls -l course* ls -l *.c ls -l ???.c ls -l ~/courses/ee446/lab[!5]*.c ls -i [a-zA-Z]??[1-5].html ls ~/ [!0-9]*.[c,C] ● Determining file types: file *(to see file type) 26 CTIS156 INFORMATION TECHNOLOGIES II


Download ppt "BILKENT UNIVERSITY DEPARTMENT OF COMPUTER TECHNOLOGY AND INFORMATION SYSTEMS CTIS156 INFORMATION TECHNOLOGIES II FILES AND FILE SYSTEM STRUCTURE."

Similar presentations


Ads by Google