CSC 140 Introduction to IT Files and Filesystems

  • Slides: 22
Download presentation
CSC 140: Introduction to IT Files and Filesystems CIT 140: Introduction to IT 1

CSC 140: Introduction to IT Files and Filesystems CIT 140: Introduction to IT 1

Questions 1. 2. 3. 4. 5. 6. 7. What is a file on UNIX?

Questions 1. 2. 3. 4. 5. 6. 7. What is a file on UNIX? What file types are supported by UNIX? What are file attributes? What are pathnames? How can I browse the filesystem using the shell? How is a UNIX file is stored on the disk? How to use the following commands/paths: ~ , . . , / , PATH, cd, echo, file, ls, mkdir , pwd , rmdir CIT 140: Introduction to IT 2

Types of Files 1. 2. 3. 4. Simple/ ordinary file Directory Symbolic (soft) link

Types of Files 1. 2. 3. 4. Simple/ ordinary file Directory Symbolic (soft) link Special (device) files – block special files and character special files 5. Named pipe (FIFO) CIT 140: Introduction to IT 3

Ordinary File Types CIT 140: Introduction to IT 4

Ordinary File Types CIT 140: Introduction to IT 4

Structure of Directory Files CIT 140: Introduction to IT 5

Structure of Directory Files CIT 140: Introduction to IT 5

Symbolic Links A Link File is created by the system when a symbolic link

Symbolic Links A Link File is created by the system when a symbolic link in created to an existing file. > touch a > ln –s a link > ls –l. link lrwxrwxrwx 1 jw jw 1 2005 -09 -08 link -> a If you remove the file a link points to, then the link is no longer valid, and ls will hilight it in red. CIT 140: Introduction to IT 6

Device Files A special File is a means of accessing hardware devices, including the

Device Files A special File is a means of accessing hardware devices, including the keyboard, hard disk, CD-ROM drive, tape drive and printer. – Stored under /dev directory. – Character Special Files • Correspond to character-oriented devices (e. g. , Keyboard) • /dev/pts 0 • /dev/mouse – Block Special Files • Correspond to block-oriented devices (e. g. , a disk) • /dev/hda • /dev/cdrom CIT 140: Introduction to IT 7

/dev Directory Listing > ls -al crw-rw---1 lrwxrwxrwx 1 hda lrwxrwxrwx 1 hdg crw-rw---1

/dev Directory Listing > ls -al crw-rw---1 lrwxrwxrwx 1 hda lrwxrwxrwx 1 hdg crw-rw---1 lrwxrwxrwx 1 /proc/kcore crw-rw---1 lrwxrwxrwx 1 hdg brw-rw---1 root audio root 14, 4 2005 -08 -28 12: 32 audio 3 2005 -08 -28 12: 32 cdrom -> root 3 2005 -08 -28 12: 32 cdrom 1 -> root 3 2005 -08 -28 12: 32 cdrw 1 -> root root audio root 5, 14, root floppy root cdrom 1 2005 -08 -28 12: 27 console 11 2005 -08 -28 08: 32 core -> 3 2005 -08 -28 12: 32 dsp 3 2005 -08 -28 12: 32 dvd -> 3 2005 -08 -28 12: 32 dvdrw -> 2, 3, CIT 140: Introduction to IT 0 2005 -08 -28 12: 32 fd 0 0 2005 -08 -28 12: 32 hda 8

Named Pipes Named Pipe (FIFO) – Enable processes to communicate with each other. >

Named Pipes Named Pipe (FIFO) – Enable processes to communicate with each other. > ls –l. F /usr/lib/cron/FIFO > prw------- 1 root 0 Apr 18 08: 27 /usr/lib/cron/FIFO| CIT 140: Introduction to IT 9

File System Structure • File System Organization • Home and Present Working Directories –

File System Structure • File System Organization • Home and Present Working Directories – $HOME, ~, $home – pwd, . . • Pathnames: Absolute and Relative • Some Standard Directories and Files – Root directory (/), /bin, /dev, /etc, /lib… CIT 140: Introduction to IT 10

UNIX File System Structure CIT 140: Introduction to IT 11

UNIX File System Structure CIT 140: Introduction to IT 11

Navigating the File Structure Browsing the File System – cd [directory] – ls [options]

Navigating the File Structure Browsing the File System – cd [directory] – ls [options] [pathname-list] CIT 140: Introduction to IT 12

Common Hidden Files CIT 140: Introduction to IT 13

Common Hidden Files CIT 140: Introduction to IT 13

File Commands • Creating Files – pico, vi, emacs • Creating and Removing Directories

File Commands • Creating Files – pico, vi, emacs • Creating and Removing Directories – mkdir [options] dirnames, rmdir [options] dirnames • Determining File Attributes ls –l, ls –i , ls –al , ls –F CIT 140: Introduction to IT 14

Listing Files CIT 140: Introduction to IT 15

Listing Files CIT 140: Introduction to IT 15

Listing Files (Contd) $ ls -i 12329 courses 22876 memos 12487 personal $ ls

Listing Files (Contd) $ ls -i 12329 courses 22876 memos 12487 personal $ ls -al ~/courses/ee 446/exams drwxr-x-- 1 sarwar faculty 512 Mar 16 08: 24. drwxr-x-- 1 sarwar faculty 512 Jan 29 13: 27. . -rwxr--r-- 1 sarwar faculty 1863 Mar 16 11: 10 mid 1 -rwxr--r-- 1 sarwar faculty 459 Apr 11 14: 34 mid 22 drwxrwxrwx 1 sarwar faculty 512 May 12 23: 44 solutions $ ls -F / bin/ dev/ etc/ [email protected] lost+found/ tmp/ usr/ unix* $ ls -l ~/courses/ee 446/lab[^5]*. c. . . $ ls ~/[^0 -9]*. [c, C]. . . $ CIT 140: Introduction to IT 16

UNIX File Types file [options] file-list $ file /* all. backup: bin: dev: etc:

UNIX File Types file [options] file-list $ file /* all. backup: bin: dev: etc: install: lost+found: tmp: usr: unix: $ POSIX tar archive directory symbolic link to var/lib/LST directory ELF 32 -bit LSB executable CIT 140: Introduction to IT 17

UNIX Filesystem • Boot blocks • Superblocks: free space, 1 st inode pointer •

UNIX Filesystem • Boot blocks • Superblocks: free space, 1 st inode pointer • Group descriptors: bitmaps, inode table CIT 140: Introduction to IT 18

UNIX Inodes CIT 140: Introduction to IT 19

UNIX Inodes CIT 140: Introduction to IT 19

File Storage in UNIX CIT 140: Introduction to IT 20

File Storage in UNIX CIT 140: Introduction to IT 20

File Descriptors CIT 140: Introduction to IT 21

File Descriptors CIT 140: Introduction to IT 21

File Descriptors (Contd) CIT 140: Introduction to IT 22

File Descriptors (Contd) CIT 140: Introduction to IT 22