MegaZone's UNIX Basics Manual



UNIX Basics Manual

Getting Started

The Basics of a UNIX Network:
Basic File Management, Emacs, Elm, and News

(What every user should know to get started.)

Written and compiled by MegaZone

"UNIX wasn't designed to keep you from doing stupid things, because that would keep you from doing clever things." - from a pin.

Table of Contents


This guide is meant as a bare bones introduction to a UNIX network. The information contained herein is all a user needs to begin using the network for email, news, and basic file work such as editing and movement. It is written in basic English and in a deliberately casual tone, a bit different than the typical manual, but a difference than will hopefully make understanding a bit easier.

This manual only touches on the most basic aspects of the network, but if a user develops a solid understanding of this information, learning more will be easier. Most of the skills developed for file management, and emacs use are universal. Emacs can be used as an editor for any task, and many different programs work in similar ways.

The best approach is to read through this manual first, and then keep it by your side as you practice on your own. Once you have learned the basics, keep it is a fast reference. There is always more to learn.

File Management

Shell: When you login you run what is known as a shell. This is the basic program that allows you to interface with the computer. There are several different shells, and each one varies slightly.

It is recommended that you use 'tcsh' since it has many useful features. Many new accounts are now created with 'tcsh' as the default. However, some accounts may still have 'csh'. If your prompt is '>', then you are running 'tcsh'. To change shells type 'chsh' and enter '/sh/tcsh' when prompted for the shell name. Not all systems offer 'tcsh', if it doesn't allow you to choose it your system may be one of those that doesn't use it.

Path: 'Absolute path' refers to the complete location of a file, or the 'path' the system uses to find it. For instance, given that a username 'megazone', located on '/usr5', has a file called 'final' in a sub-directory called 'MQP', the absolute path is '/usr5/megazone/MQP/final'. This 'path' is used by the system to find the file, in much the same way that you use a map to find a destination.

'Relative path' is the path to a file from the directory you are currently located in. For example, if you are in '/usr5', 'megazone/MQP/final' is the relative path from the above example.

You don't know what file-system someone is in? No problem, there's a shortcut. The '~' character can be used before a username to tell the system to look for the drive on its own. In this way '/usr5/megazone' can be abbreviated as '~megazone', and your own home directory may be abbreviated as '~/'.

Understanding how paths work is important as they are used in conjunction with many commands. Using the above example, at any time you can type 'cd ~megazone' to change to that directory, or 'more ~megazone/MQP/final' to read that file. 'cd' is the change directory command, and more is a program used to view text files one screen at a time. Use 'cd path' to change to a new directory, and 'cd' alone at any time returns you to your homedir. This doesn't mean that you can enter any directory, or read any file, just those that have the permissions set to allow it.

Directories: Your home directory is simply the top directory in your account. It is the directory you default to when you login. A sub-directory is simply a directory within another directory. Continuing the example, 'MQP' is a subdir of '~megazone'.

If you want to create a new directory the command is 'mkdir'. There are two ways to create a subdir in one of your directories. The first is to 'cd' to the directory in which you wish to create the subdir and enter 'mkdir directory-name'. This will create the subdir with the name you supply.

The other way is to use 'mkdir /path/directory-name' from any directory. This will create the new directory at the end of the path specified. If you were to enter 'mkdir ~/Eris' you would create a new dir called 'Eris' under your home directory.

To remove a directory the command is 'rmdir', used in the same way as 'mkdir'. However, the directory must be emptied of files first for this to work.

Files: These are the basic dealt with in any computer system. Files can be stored text, a program, a digital picture, basically anything, but all are handled in the same way. In fact, under UNIX, a directory is simply a special file. To move a file you use 'mv path/file path/newfile'. For example, 'mv ~/stuff ~/subdir/oldstuff' will move the file 'stuff' from the home directory into a file named 'oldstuff' in the directory 'subdir'. If you leave the last filename off, the file will be moved to the new directory, but retain it's name.

Note: Be careful when using 'mv', as it will overwrite any existing files with the same name in the destination directory! You can avoid that by aliasing 'mv' to 'mv -i'.

To make a copy of a file use the command 'cp' in the same way as 'mv'. This will create a new copy of the file in the specified location, while leaving the original file in place.

Remove files with the 'rm' command, as in 'rm filename'. When 'rm' prompts you with 'rm: remove filename?', simply press 'y' and '<Return>'.

