- Forward


UNIX Files
An Introduction


Prof. David Bernstein
James Madison University

Computer Science Department
bernstdh@jmu.edu

Print

Before Getting Started
Back SMYC Forward
  • A Common Usage:
    • A file is a sequence of bytes that persists beyond the life of a program
  • The UNIX/Linux/Posix Usage:
    • A file is a sequence of bytes
Before Getting Started (cont.)
Back SMYC Forward
  • Theoretical Implications of the UNIX Usage:
    • A file is an abstraction
  • Practical Implications of the UNIX Usage:
    • Files are used to model every I/O device (e.g., disks, keyboards, displays, networks)
    • Files provide a uniform view of varied I/O devices
File Types
Back SMYC Forward
  • Regular Files:
    • Contain arbitrary data (Note: To the kernel, there is no distinction between text files and binary files, all files contain bytes.)
  • Directories:
    • Contain a collection of (hard) links, each of which maps a filename to a file
  • Sockets:
    • Used to communicate across a network
  • Pipes:
    • A (unidirectional) byte stream with limited capacity
File Types (cont.)
Back SMYC Forward
  • Symbolic (Soft) Links:
    • A file whose data is the name of another file (which may or may not exist)
  • Character Devices:
    • Devices that handle data on a character-by-character basis (e.g., terminals and keyboards)
  • Block Devices:
    • Devices that handle data a block at a time (e.g., disks)
Text Files and Binary Files
Back SMYC Forward
  • Applications:
    • Often distinguish between text files that contain only ASCII or Unicode characters and binary files
    • Text files are often line-oriented (i.e., contain line-feed characters [UNIX], carriage returns, or both)
  • The Kernel:
    • Does not distinguish between text and binary files
Organization of Files
Back SMYC Forward
  • The Hierarchy:
    • Anchored at a directory named / (called the root directory)
  • Some Important Directories:
    • /dev contains devices
    • /usr/include contains header files
  • Some Important Directory Entries:
    • . a link to the directory itself
    • .. a link to the parent directory
There's Always More to Learn
Back -