Peter Radatti
Background Background Experience Ventures Published Works Patents

The Sun Observer, Volume 8 No.5

Peter V. Radatti

radatti@cyber.com

CyberSoft

May 31 1995

Notice: Copyright March 31, 1995 by Peter V. Radatti, All rights reserved.

Hello everyone! You may remember me from a few years ago when I wrote a Column for the Sun Observer called "Getting Started". The wise and noble editors here managed to convince me to write for you again by promising me fame, wealth and a date with Madonna. I'm not sure about the wealth and Madonna parts but it's nice to be back.

First, lets set a foundation for these articles. These articles are intended as practical lessons for the beginning Unix user. If you are a power user and have never used anything except your word processor in the last 10 years you should stop reading now. These articles will expand your ability to work smarter not harder by teaching you about the environment in which you work, the Unix operating system.

The heart of any computer system is the ability to manipulate data. Data is normally stored on disk, collected into a logical container called a file. The files are then collected into a larger logical container called a directory. A directory may contain both files and other directories. In order to distinguish files from each other they are given filenames. Just as two people have two different names, two files may have two different filenames. Filenames usually have a basis in logic. For example, a file containing the names of your customers may be called "customer.txt". The filename extension, ".txt" is voluntary and not necessary, however a tradition of extension filenames identifying the type of file. In the example, "customer.txt", the ".txt" extension normally means the file contains plain text. Some common extensions and their meanings are:

extension meaning db database file sh shell program txt text file ps postscript file eps encapsulated postscript file

Remember, it's a custom to use filenames that make sense. The system does not enforce it. If you wanted, you could call your customer list, "roadkill.eps" and the contents would not change.

As mentioned above directories can be stored in directories. This becomes messy very quickly if not organized in some common sense way. The way most systems choose to implement this stacked approached to directories is called a hierarchical filesystem. A hierarchical filesystem can be compared to a multi limbed tree. At the base of the tree is the "root" directory followed by fixed directories. Fixed directories are directories that must exist for the system to function. You do not have the option of removing them. Following the fixed directories are user discretionary directories. These directories are where users normally store their personal files and where the system administrator stores files that must be shared between multiple users.

Files can become nested several layers deep in an hierarchical filesystem. This creates a problem when attempting to describe where the file is located. Unix allows two ways of describing the location and filename of a file in the filesystem. There is the positional, (aka relative filename), and full filenames. Positional filenames relate to where ever you already are in the filesystem. If you are positioned in the "happy" directory and you want to describe a file called "friday" in a nested subdirectory called "days", you would skip the description of the "happy" directory, itself nested below the "root" directory, and refer directly to "days" directory and "friday" file. If you needed to refer to the location of the same file in a position independent way you would use a full filename which would describe the location starting at the root, or top most, directory. In the Unix system the root directory is represented by the symbol of a forward slash. It is also used as a separator between directory and filenames. Therefor an absolute or full filename for the file mentioned above would be, "/happy/days/friday". A relative filename from within the "/happy" directory would be, "./days/friday". The dot symbol refers to your current position. As reference, the dot-dot symbol refers to the directory above your current position. More than two dots are not allowed.

When users first logon to a system they have to have a default place where they store files. This default place is called a user's home directory. The user's home directory is selected by the System Administrator and can only be changed by them. User's can change their position in the filesystem structure using the change directory, "cd" command. To change to the lower most directory given in the example, above, the command would be "cd /happy/days". Notice that you can not specify a filename using the "cd" command. Once in a directory you can open a file for processing but your location is always the current working directory, "cwd". You can print the value of your current working directory by executing the "pwd" command.

If after a hard session of roaming around the filesystem tree you want to return to your home directory it's only necessary to enter the "cd" command without options. In your home directory there are many files that control the features of the system and how you perceive it. Some of the most important files are ".cshrc", ".profile", ".login" and ".logout". The ".cshrc" and ".profile" files control the features of the shell program. The shell program is the operating system's interface to you the user. The ".login" file executes when you first login. It allows you to set global options that never need resetting again and to start applications that you always want started, an example of which is the windowing system. The ".logout" file executes when you logout. It allows you to do cleanup without having to remember. Some word processors leave lots of junk files in your home directory. You can have the ".logout" file delete all of them when you are done and logout.

There are multiple shell programs available including bourne, csh and korn shells. The most popular are borune, which is necessary to run the system and csh which is preferred by many users, including myself. One of these options is called the path. The path is a way to tell the operating system which directories to search and the order to search those directories for programs that you want to execute. This is a great convenience since you don't have to remember the full path name for each command. If you want to execute the program "invoice" in the "/happy/days" directory structure you can enter the command "/happy/days/invoice" or you can set your path to search that directory then enter the command, "invoice". The path is set using a global variable with the obvious name of "path". The csh command "set path = ($path /happy/days)" will amend your path so that it searches the "/happy/days" directory. In this example it will be searched last. You can make your modification to the path permanent by entering the command in the ".cshrc" file. The same thing works for the bourne shell, but the command is different.

One of the essentials to know is how to view the list of files and directories that you are working with. One command, with several options, provides the solution on the Unix system. That command is "ls". If you enter the "ls" command with no options it will show you the files in your current working directory with the exception of hidden files. Hidden files all start with a dot. The ".cshrc", ".profile", ".login" and ".logout" files are all hidden files. To see all of the files, including the hidden files use the "a" option. The command using the "a" option is "ls -a". Another useful option is the "l" option. (lower case L) The "l" option provides a "long" listing of the files. If you execute the command "ls -la" you will be presented with a listing of all files in your current working directory, the file type, their permission settings, owner, group owner, size, date of last modification and the filename. This can be very important information especially the file type and permissions settings. The file type will tell you if the filename is a directory or a file. If the first character displayed as part of the permissions settings is a "d" then the filename is a directory. If it is a dash then it's a file. There are several types of files but we will deal with them later. An example of using the "ls" command with the "l" and "a" options is:

% ls -la

drwxrwxrwx pete pete 512 Mar 30 18:00 days

-rwxr-xr-x pete pete 20 Mar 30 19:00 shopping_list

Stay tuned next month, same author, same column for we continue learning how to navigate though the Unix system, how to distinguish the type of contents a file has and learn ways to utilize the contents of the files. I will also report on my date with Madonna. I wonder if I can get lucky with her?

Pete Radatti is the founder and CEO of CyberSoft, Inc. CyberSoft manufactures, VFind the an antivirus software product that executes under Unix and simultaneously scans for Unix, MS-DOS, Macintosh and Amiga destructive software. You can reach Pete at radatti@cyber.com.

View more of Pete's Published Works

Background Background Experience Ventures Published Works Patents



HomeNewsBackgroundAccomplishmentsAwardsVenturesPublished WorksPatentsGuestbook

Peter V. Radatti CEO CyberSoft, Inc 1958 Butler Pike, Suite 100 Conshohocken, PA
Voice: 610-825-4748 Fax: 610-825-6785 E-mail: radatti@cyber.com
Copyright 2004, 2005, 2006 Peter V. Radatti. All rights reserved.
PVR