Note: This prompting is not standard, so don't expect this to be the same at all sites. Many new accounts are created with 'rm' aliased to 'rm -i' which triggers this prompting.

You can list your files with the 'ls' command. On its own 'ls' will list your normal named files and directories. There are also dot-files with are normally used by the system to store information used by applications. To see all the files use 'ls - a'. For information such as file size and date of last change use 'ls -l filename'. These flags can be combined, as in 'ls -al', which will provide complete information for all the files in the directory.

This may be more than a screen in length. To counter this problem you can pipe the output through the 'more' program. This is done with the '|' symbol, as in 'ls -al | more'.

Wildcards: If you've ever played card games you probably know the principle behind a wildcard. It is something that can assume different values, other than what it normally would be. There are several wildcards that makes life easier on the system.

The most commonly used is '*'. When an '*' is used in a command the system looks for all possible completions from 0 characters up. Examples: 'rm n*' will remove all files with 'n' for a first letter, while 'rm q*m' will remove all files that start with 'q' and end with 'm'.

'?' is also a wildcard. It is used for single character replacement. Whereas '*' replaces a string, '?' will replace one, and only one, character. If you had files hw1, hw2, and hw3, you could delete them using 'rm hw?'

The bracket pair, '[' and ']', can also be used for wildcards. These are used for pattern matching. Using the previous example, you could also remove the files with 'rm hw[1-3]'. If you wanted to keep hw2, you could use 'rm hw[1,3]'. Or you could use the negation available.

Instead of 'file[pattern]' you use 'file[^pattern]'; the '^' means to perform the operation on all the matching files BUT those named. The '^' must be the first character inside of the brackets In this example you would use 'rm hw[^2]'.

Flags: This is the term used to refer to options available with commands, such as '-r', '-l', etc. All the 'dash-*' options are called 'flags'.

Odd files: At some point you may accidentally create a filename with a special character in it, ie home*ork. If you tried normal commands to move, or remove the file, they wouldn't work. There are ways around this; enclose the filename in single or double quotes, ie 'rm 'home*ork'' or 'rm "home*ork"', or use '\' as in 'rm home\*ork'. A backslash will de-specialize the following character allowing commands to function normally.

A special case is creating a file with '-' as the first character. This will cause commands, such as 'rm' or 'mv', to view the filename as a flag. To solve this problem, separate the command and filename with an isolated '-', as in 'rm - -kallisti'.

Manual pages: If you want to learn more about a command there are manual pages, or 'man pages', online. Simply enter 'man command', such as 'man rm', to display the online manual for that command. Most of the common commands will have a manual page. It is a good idea to do this once you understand the basic command, as most commands have several flags.

'man' can also be used to research new commands via the '-k' flag. 'man -k keyword' will return all commands with 'keyword' in their description. Simply use keywords you feel are related to the topic you're interested in.


Emacs is an editor that is very common on the networks. It is an extremely powerful editor and trying to explain it all would take a book. However, emacs is also fairly simple and with only a few basic commands anyone can use it productively.

Characters in strings indicate a command sequence. Example: '^X^C' means control-x then control-c; '^X-i' means control-x then just plain 'i'.

To enter emacs to edit a file, simply enter 'emacs filename' at your prompt. If you use the name of an existing file you will automatically load the file into emacs to be edited. If you use a new file name you will create a new file with the editor.

You can use emacs as your editor in nearly every application that calls for one. Therefore, emacs can be your editor for direct file editing, Elm ,and netnews. If you would like to use emacs for all of your editing, and have it be the default for programs using an editor, you can modify your '.login' file. The .login is the file where your defaults are stored. Emacs the .login and add these two lines:

setenv EDITOR /usr/local/bin/emacs
setenv VISUAL /usr/local/bin/emacs

These are called environment variables and many programs use these for their default settings. To make these take effect immediately type 'source .login'. This will be done automatically the next time you login.

Before explaining the commands, you need to understand some of the terminology. A letter preceded by a '^' indicates that letter is a control character. For instance, '^X' means you hold down the 'Ctrl' key while pressing 'x'. It is convention to use uppercase when writing these characters into a manual; however, you do NOT press shift while typing them.

A letter preceded by 'M-' indicates that the letter is a Meta command. Meta is entered as '^[', or control left bracket. Using control and meta commands, and combinations thereof, allow you to do a wide range of tasks within emacs. The following list is by no means complete, it only covers the basic commands you need to get started.

