About | Gallery | News | Order the XPT | Products | Resources | Security | Services | Workshop
Home » Resources » Linux » Unix 101

Unix 101

'Unix is not so much an operating system as a way of thinking.'
 - Old Computer Science Proverb

File Stuff

First off, Unix has only one root, and it is denoted by a forward slash, not a backward slash (yes, Billg just wanted to be different). But, contrary to the scheme used by CP/M and thereafter adopted by MS-DOS, there are no drive letters. All physical drives are mounted and mapped under the same single root.

Basic Commands

Probably the most basic command in the Unix arsenal is ls. When you try to remember what all these cryptic commands mean, try to remember that Ken Thompson, architect of most of them, was extremely cryptic, both by nature and for a very good reason: They were using teletype terminals back then and wanted to minimize output. Also, once you've got to know them better, you will appreciate their brevity: It means far less to type.

ls is the directory list command (that's right - pronounce 'ls' as 'list' and you'll get the hang of it). How the ls command is implemented varies from system to system, but at the root of ls is the essence of the Unix file system: the inode.

The inode

It is essential to appreciate the elegance of the build-up of the Unix file system: Directories do not contain file information and other junk as do MS-DOS directories; they only contain inodes. The inode itself is an index into file information which is housed separately. All a file entry in a directory has is the file name itself and its inode number.

Unix does not admit of file extensions either, for that matter: If you want a dot ('.') in a file name - fine. If you want several in a row, fine too. (The only limitations are for '.' and '..' which always represent the current and the parent directories.)

It is likewise important to understand that because the Unix file system is built up by inodes, that the name given to any file is relatively unimportant. The one-on-one correspondence between a file name and a disk allocation found on Microsoft systems is replaced by a one-on-one correspondence between the inode and the disk allocation on Unix.

A file name is merely a link to an inode; and because the file name is merely a link, any number of similar links may exist. Thus it is perfectly possible (and quite common) for any one single physical file to have different names found in different directories in a Unix file system. The file itself will continue to exist as long as at least one link - one file name - is associated with its inode.

File Attributes

Unix was from the outset a multi-user system, so its file attributes take this into account. A typical listing for a Unix file will look like the following:


Where the initial character is set to 'd' if the file is a directory (Unix does not distinguish between files and directories - they're all files) and where the next three groupings of 'rwx's are for 'user', 'group' and 'other'.

'user' - the owner of the file - the user who created it.
'group' - the user group the owner belongs to.
'other' - everybody else.

Only the 'user' (the owner) of a file can change these attributes (by using the chmod ['change mode'] command - more on this command later).

File Times

Unix also admits of three file times:

atime - time the file was last accessed.
ctime - time the file was created.
mtime - when the file was last modified.

Back to ls

Armed with all that, it might be possible to go back now to that most basic of all commands - ls.

By default ls will list very little. What you need to do is check which command line switches work on your system, and what you will run into can be nothing short of amazing. ls should be able to list both the file names, their inodes, their attributes, their atimes, ctimes, mtimes and a whole lot more.

As the directory architecture is not burdened by a static file entry structure of fixed size, any amount of data at all may be contained in an inode. The inode will in addition contain references to the information needed by the drivers to actually access the file, in other words its direct disk locations. Smaller files have a number of directly accessed sectors listed, while larger and larger files use a more and more indirect approach. Further, the Unix file drivers are written so as to avail themselves of 'lazy write', that is the controller itself will tell the driver where it is located after any completed operation, and the driver will then figure out what pending operation is closest by and send it on to the controller - all in an effort to speed up overall disk operations and reduce disk wear and tear.

The most universal form of expanding the ls command is:

ls -al

But there are additional switches for listing the inodes and all the rest of that nifty stuff.

Next »

About | Gallery | News | Order the XPT | Products | Resources | Security | Services | Workshop
Copyright © Radsoft. All rights reserved.