environment of Unix, UNIX structure ,UNIX FILES , Naming Files in UNIX, UNIX FILES Parent-Child Relationship:
UNIX FILES :
THE FILE:
The file is the container for storing information. Neither a file's size nor its name is stored in file. All file attributes such as file type, permissions, links, owner, group owner etc. are kept in a separate area of the hard disk, not directly accessible to humans, but only to kernel.
The UNIX has divided files into three categories:
- Ordinary file – also called as regular file. It contains only data as a stream of characters.
- Directory file – it contains files and other sub-directories.
- Device file – all devices and peripherals are represented by files.
1. Ordinary File:
Ordinary file itself can be divided into two types-
- Text File – it contains only printable characters, and you can often view the contents and make sense out of them.
- Binary file – it contains both printable and unprintable characters that cover entire ASCII range.
Examples- Most Unix commands, executable files, pictures, sound and video
files are binary.
2. Directory File:
A directory contains no data but keeps some details of the files and subdirectories that it contains. A directory file contains an entry for every file and subdirectories that it houses.
If you have 20 files in a directory, there will be 20 entries in the directory.
Each entry has two components-
- The filename
- A unique identification number for the file or directory (called as inode number).
3. Device File:
Installing software from CD-ROM, printing files and backing up data files to tape. All of these
activities are performed by reading or writing the file representing the device. Advantage of device file is that some of the commands used to access an ordinary file also work
with device file. Device filenames are generally found in a single directory structure, /dev.
Naming Files:
File name in UNIX can have the following:
- A filename can consist up to 255 characters.
- File may or may not have extensions, and consist of any ASCII character expect the / & NULL character.
- Users are permitted to use control characters or other unprintable characters in a filename.
- Examples - .last_time list. @#$%*abcd a.b.c.d.e
- But, it is recommended that only the following characters be used in filenames- Alphabetic characters and numerals
- The period(.), hyphen(-) and underscore(_).
The Parent-Child Relationship:
- The files in UNIX are related to one another.
The file system in UNIX is a collection of all of these files (ordinary, directory and device files) organized in a hierarchical (an inverted tree) structure as shown in below figure.
![]() |
UNIX file system |
- The feature of UNIX file system is that there is a top, which serves as the reference point for all files.
- This top is called root and is represented by a / (Front slash).
- The root is actually a directory.
- The root directory (/) has a number of subdirectories under it.
- The subdirectories in turn have more subdirectories and other files under them.
- Every file apart from root, must have a parent, and it should be possible to trace the ultimate parentage of a file to root.
- In parent-child relationship, the parent is always a directory.
Tags:
unix