What is the difference between UNIX and LINUX? It's difficult to get an exact answer, but basically UNIX is an operating system that is owned and maintained by a few major vendors, including IBM, Oracle/SUN and HP. The different flavours of UNIX are very similar and are supposed to be straight compatible. For example, it is easy to work between SUN Solaris and IBM AIX. However the source code is propriety and is not available.
Linux can be considered an open source version of UNIX. Linux comes in lots more flavours than UNIX and many of them are free. Most of the following pages will apply to both operating systems, I'll hilight the differences as I know them, but as always, do not assume that anything discussed here applies directly to your environment. Test it first.
In general, everything in UNIX and Linux is a file, although some of these files are a bit special. Most files, or regular files as they are called, just contain normal data like text, programs or images. Special files include
File names can be up to 256 characters long, but are best kept reasonably short to make them manageable. If you use standard extensions like .exe or .txt, then everyone will know what a file does. File names are case sensitive, and can include special characters. It's considered good LiNUX practice to use lower case. Avoid using command names for file names as this will cause confusion. For the same reason, it is best to avoid wild card characters like * or ? in file names.
Partitioning is the process of splitting a storage disk into a number of separate segments. This was originally designed to limit the impact of a damaged disk, as only part of the storage system might be damaged. This risk was reduced with the intoduction of journalled file systems, however, partitioning also means that if one partition fills up, other parts of the disk still function. Typically, the system will be kept on a different partition to use data, so user damage can also be limited. The two major kinds of partitions on a Linux system are:
Workstations are usually defined with either one large data partition, or two partitions, one for system data and one for non-system data.
Linux servers are usually defined with a root partition, several data partitions and one or two swap partitions. A different file system might be installed on each partition. Most Linux systems have the basic partitions defined automatically at installation time.
The standard root partition, the '/' directory, holds the system configuration files, server programs, system libraries, and the 'admin' home directory.
The kernel is often on a separate partition too, in a '/boot' directory and holds the kernels and associated data files.
Swap partitions do not have a visible directory and can only be accessed by the system itself. Generally speaking, the swap areas contain twice the capacity of the physical memory.
The rest of the hard disks are usually divided in data partitions, and the following partitions are pretty standard.
'/usr', a partition for user programs
'/home', a partition containing the users' personal data
'/var', a partition to store temporary data like print- and mail-queues
'/opt', a partition for third party and extra software
Partitions are attached to the directory listing with mount points, and these mount points indicate the location of the partition in the listing. The standard mount points are usually attached through the root partition. Mount points need an existing, empty directory before they can be attached. For example if you want to mount a new partition, first you need to define an empty directory using the mkdir command. You would then mount the new partition using the mount command.
You can check out existing partitions and their mount points by using the df -h command.
We normally think of the file system as being like a tree, with a single 'root' directory that has directories attached to it, then subdirectories to those and eventually terminating with lots of 'leaves' or files. LINUX systems are usually drawn like a tree, but in actual fact it is just a collection of pieces of data with links between them. The data is identified by inodes. An inode is a bit like a label that is attached to a file. An inode label has a unique number within each partition and also contains
You can display the inode number for a file with the ls command, usually by using a –i switch.
When you create a partition, you set aside part of that partition space for a fixed number of inodes, and the inode numbers are unique within that partition, but duplicate inode numbers can exist between partitions. Every time you create a file, you assign a free inode to that file. The file system can build up a tree picture of the file structure by piecing together the file names and inode numbers (the inode does not contain the file name and directory, these are held in the directory files).
Files are organised into directories to make it easier to find things, and to keep common files in a central location. The lowest level directory is the root directory, denoted by a / (forward slash). A number of sub-directories will exist below the root; the common or standard directories are shown in the table below, but be aware that the names of some of these directories can be changed.
|/bin||Used for program files, by the system, the system administrator and users.|
|/boot||Contains the files and information needed to start the system up. Newer versions of Linux use a GRand Unified Boot loader or GRUB, and the GRUB files will be in here.|
|/dev||Contains the 'special files' that describe all the peripheral hardware like VDUs, keyboards, disks, tapes, etc.|
|/etc||Contains the system configuration files|
|/home||Contains the 'home' or personal directories for most users. This directory name is actually heavily site dependent, though home is the default|
|/initrd||Used by some Linux versions to hold boot information.|
|/lib||Library files, includes files for all kinds of programs needed by the system and the users.|
|/lost+found||Used for files that were saved during failures|
|/mnt||external file systems mount point|
|/net||remote file systems mount point|
|/proc||Contains system resources information.|
|/root||The home directory for the administrative user. Not the same as /, which is the root directory.|
|/sbin||Contains system programs.|
|/tmp||Temporary system space and general scratchpad.|
|/usr||Contains user programs, libraries and documentation.|
|/opt||On Linux, Typically contains extra and third party software.|
|/usr||Contains user programs, libraries and documentation.|
You can add your own directories to the root, but its best to add them as subdirectories under the appropriate main directory. Directory names are case sensitive, must be unique within one directory and can contain almost any character.
There are lots of GUI style file managers available for Linux that have the same look and feel as Windows Explorer. Popular products include Nautilus, Conqueror and Midnight Commander. The UNIX Command section discusses the line commands to display files and directories
Now let's get a little more complicated. Say you want to create 2 new file systems. You can do that, no problem and each file system will have its own root directory. However if you want to access the new file systems, you need to 'mount' them somewhere. You can mount them on the root directory of the main file system, or mount them under subdirectories hanging off the main root. In this way, you can build a complex composite file system, but one that all hangs together from that central point.
Contrast this with Windows, where new file systems are allocated as different drives, each with its own drive letter. There is obviously a limitation on how many file systems can be allocated this way.
Say you develop a program called 'space.exe' in your /usr/storage/bin directory that goes out and checks on how full all your disks and partitions are, and reports the results back to your terminal. To execute that program you might have to type /usr/storage/bin/space which is a pain because it requires extra typing and you have to remember where the program is. UNIX stores lists of program locations in a PATH variable. To see what PATHs are defined type
>env |grep PATH
or in Linux
And the result will look like
UNIX will search these directories in order when a command is entered, and will execute the first command it finds, so if you type 'space' on a command line and there is a space program in /usr/local/bin then that version of space.exe will be executed, not the version in /usr/storage/bin
Each user could have a different path variable. The 'which' command will display the full path name for a command, for the path variable used by your environment. An example is:
Space is /usr/local/bin