Lecture 5
Lecture 5
Pathname Contents
/bin Commands needed for minimal system operability
/boot Kernel and files needed to load the kernel
/dev Device entries for disks, printers, pseudo terminals, etc.
/etc Critical startup and configuration files
/home Home directories for users
/lib Libraries and parts of the C compiler
/media Mount points for filesystems on removable media
/opt Optional application software packages (not yet widely used)
/proc Information about all running processes
/root Home directory of the superuser (often just /)
/sbin Commands for booting, repairing, and recovering the system
/tmp Temporary files that may disappear between reboots
/usr Hierarchy of secondary files and commands
/usr/bin Most commands and executable files
/usr/include Header files for compiling C programs
/usr/lib Libraries; also, support files for standard programs
/usr/local Local software (software you write or install)
/usr/local/bin Local executables
/usr/local/etc Local system configuration files and commands
Standard directories and their contents
(Cont’d)
Pathname Contents
/usr/local/bb Local support files
/usr/local/sbin Statically linked local system maintenance commands
/usr/local/src Source code for /usr/local/*
/usr/man On-line manual pages
/usr/sbin Less essential commands for system administration and repair
/usr/share Items that might be common to multiple systems (read-only)
/usr/share/man On-line manual pages
/usr/src Source code for nonlocal software packages (not widely used)
/var System-specific data and configuration files
/var/adm Varies: logs, system setup records, strange administrative bits
/var/log Various system log files
/var/spool Spooling directories for printers, mail, etc.
/var/tmp More temporary space (preserved between reboots)
Device Files
Character Devices
Transfer unit: byte
Example: /dev/console
Block Devices
Transfer unit: Group of bytes (block)
Examples: /dev/hda
Device Numbers
Major – Type of device
Minor – Device number
Device Files (Cont’d)
Character Driver Block Driver
Character devices are accessed as a
Block Device are hardware devices which randomly
stream of sequential data, one byte after
access fixed-sized chunks of data.
another.
No buffering is required. Accessed through a cache so buffering is required.
Seeking is not allowed. Seeking is possible.
Managing char driver within a kernel
Managing block driver within a kernel requires more
require less care, preparation and work
care, preparation and work done.
done.
Character driver has only one position Block driver navigates back and forth between any
current one. It can’t move back and forth. location on media.
Reads and write done by buffer cache mechanism
The read() and write() calls do not return
by bread(), bwrite().These request may be
until the operation is complete.
asynchronous.
The kernel doesn’t have to provide an The kernel does have to provide an entire
entire subsystem to the character device. subsystem to block device.
sources for character devices are kept in Sources for block devices are kept in
…/kernel/chr_drv/ …/kernel/blk_drv/
Less complex. More complex.
Eg: Keyboard device, serial port. Eg: Hard disk, Pen drive, Blue-rays.
Sockets & Named Pipes
Enables communication between
processes
Socket
Processed must have a connection first
Example: X Windows
Named Pipe
Communication between unrelated processes
FIFO
Not used very often
Link Files
Multiple names for same file
Hard Link
Pointer to Inode
Can’t cross partitions
Equivalent to the original file reference
File removed when all links deleted
Symbolic (Soft) Links
Pointer to file path name
Dangling symlink – Real file which no longer
exists
ln [-s] <real_file> <link_file>
Magic Numbers
Byte pattern at beginning of file
Patterns listed in file called magic
RedHat: /usr/share/magic
file – Tests a file to determine type
Filesystem Test
Magic Number Test
Language Test
MS File/Directory
Attributes
Read-Only
Hidden
System
Archive
UNIX/Linux File Attributes
Inode
Permissions
Ownership
Time Stamps
Change
Modification
Access
File Size
Link Count
Pointers to data
Viewing File Attributes
ls –l: Long listing (includes attributes)
File Type File Size/Device #
Permissions Modification Date
Link Count File Name
Ownership
User
Owner of file
User names/UIDs defined in /etc/passwd
Group
Organization of users accessing the file
Group names/GIDs defined in /etc/group
Permissions
# ls -ld /home /etc/passwd /dev/console
crw--w--w- 1 root root 5, 1 Sep 27 11:27 /dev/console
-rw-r--r-- 1 root root 559 Sep 22 13:14 /etc/passwd
drwxr-xr-x 3 root root 0 Sep 26 10:42 /home