Note: Most of these commands are standard, but some may vary depending on choices made when emacs was installed. Double check these commands before using them.

Emacs Command List

  • ^D Delete character cursor is on.
  • ^K Kill from the cursor to the end of the line, stores deleted text in kill ring. You can store as much text in the kill ring as you'd like with successive kills.
  • ^Y Yanks text back from kill ring. Use with ^K for cut and paste editing.
  • ^L Reset and clear screen.
  • ^A Move to the start of the line.
  • ^E Move to the end of the line.
  • ^F Move forward (right) one character. (right arrow)
  • ^B Move backward (left) one character (left arrow)
  • ^P Move up one line. (up arrow)
  • ^N Move down one line. (down arrow)
  • ^G When all else fails, emacs quit. Use this in case you make a typo with a command, it will abort the command.
  • ^T Transpose char on cursor and before cursor.
  • ^Z Pause the job. fg at your prompt will restart it.
  • ^U Followed by number, ^U will repeat the next argument that number of times. Without a number it is a multiple of 4: ^U is times 4, ^U^U is times 16, etc.
  • ^O Insert blank line after the cursor.
  • ^V Scroll down one page.
  • M-v Scroll up one page.
  • M-f Move forward (right) one word.
  • M-b Move backward (left) one word.
  • M-< Move to the top of the file.
  • M-> Move to the bottom of the file.
  • ^X-u Undo one batch of changes.
  • ^X-s Save the file.
  • ^X-i Insert another file into the current file.
  • M-s Center entire line.
  • M-S Center entire paragraph.
  • ^X^C Exit emacs and save the file.


Elm is an electronic mail reader that many users prefer over mail or pine. It utilizes a menu that allows you to choose the letter you wish to read, along with a menu table that gives you the commands available to you. The first time you use elm it will ask to create two directories, Mail and .elm, answer yes to the requests.

Once in elm, you can choose which letter to read by moving the highlight bar or by simply entering the number of the letter. To read the letter press return or space.

  • d Delete the highlighted letter.
  • u Undelete a letter. First go to it by entering the number of the letter.
  • r Reply to a letter.

    You will be prompted for a few self-explanatory choices, then the default editor will come up. (If you inserted the lines into your .login as above you will enter emacs.)

    Once you exit your editor you will be asked whether to edit, forget it, edit headers, or send the letter. Edit will return you to the editor. Forget it will cancel the mail. Edit headers allows you to make changes to the header information, such as the subject and the address to send it to. and Send will mail the letter.

  • b Bounce a letter you have received to someone else.

    Bouncing forwards the letter just as you see it. If the person you bounce it to replies, the mail will go to the original sender, not to you.

  • f Forward mail.

    This will send the header and body of the letter. Forwarding gives you the option of editing the outgoing mail. Replies will go to you in this case.

  • p Print hardcopy of your email.

    This will send a copy of the letter to your default printer

  • g Group Reply.

    This will send your reply to all recipients of the original letter. Please keep in mind that perhaps your reply is not pertinent to everyone. Do not use group reply if this is the case, it just increases the level of junk mail.

  • c Change to a new mail folder, mbox for instance. Enter 'c' and then the path to the mail folder you want to open.
  • s Save a letter to a folder. Press 's' then enter the path to the folder.

    There are a couple of short-cuts when using folders. If you want to change to, or save a message to, your default storage file, you can simply enter '>' as the path. For your default mail spool, where incoming mail is stored, use '!'.

  • m Mail to an address or addresses.

    Make sure you enter the address properly, and use appropriate subject lines. Try to give some indication of the content and purpose of the letter. If the letter is urgent, say so clearly in the subject.

  • i Return to index from within a letter.
  • q Quit elm.
  • ? Enter online help. Another '?' will bring up a full list of elm commands and functions.
  • <Space> Display highlighted message, go to the next screen.

When you exit elm you will be asked whether to delete any articles marked for deletion, and whether to move mail to the 'received' folder. If you say no the mail will remain in your incoming mailbox. If you answer yes elm will save the letters to the default mail folder 'received' in your Mail directory.

If you wish to start out in elm in a previously created folder, you can use the '-f' flag. For example, 'elm -f ~/Mail/received' will open elm and display the contents of your received folder.

You can also use elm to send mail simply by entering 'elm person@address' at your prompt. This will enter elm's send only mode. Elm also easily mails a previously prepared file with 'elm person@address < filename'.

