The Unix Shell

 

Introduction to the Shell

The Unix shell is a command line environment that is very similar to the DOS command line interface. You type a command at the prompt, the computer executes the command, and you get to see the output and then another prompt.

Of course, this kind of environment is becoming more scarce in day-to-day computing for the average person, mostly because the snazzy Graphical User Interfaces are so much easier to use. But to get the most work done in the least amount of time, gurus all over will tell you, "You just can't beat Unix."

You can login and use the Unix shell by starting up your telnet client program on your computer, and connecting it to "netmar.com" and giving your username and password at the prompts. You will then see your "netmar>" prompt, at which you can begin entering commands, just like you were at your own "C:\>" prompt. That means you can read and write email, news, and even edit your WWW pages online!

Lastly, before we dive in, let me show you a quick utility that's really handy. It's called the system manual pages. You can find out just about all there is to know about any Unix command or program simply by typing "man PROGRAM" at the "netmar>" prompt. Or, you can go to http://info.netmar.com/man/ to see them on your World Wide Web browser!

 

Note:
Make sure your CAPS LOCK key is OFF when you use the Unix shell. Since the Unix shell is case-sensitive, meaning it cares if your letters are lower or upper case, you'll have a tough time getting anything to work if you're typing in all caps.

Using mail

When you access your Netmar account via telnet, you havve the option of using either of two mail programs. The first is Pine, which is a very simple, intuitive full-screen mailer that nonetheless has several powerful features. The other is message handler(mh), which is a command-line mail program that enables you to perform all of the activities that Pine does without leaving the command line.

 


Usenet news

To access Usenet news, just type "tin" at the UNIX prompt. This will start up the tin newsreader. After it gets started(don't be surprised if this takes a while - tin is rather slow), you will see a column of newsgroup names on the right and numbers on the left. The numbers are the number of posting in the group. You can navigate with the arrow keys, where the up and down keys will move you up and down a list, and the right and left keys will select an item or move you back to the previous menu, respectively.

The various options are defined at the bottom of the screen, but I will discuss a few of the more important ones here. Yank in/out allows you to yank in all the newsgroups or just display the ones that you've subscribed to. The subscribe option subscribes you to the currently selected group, or unsubscribes you if it is one you already belong to. Finally, you can use the search option to look for newsgroups that you can't remember the names of by using the wildcard character(*) around the part of the name that you do remember.

Click here for the manual page.

 


Manipulating Files

UNIX is very good at manipulating files, but provides the user with enough power that it's essentially 'giving them enough rope to hang themselves'. UNIX has several commands to manipulate files, but the most basic are: cp(copy), mv(move), rm(remove), and mkdir(make directory). Before discussing these commands, it is important to understand that with UNIX, there is essentially NO RECOVERY. What is deleted cannot be undeleted, what is copied over cannot be retreived. UNIX gives no warnings or second chances. It merely does what it is told.

 

cp(copy)
cp takes two arguments, a source file, and a destination.

 


cp /www/mhome/johndoe/www/bunny.gif /www/mhome/janedoe/www


This example would place a copy of bunny.gif from johndoe's www directory into janedoe's www directory.
For more information on this command, click here

 

mv(move)
mv takes two arguments, a source name, and a target name.

 


mv oceans.html waves.html


This example would effectively rename the file 'oceans.html' as 'waves.html'.
For more information on this command, click here

 

rm(remove)
rm takes one argument, the object to be deleted.

 


rm badfile.html


This example would effectively delete the file 'badfile.html'.
For more information on this command, click here

 

mkdir(make directory)
mkdir takes one argument, a name of the directory to be created.

 


mkdir stuff


This example would create the directory 'stuff'.
For more information on this command, click here

 

rmdir(remove directory)
rmdir takes one argument, a name of the directory to be removed.

 


rmdir stuff


This example would destroy the directory 'stuff', as well as all its contents.
For more information on this command, click here

 

edit(call to established editor)
edit takes no arguments

 


edit


This example would bring up the established editor, either pico(default), emacs , vi, or joe.
For more information on this command, click here

Editing online

You also have a choice of three editors while online. They are pico, which is the editor used by Pine, vi, the UNIX standard editor, and emacs, another popular UNIX editor.

For the uninitiated, pico is undoubtedly the best choice. All the commands are visible at the bottom of the screen and they are all letters combined with the CTRL key.

Vi is somewhat less user-friendly, but easy enough to get used to. You have to memorize the key combinations (there are many of these) and it's easy for someone raised on PC or Mac word processors to forget which mode he's in and make a mess. On the other hand, vi is much more powerful than pico, and many things can be done much quicker.

The most powerful of the three is emacs. Needless to say, it is also the most difficult to use. Those who do learn how to use it, however, tend to swear by it.

The easiest way to access an editor is to use the aliased command edit. Edit invokes a prechosen editor(PICO by default).


Programming

Your Netmar account also supports program development in the form of the full GNU C/C++ compiler and libraries. For those used to programming on the PC or the Mac (does anyone program on the Mac?), the switch can be somewhat intimidating, although ultimately rewarding. The UNIX environment has so many libraries and options that there is a danger of information overload.

Stick to the basics and it'll all be fine. Despite what Bill Gates and IBM claim, UNIX is still THE 32-bit operating system, with decades of develpoment, mountains of software, and an extremely powerful command line interface.

Just ftp your code over or write it online using the editors above. To compile just type "gcc input -o output", where input and output are the names of the input and output files. Alternatively, you can use a makefile and multiple source files with the make command.