|
Courses |
Main /
File systems, files, directories and devices
Page bread crumbs: Unix For Busy People wiki - Courses - Unix For Busy People - Handouts - Handout 03 Devices:Unix sees devices as either a stream or a block oriented. A stream access is a sequential
Regardless of orientation all devices are identified by a major and minor number in the
Devices are bound (loaded into) to the kernel via software called a device driver. They
All devices appear as a file system (we will explain file systems in a moment) and are
A fairly decent (albeit technical) explanation of devices and device drivers (if you want to
Special Devices:/dev/null -- Also known as the "bit bucket" or "black hole", this virtual file discards all contents written to it. This is typically used to throw away unwanted data streams, such as log files. /dev/random -- This is a virtual file which contains random numbers (subject to the limitations of Random Number Generators in Computing). It uses system noise to generate random numbers and blocks if not enough entropy in the noise is available. Random is commonly used more by programs that absolutely need high quality random data (such as SSH to generate an encryption key). /dev/urandom -- Same as /dev/random, except it always returns random numbers, even if there is not enough entropy in the system noise available. In the latter case, pseudorandom numbers are generated, which are based on an algorithm, depending on the type of Unix system. Terminal devices:The Unix terminal is a simple device that acts much like a file. Terminal emulation is still used by telnet, ssh, xterm, since hardwired terminals are rarely used today. Use tty to tell the name of the current terminal device. Try cat /etc/motd > terminal-device-name or any other Unix command to read or write to the device. Unlike other devices (particularly stream devices) terminal drivers perform a lot of additional processing to be more adaptable to humans such as buffering, terminal addressing using escape codes, line disciplines (XON/XOFF) and modem control and terminal characteristic such as local echo and synchronous and asynchronous operation. Storage:Simply put storage is anything the computer can use to maintain state. This state can be
Disks:Notes: http://en.wikipedia.org/wiki/Hard_disk Disks also known as HDD or hard disk drives (as opposed to floppy drives in ye olden days)
Disk geometry and characteristics HDDs record data by magnetizing ferromagnetic material directionally, to represent either a 0
The platters are spun at very high speeds. Information is written to a platter as it rotates
Cylinder-head-sector Notes: http://en.wikipedia.org/wiki/Cylinder-head-sector Cylinder-head-sector, also known as CHS, was an early method of mapping the geometric
Attach:360px-Cylinder_Head_Sector.png Δ Logical block addressing Notes: http://en.wikipedia.org/wiki/Logical_Block_Addressing Data on single disks are now addressed using LBA or Logical block addressing. Zone Bit Recording Notes: http://en.wikipedia.org/wiki/Zone_bit_recording I am not a disk "geek" and I don't want to get to deep into this however, note that current
Spindle The spindle of a hard disk is the spinning axle on which the platters are mounted. Attach:300px-Hard_drive-en.png Δ Volumes:In modern computing it is advantageous to group storage disks into collections known as
Notes: http://en.wikipedia.org/wiki/Redundant_array_of_independent_disks Partitions:Notes: http://en.wikipedia.org/wiki/Disk_partitioning Like MS-DOS based systems (Windows) Unix disks are divided into logical groups called partitions.
Multiple partitions allow directories such as /tmp, /usr, /var, or home directory space to be
A good partitioning scheme requires the user to predict how much space each partition will need,
File systems:The Unix file system (often also written as filesystem) is a method of storing and organizing
Each file system is stored in a separate whole disk partition. Directories:Notes: http://en.wikipedia.org/wiki/Unix_directory_structure In Unix-like operating systems, the Unix directory structure is a convention of organization within a file system. To use the example of a physical file cabinet, if the separate drawers in the file cabinet are
The directory structure is hierarchical and begins with the root file system and extends downward using the forward slash "/" as the delimiter in the path name. The further down you go the moe slashes are used. Directories can contain files or other directories called sub-directories. Sub directories:Sub directories are directories under the root (/) directory or other directories below that level. Directories can be created or renamed only by the the system administrator in the root file system. Normal non-privileged users cannot create directories directly under the root file system but are usually assigned to a lower directory in the structure such as /home or /export/home. Then a directory will be created under one of those directories usually with your login name. For example a person named Andy Johnson would be assigned a username johnsona and given a "home" directory of /home/johnsona or /export/home/johnsona. This is considered your "home" directory and is where you land whenever you login. It is normally where all the files you create are stored and is also where yourenvironment files live. Root directory or root file system:The root file system is the primary file system on a Unix system. As the name implies it contains the primary file system ion which the operating system is stored and uses for file storage. There is a special command called chroot which can change this for a given login (job) session. The root directory is the directory on Unix-like operating systems that contains all other directories and files on the system and which is designated by a forward slash ( / ). The use of the word root in this context derives from the fact that this directory is at the very top of the directory tree diagram (which resembles an inverted tree) that is commonly used to represent a filesystem. Strictly speaking, there is only one root directory in your system, which is denoted by / (forward slash). It is root of your entire file system and can not be renamed or deleted. /root:On Linux (and some AT&T drrived Unixes), there is also a directory which is named /root.
Linux directory structure Notes: http://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard / --> /bin - Stands for "binaries"; Contains some fundamental utilities needed by a system
administrator. As a failsafe, these were placed in a separate directory so that they
could be placed on a separate disk or disk partition in case the main drive failed.
/sbin - Statically linked binaries also meant originally to be a seperate partition.
/usr - Holds executables, libraries, and shared resources that are not system critical:
X11, KDE, PERL, etc. The name "Unix System Resources" is a post hoc backronym.)
/boot - Usually a seperate partition which contain boot-strap files needed at boot time.
/dev - short for devices. Contains file representations of every peripheral device attached
to the system.
/etc - Contains configuration files and some system databases.
/home - contains the home directories for the users. On Solaris this is usually in /export/home.
/lib - This is the depository of all integral UNIX system libraries.
/lost+found - Each partition has its own lost+found directory. It's purpose as it's name
implies is to become a storage bin for files that become lost from their
original directory. Only the system administrator needs to worry about
this directory.
/mnt - Temporarily mounted filesystems.
/media - Mount points for removable media such as CD-ROMs and PEN drives.
/var - Short for "variable." A place for files that may change often, such as the storage
to a database, the contents of a database, log files (usually stored in /var/log),
email stored on a server, etc.
/opt - This originally meant optional software applications but has really become to
mean any software that is installed that did not come with your Linux distribution
so as to avoid contention with file names or software patches being applied in the
root file system. There are several schools of thought on this directory and some
system administrators (myself included) and some distributions use /usr/local for
the same purpose.
/proc - This is a special directory used by the kernel. Well, actually /proc is just a
virtual directory, because it doesn't exist really. It contains some info about the
kernel itself. There's a bunch of numbered entries that correspond to all processes
running on the system, and there are also named entries that permit access to the
current configuration of the system. Many of these entries can be viewed as text files.
/root - The home directory for the superuser root.
/sys - Modern Linux distributions include a /sys directory as a virtual filesystem (Sysfs,
comparable to /proc, which is a Procfs), which stores and allows modification of the
devices connected to the system.
/tmp - A place for temporary files. Most Unix systems clear this directory upon start up.
Solaris directory structure Much like Linux above however also contains some additional psuedo directories which include /net which is used for
Files:File types Every item in a UNIX file system can de defined as belonging to one of four possible types: Ordinary files Ordinary files can contain text, data, or program information. An ordinary file cannot contain
Directories As previously mentioned directories are containers that can hold files, and other directories.
Special files Special files represent input/output (i/o) devices, like a tty (terminal), a disk drive, or a
Links A link is a pointer to another file. Think of links as aliases or another name to locate a file.
Unix For Busy People is created by Kevin P. Inscoe is licensed under a Back to main web site - http://unixforbusypeople.com |