Once you have adjusted to elm you can begin to customize it. While in elm pressing 'o' will open an options screen with several settings you can change. And for those who really feel comfortable you can edit the '~/.elm/elmrc' file. This file contains all of the user modifiable variables for elm. Elm is versatile and allows for a good deal of personal modification if the user is so inclined. However, make sure you are comfortable with the basics before setting off to customize things.


News is a system which allows users from across the globe to post articles on a wide variety of subjects for other users to read and reply to. There are many groups, which divided into separate hierarchies to make it easier to find what you are looking for. It may be confusing at first, but it really only takes a few days to have a good working knowledge of the system, and in a few weeks it'll be second nature.

You cannot only post original articles, but also post follow- up articles to existing posts, or send email to the author of a post. Newsgroups range from the technical, such as sci.aeronautics, to the creative, such as rec.arts.anime.stories, to the odd, such as alt.discordia.

Net news is informative, entertaining, and educational. You can keep track of the latest for your discipline, or your hobbies, the groups are there for you to take advantage of.

There are some basic rules, or netiquette, to be followed. The group news.announce.newusers should be read by those new to the networks for a good description of what is acceptable. However, there are some basics that are common sense.

A good strategy for new users is to read news for a few weeks without posting. Just observe the way things are done. In addition, many groups have Frequently Asked Questions lists, or FAQs, which are posted monthly. The FAQs are also available on news.answers. These lists answer the questions commonly asked on the group, questions which have been answered countless times in the past. They're designed to bring a new user up to speed without having to repeat the same answers every time a user asks.

Every group has a topic. When posting, please make sure your posts falls within the topic of the group. If it doesn't, look for a different group that is closer to your topic. When you join a group, there is no need for a "HI, I'M NEW HERE!" post. If you want to point out that you're new, simply wait until you post on a real topic and just mention it. Many sites pay for their feed and the greater the volume, the higher the cost. So, please, try not to post wastefully.

DO NOT WRITE IN ALL CAPS! It's the USEnet equivalent to shouting, and is considered very impolite. In general, just try to be considerate of the other members of the nets.

There are many programs that allow you to access the USEnet newsgroups, generally referred to as news readers. The most common is 'rn,' but both 'trn' and 'tin' are growing in popularity. 'rn' and 'trn' are directly related, and, as they are the standard, they are the best to learn.


To run 'rn' simply enter 'rn' at your prompt. The first time you do so you will see a greeting screen, be sure to read it. Some of the entries will refer to 'trn'. That is because 'trn' is an expansion of 'rn' and they share many files.

After the greeting you will be prompted on a list of newsgroups, asking whether or not to subscribe to them. Entering 'y' will subscribe to the group and prompt you for a location. Just press return and let 'rn' place it for you. 'n' will not subscribe to the group. 'Y' will subscribe to ALL groups, which may be well over 10,000 newsgroups. It is not recommended to use 'Y'. 'N' will leave you unsubscribed to all of the groups. The best procedure is the set aside a couple of hours and go through the groups with 'y' and 'n', subscribing to the ones that catch your interest.

You'll notice that the commands are in a box, like '[ynYN]'. Throughout all of the levels, 'rn' places the common commands in a box like this. The most common is the first one, and space bar will automatically select it. Pressing 'h' will always bring up online help, a good key to remember.

'rn' will create a few files for the program's use. One of which is the '.newsrc' which contains a list of the newsgroups. 'rn' uses this file to determine which groups you are subscribed to, which ones to skip, and what order to access them in.

From time to time new groups are created, and they will show up when you run 'rn'. You'll be prompted about subscribing to these groups in the same way as you were the first time you used 'rn'. Once you have completed the news group selection, and each time you run 'rn' from then on, it will present you with the groups that you are subscribed to and which contain unread articles.

When you enter there will be a brief list of the top few subscribed groups and the number of articles in each, followed by one line with the number of unread articles in the first group in line, ending with '--read now? [ynq]'. 'y' or space will read the first article in the group, 'n' will skip to the next group with news, and 'q' will quit out of news.

