Files are used to store data and directories are a way of organising files in a hierarchical structure. What UNIX does differently from DOS and other systems is the way it organises different physical storage devices.
In DOS there are individual drive names (actually letters from A to Z) denoting the different drives. In UNIX there is essentially just one virtual drive. All physical drives are sub-directories of this virtual drive or other drives.
Example: In DOS the first floppy disk drive is always A: and the first hard disk is always C:. When copying a file from the floppy disk directory flop_dir to the hard disk directory hard_dir, we issue the following instruction:
copy A:\flop_dir\file C:\hard_dir
In UNIX we first have to know where the floppy disk drive and the hard disk drive are attached (mounted) to the system. Say the floppy disk drive is mounted onto the directory floppy, which in turn is a sub-directory of the directory removable-disks. The hard disk is mounted onto the directory hard-disk, which is a sub-directory of the directory fixed-disks. The UNIX copy command now would look like this:
cp /removable-disk/floppy/file /fixed-disk/hard-disk
The next difference to DOS and other systems is UNIX's handling of other physical devices like the keyboard, screen and printer. Every device is represented as a special file. This makes it possible to copy a normal file to the printer special file. This copying is interpreted by the operating system as an instruction to print the contents of th normal file. Similarly it is possible to copy data from a serial port special file into a normal file, thus reading the serial ports input.
A third important feature of files in UNIX is that every file has an owner, identified by a user identification (UID). The owner of a file can specify the following attributes for a file: read access allowed, write access allowed and execution allowed. These attributes can be separately specified for the owner of the file, a special group of users or everybody. This means a user can set up a file which contains a program to be readable and executable for himself, while others can only execute it, but not read or copy it.
The last feature we will discuss in this section are pipes. These are pseudo-files which can be used to connect processes. The first process redirects its output into a pipe and the second process reads its input from the pipe.
Example: We want a directory listed in alphabetical order.
To do this we can connect the directory command to the sorting command using a pipe. This will produce a sorted directory.