In addition to the listed selections there are many other options. Only a few are needed by the novice user. 'u' will unsubscribe you from the group. 'c' will catch up the group, or mark everything as read. 'N' will go to the next newsgroup, whether or not it has any unread news. 'p' and 'P' are like 'n' and 'N' except for the previous group. 'g group-name' will go to the named group; if it isn't currently unsubscribed it will ask you to subscribe. This is also how you can add new groups. 'a pattern' will add groups containing 'pattern' in their name. For example, 'a aero' would add 'sci.aeronautics' and 'sci.aeronautics.airliners' to your .newsrc. '=' will list the current articles' subjects, the article number first.

If you wish to read a specific article you can enter that article's number. If you read the article the first thing you will see is the header. The header contains information such as the author, the groups the post can be found on, the date it was made, etc. Following this is the body of the article. The body is the actual post entered by the user. If the post is more than one screen long, a bar will appear at the bottom displaying '--MORE-- (*%)' where '*' is the percentage you've seen so far. Press the space bar to see more.

At the bottom of the post you have a bar that shows the current article number, the total number in the group, and then a choice of [npq]. 'n', or space, will go to the next unread article, 'N' will go to the next article, and '^N' will go to the next article with the same subject. 'p', 'P', and '^P' work the same way, only for the previous articles.

'=' works the same as above. 'f' will allow you to submit a follow-up article to the group, without including any text from the article you are following up. 'F' is follow-up, but including the text of the article. 'r' and 'R' are similar, but they send email directly to the author of the post.

's' allows you to save the article. You can simply enter 's' and allow rn to place the article in a folder in your News directory with the name of the group. You can choose to use mailbox format [y], a plain file [n], or quit the save [q].

Mailbox format is compatible with elm. Therefore, you can use them to read the file and send email to the author of the post as with normal mail. Alternatively, you can use 's path' and the file will be saved via the path entered, such as 's ~/principia'.

'b' backs up one page. Pressing 'j' while reading an article will junk it, or mark it as read. 'm' will mark an article as unread, to save it for later. 'k' will kill the current subject thread. 'q' will quit out of the group. '=', 'c', and 'u' are the same as previously described.


'trn' is very similar to 'rn', simply being a threaded version of thereof. Threads are a chain of articles that share the same subject. 'trn' automatically follows these threads, making it easier to follow an ongoing conversation.

Upon entering 'trn' the interface will look nearly identical except that there is a new choice, [+ynq]. You can use all of the standard 'rn' commands, as covered above, in 'trn'. However, there are a few additions.

If you use '+', or space, you will enter the thread selector. This is the biggest difference from 'rn'. The unread articles in the group are listed vertically. At the left side of the screen is a column of alpha-numerics which refer to each thread. Next to those is a list of the posters' names, next is the number of posts in that thread, and finally comes the subject of the thread. You can move up the list with 'p' and down with 'n', or use the arrow keys.

Space will display the next screen of selections if there is one, otherwise it will begin reading. '<' and '>' will move to the previous and next pages, respectively. You can select a thread directly by using the keyed alpha-numeric; simply press the letter preceding the entry.

'.' will toggle selection of the highlighted thread. A '+' will appear next to the alpha-numeric when a group is selected. '=' will toggle between the thread selector and an individual article selector. This way you can choose to read an entire thread or specific articles.

<Return> will begin reading the selected articles. 'k' or ',' will mark the thread or article as killed. A '-' will appear next to the alpha-numeric for a killed thread or article. '@' will toggle all of the selections displayed with a '+'. 'X' will mark all unselected articles as read and begin reading the selected articles. 'c' will catch up the group, as in 'rn'.

Once you have started reading, it will look much like 'rn', except that the thread tree will be displayed in the upper right hand corner. The normal 'rn' commands will also work at this point, in addition 'trn' adds the following commands.

'_N' and '_P' will go to the next and previous articles in numeric sequence, respectively. '<' and '>', browse the previous/next selected thread or subject. '[' and ']', proceed to the left/right in the article tree, also left/right arrow keys. '{' and '}', go to the root/leaf of the article tree. '(' and ')', go to the previous/next related article, also up/down arrow keys.

There are many more commands in both 'rn' and 'trn' which are shown via 'h', the help command. However, the above commands will cover most situations.

It may seem confusing, but you needn't memorize all of the commands. Both programs will walk you through the steps via the boxed choices on the screen. It may be simpler for new users to start with 'rn' and move on to 'trn' once they are comfortable with the basic commands.

Weblint Validated!
Image: Valid HTML 4.0!
  © Copyright 1997, MegaZone, Revised Wednesday January 12, 2000 16:36 EST