FIU Home College of Engineering and Computing
Search:

Unix Help

request@cis.fiu.edu, Support Group

Contents
1. Introduction / First Steps

Getting an account 

Accounts in the School of Computing and Information Sciences are given to graduate students whose courses require graduate lab access. Instructors will inform students of these requirements. In the event that you require a computer science account, you must first insure that you know what your FIU E-mail address is. To find this, visit http://intra.fiu.edu/irm/sc/studsearch/index2.htm.

Researchers that were hired from grants will have their accounts requested by the grant staff or the secretarial office. If you are not sure of the status of your account, contact the grant staff member who is making your initial employment arrangements. New and visiting faculty and researchers can request new accounts through office staff or by writing an email to request@cis.fiu.edu

If you are an undergraduate looking for JCCL/AUL access, please visit the aul web site www.aul.fiu.edu. or talk to your undergraduate course instructor.

Logging in. 

a. Usernames and Passwords 

The first step in starting to work with a multiuser machine is to identify yourself as a valid user to the machine through a procedure called log in. The use of the machine is controlled through accounts. Before beginning to use the computer you should have obtained a Unix account from the School of Computing and Information Sciences (CS) system administrator, which assigns you a username and a password for accessing the systems. Your username is a unique name which the system knows you. For students this consists of the first letter of your first name, the first five letters of your last name and two digits. For example, if your name is Mark Anderson, your username might be mander03 (the last two characters are the numbers, zero three, not the letter 'oh'.) The numbering scheme is dependent upon how many other people already have the account mander## before you do. Your password will at first be assigned by CS, but you should change it when you first log in. The password ensures that it is indeed you who is using the system and not some intruder. You should guard your password carefully: never reveal it to anyone, nor write it down. See the section on Changing your password for information about changing your password.

b. Machine names 

Each computer on the School of Computing and Information Sciences (CS) network is issued a unique name that it can be accessed by. This is done so that you do not have to remember the IP number of a machine in order to access it. A machine name may be separated into several parts which each part having a significant meaning. For example, on the machine named "grads.cis.fiu.edu": the fiu.edu extension means that it is an fiu machine, the cs means that it is part of the computer science network, and grads is the name of the machine itself.

Below is a list of the servers for CS, their description, and their functions:

goliath: goliath is the primary server for graduate students. It is Sun Ultra Enterprise 250 server, running Solaris 2.8 All graduate students are encouraged to use goliath as their primary server.
leopard: leopard is the primary Linux server for graduate students. It is an Intel Pentium 4 based server, running Linux.

c. Using Telnet  

You might have used telnet in the past to access UNIX systems. This is no longer recommended because telnet is an unencrypted cleartext protocol; your password will be transmitted over the network in the clear and can be intercepted by malicious parties. See the section on ssh below to learn the new way to login.

d. Using SSH 

Malicious users have been known to "listen in" on your telnet sessions to see exactly what you type while you log in as well as throughout your entire telnet session. YES, THIS MEANS THEY CAN SEE YOUR PASSWORD AS YOU TYPE IT! Therefore, to deter or hamper them in their attempts, you may use what is known as a secure shell instead of telnet to connect to a machine. Secure shell will connect you to a machine much like the way telnet does with the exception that secure shell will encrypt the data you type. To anyone who might be listening on your telnet session, they will get garbled data that makes no sense to them. To use secure shell on a unix machine, you simply type from a local terminal:

ssh -l username machine_name

such that:

ssh -l jdoe01 grads.cis.fiu.edu

will run a secure session from the machine you are on to grads.cis.fiu.edu. Secure shell will then ask you for your password. Simply type in your password and it will log you on.

On machines running Windows, there should be a graphical secure shell program such as PuTTY or TeraTerm SSH that will allow you to login to UNIX systems.

Entering Commands 

The program you interact with is called the shell, a command interpreter. The shell prints a prompt, then waits for you to type something telling it what to do, interprets it, and executes it. The most commonly used shell at CS (like anything in Unix, there are several) is called the tcsh. We will assume for now that you are using the tcsh. You must use the simple and powerful shell language in order to issue commands to the operating system. Most of the things you type start with a word called the command. Commands are usually programs that are run, although some of them are built into the shell itself. For example, if you type date and press RETURN, the system responds with the current date and time according to its internal clock:

Code listing 1.1

% date 
Tue Mar 3 19:57:11 EST 1992

Your prompt should will look something like this: username@host 1%. Unix keeps track of each command you type, so that later on you can type the command !1 and in this case it will print the current date and time.

Some commands have arguments which are additional information you give to the command specifying the objects that it is to act upon, or modifying the actions performed by the command in some way. For example, you can tell the date command to give you the time in Greenwich Mean Time by specifying -u as an argument:

Code listing 1.2

% date -u 
Tue Mar 3 01:04:27 GMT 1992

Arguments such as -u which usually start with a minus sign, consist of one letter, and act as a control switch for the command, are called options or flags. Simple commands such as date usually have only a couple of options, while large, complicated ones such as cc, which invokes the C compiler, have numerous flags each controlling a particular facet of its task.

Unix is case-sensitive. This means that the system distinguishes between upper and lower-case letters, so you must be very careful to use the proper casing when typing in commands and filenames. *Most* things are lowercase. Notable exceptions are environment variables and some command line switches. These will be explained later on.

Getting Help 

Unix has a manual stored in the system that contains a page for every command and utility known to the system, detailing its syntax, purpose, options, etc. To read this manual you use the man command. For example:

man date

would display a description of the date command. Another helpful command is apropos, which gives you a one-line summary of all the manual pages which relate is some way to its argument. For example

apropos disk

would list all the commands dealing with disks. Using the man and apropos commands, you can learn much about the system.

man -k disk

would have a similar effect as apropos disk

There are also graphical versions of the man command and these can be run by typing tkman and xman at the prompt.

In addition, you may ask a question to the system administrators by mailing request@cis.fiu.edu . Also, more information may be found at the School of Computing and Information Sciences support and documentation pages at http://www.cis.fiu.edu/support

 

One of the very first things you should do when you log in to your account for the first time is to change the password originally given to you. Make sure you choose a good password.

The passwords that you should NOT use according to an excerpt from UNIX Password Security by Walter Belgers, are, for example:

  • all English words and derivatives ( 'laugh', 'laughs', 'laughing', etc )
  • all words from a foreign language ( it is easy to get foreign dictionaries )
  • words that can be found in the passwordfile itself ( username, user information, etc)
  • patterns like 123456, qwerty, etc.
  • geographical names
  • words from an encyclopedia
  • the license plate of a car, the roomnumber, the phonenumber, or other personal
  • information about yourself
  • given names
  • variations of a word (walter, WALTER, retlaw, Walter, walter0, etc.. )

One should pick a password that not only consists of upper and lowercase characters, or only one capital letter. It is preferable to use a non-alphanumeric character in the password (e.g. %,$,#,etc.). The use of control characters is possible, but not all control characters can be used, and it can give rise to problems with some networking protocols.

Other methods of picking a password are as follows:

  1. Concatenate two words that together consist of seven characters and that have no connection to each other. Concatenate them with a punctuation mark in the middle and convert some characters to uppercase. e.g. 'Pit+idEa'
  2. Use the first characters of the words of a certain sentence. When we use the sentence 'My goldfish are called Justerini and Brooks' as example, we would get the password 'MgacJaB!'. (Also in this case make sure you use an eight- character password with uppercase characters and/or punctuation marks.)
  3. Alternately pick a consonant and one or two vowels resulting in a pronounceable (and therefore easy to remember) word.

    Examples: 'koDupaNy','eityPOop'.

You may change your at your unix prompt using the yppasswd command.

Code listing 1.3

% yppasswd
 Current password:
 (Type your old password. It won't display.)
 New password (? for help):
 (Type your new password)
 Retype new password:
 (Type your new password again)
 
 

Password changes are processed once an hour, so your new password may not take immediate affect. Wait sixty minutes before trying to log in using your new password.

User Settings 

a. Special dot files 

Your environment is controlled by several special dotted files in your home directory. The preceding dot makes them normally invisible by standard ls. To see these files, add the -a option to any ls command that you use. You will notice that many of these files end in 'rc' which stands for run commands or resource control.

.login This is the first .*rc file that is read at boot time. This file is used to set shell independent variables such as terminal type or search path.
.logout This file is executed when the user logs out from the system. UCS also provides this file for users. It is usually used to remove all user processes before logging out. This file may or may not exist in your CS account.
.exrc This file provides the ability to set characteristics to your vi or ex editing session. Consult the approprate man page for configuration options.

b. Your .cshrc 

Your .cshrc file is very important. It contains the various settings and the paths for the terminal that you are typing in. The slightest change in this file may result in not being able to run certain commands and/or a corrupted display when you run programs that require the display. Therefore, unless you know what you are doing, it is best not to alter this file. Even if you DO know what you are doing, it is always a good idea to make a backup copy of it before attempting to change it.

c. Other terminal and display settings  

Some programs, such as full-screen editors, need to use the full capabilities of your terminal, so they need to know exactly what kind of terminal you are using so that they can generate the proper control sequences to move the cursor, blank the screen, etc. The system keeps this information in what is called an environment variable. To show your current setting, enter the command:

echo $TERM

To set the correct terminal, use the command

setenv TERM termid

where termid should be chosen from the following table:

If You use this terminal/emulation Use_termid
Digital VT420 vt420
Digital VT200, VT240, VT340 vt200
Digital VT102 vt102
Digital VT100 vt100
MIT's xterm xterm
ANSI Emulation ansi
Wyse 50 wyse50
MacTerminal mac
Amiga ANSI amiga
Standard Kermit kermit

Additional termids can be found in the file /etc/termcap. Most people should be okay using "vt100" as their terminal type.

d. Aliasing 

In unix, there is a utility known as aliasing. The idea of aliasing is to make ones life simpler. For example, lets say the situation occurs where you want to see a full directory listing frequently. To do this, you would have to type ls -la quite often and it would become a little tedious. What you can do instead is make an alias for this command. Thus, you will only need to type your aliased command everytime. The aliasing syntax is:

alias 'full command in single quotes'

So to make an alias called "dir" for our ls -la command, you would type, at your prompt:

alias dir 'ls -la'

The quotes are quite important so please do not forget them. As you can see, this utility also lets you alias any complex command or even a sequence of commands, provided that you adhere to proper syntax, to something much simpler or some word that you are more familiar with.

Now, suppose you have grown accustomed to your alias and you really want to keep it. The problem is that the alias that you made will only last until you log out. Thus, when you log in again, you will have to retype that whole alias command again. If you really like this alias, it is going to get annoying to type it in everytime you want it. So you ask, "Is there some way to get the alias automatically everytime I log in?" The answer is "Yes." You can put your new alias at the end of your .cshrc or some other file that you have decided to "source" everytime you log in. The syntax of the alias in the .cshrc is exactly the same way as you would type it at your prompt. If you are using pico, please ensure that the command does not "wrap around" to a second line, as that would break the quotes around the actual command and render useless the alias as well as all the rest of the commands that your .cshrc runs after your alias line.

e. Xwindows Concepts 

Most CS machines running Unix will also be running a Graphical User Interface(GUI) known as XWindows. The first thing you would see on these machines is the login screen. You simply type in your login name and password on this screen and it will run either a default window manager or a window manager of your choice. Inside the window manager, you will be able to multitask and open multiple telnet and local sessions. You will also be able to run GUI programs such as netscape. Please remember that when you close all the windows, it does not mean that you are logged off. You must choose the logoff option on the window manager to completely log off. In other words, if you do not see the login screen that you started with, you have not logged out of the machine properly.

There are two files that are related to the customization of your Xwindows:

.xinitrc The .xinitrc defines the initial set up of your desktop in the X Windows environment. When this script exits, your X session will be terminated and you will be logged out.
.Xdefaults

The .Xdefaults file specifies the characteristics of windowed applications. Here are some useful entries for controlling xterm characteristics:

  • XTerm*c132: True
  • XTerm*scrollBar: True
  • XTerm*saveLines: 1024
  • XTerm*eightBitInput: True
  • XTerm*charClass: 36-37:48,42-43:48,45-47:48
  • XTerm*reverseWrap: True
.fvwm2rc Beyond the .xinitrc, there exists a "window manager." By default, the window manager for CS is fvwm2 and the settings for it are controlled by this .fvwm2rc file. You may also type 'man fvwm' at your prompt to obtain a list of resources that you can control as well as a more detailed description of the window manager.
Note: Once you have configured your environment, you should save a copy of relevant files in .bak. If you fun the new_user_setup script again, it will overwrite existing files

Using Email 

a. The CS Mailing System 

Your unix mail address is username@cis.fiu.edu. This is completely separate from any vax accounts you may have. Though you may have the same username on both servax, serss1 and over here in CS, keep in mind that they are separate and distinct accounts.

All the machines in the CS department use the same mail drop. Mail to any machine in the department will go to a central department server and all outgoing mail will appear to have come from the departmental server. The maildrop is called cis.fiu.edu.

The standard mail programs (usr/ucb/mail and /usr/ucb/Mail) have been replaced by a specially configured version of pine. Pine is a full-screen, menu-driven mail program with many features and utilizes the pico editor. You may access pine through the menu program, or by typing pine at your unix prompt. (More information on Pine below)

You may manually check for new mail messages without going into mail by typing the command: chkmail

Mail that is received is available for reading via imap3 and pop mail reading protocols. You can read CS mail via Pine or other imap3 clients by having them conenct to imap3.cis.fiu.edu. Pop clients (like Netscape or Eudora) can connect to pop3.cis.fiu.edu to access CS mail.

On CS lab servers running solaris 2 (goliath, mozart) the mail can be found in the normal system mailbox /var/mail. On CS lab servers running Solaris 1 (schema, scs) the mail can be found in the normal system mailbox /var/spool/mail. On these systems traditional unix mail and the openwindow version, mailtool, will work. Also available is the Rand mail handler and the xwindows version xmh.

If you want to forward the mail from your CS account to another account automatically, you may specify it in the .forward file.

There are also several mailing lists available for use by faculty, graduate students, and staff. You may use these mailing lists by entering them in the To: field of a mail message. They are:

scs-fac To contact all Computer Science Faculty
scs-asst To contact all Computer Science Graduate Assistants
grads To contact all Computer Science Graduate Students
scs-fac-staff To contact all Computer Science Faculty and Staff
scsnet-info To make system upgrade announcements
request To request for help and assistance with the CS lab and networks

b. Pine 

Pine is your standard mail reader. It has a full-screen terminal interface. To invoke it type:

pine

This will bring you to the Main Menu for pine. The version of pine is printed at the top left-hand corner of the screen. If it is your first time using pine, you can choose S Setup from the menu and then C Config from its submenu. This will allow you to customize your pine session. When you customize your pine mailer in this manner all changes are actually found in the file .pinerc in your home directory. This file can be edited to change your configuation too.

Reading Mail
Sorting You sort with the '$' key while in the Index. You may sort based on Subject, Arrival, From, Date, Size, Ordered Subject, or Reverse. The options are listed on the menu bar.
Searching You search through your messages by using the W Whereis command. If you search while in the Index, it will match on the From and Subject lines of all your messages. If you search while in a message, it will search within the body and header of that specific message.
Saving Saving can be done in two ways. The first option is to S Save an article or collection of articles to a separate mail folder. The other is to use E Export the message to a file in your home directory.
Aggregate Commands To use aggregate commands, you must first select a group of articles on which you would operate. The way you select is by typing ';' while in the Index. You are then queried for the selection criteria (All, Current, Number, Date, Text, Status). Selecting based on text allows you to specify matches on From, To, CC, Subject, and All Text. Once you have selected articles, you may A Apply an action on the group of messages selected (Delete, Undelete, Reply, Forward, Print, Take Address, Save, Export, Flag, or Pipe). Also, once a group of messages have been selected, you can Z Zoom to confine your view to only the selected messages.
Printing

To print from pine use the Y command. It will send your current mail message to the lpr command to be printed. The lpr command will print to the printer specified by your PRINTER environment variable.

Another way to print is to use the | Pipe command. This needs to be enabled in the config for pine (see above). Once you have a selected message, you can pipe the message into any command that you might have in your environment, including personal scripts. In this case, you would pipe it into a print command.

Composing Email
Sending Email

You send mail by using one of the following commands:

  • C Compose Compose a new message.
  • R Reply Reply to a message.
  • Marks the current message as A Answered.
  • F Forward Forwards a message.
  • B Bounce Bounces the message to a specified address (similar to forward).
Postponing

If you find that you have to postpone a message before it is completed, use the ^O Postpone command. It will save your unfinished message in a folder called drafts. When you choose C Compose again, it will ask you if you would like to continue your postponed message by default. If you have several postponed messages, it will provide a listing of messages to resume.

sent mail archives A feature of pine is that it saves all of your sent messages into sent-mail. Each month, it inquires if you would like to move your sent mail into a folder for that month, and if you would like to delete past sent-mail monthly archives. This feature is excellent for documenting email transactions without cluttering your inbox with messages copied to oneself. This feature is automatically enabled, and options may be configured in the S Setup C Config section from the Main screen.
Address Book Another nice feature of pine is that you are able to use a personal addressbook to simplify sending email. The addressbook can maintain aliases for individual users as well as mailing lists. The user is able to create addressbook entries from the main menu by entering A Address Book and choosing A Add. Another method is to interactively take names as you receive mail. When reading a message from a person not currently in your addressbook, you may select T Take from either the Index or while reading. It will prompt you for information while supplying default information from the current message.

Further help on pine configuration may be found on the pine configuration page

Using Netscape 

To use netscape, you must first login to a machine that is either running some Windows variant of Xwindows since it is a graphical program. Once you have logged in, you should open a local terminal and type

netscape &

at the prompt. If your paths are mapped correctly, you should see a netscape window pop up within a minute or two.

To visit a website, you merely type the entire internet address (also known as a URL) at the textbox marked "Location:" in netscape. Please be advised what you type here is case sensitive. In the event that you do not see the location field, you may, from the menu bar at the top, click file and then open location. It should open a popup window for you to type the address. Then, press the [Return] key to go to the home page you have specified.

Once the page that you were going to has loaded, you will notice that there are certain words that are underlined. These are links. They usually provide more information on their subject and you may click on these to proceed to the page that they lead to. Sometimes the links are also in the form of pictures. To distinguish these from regular pictures, you may move the mouse over them and if it turns into a "hand with the index finger extended," it is a link. Thus, the rule is, if you see the hand, it's clickable.

As you progress along the links, it may be quite easy to be sidetracked into a dead end and still not be able to find what you want. In this case, you may either click the "Back" button to move backwards along the series of pages that you went through. This button is the first of the row of buttons that are below the menu bar. The same concept applies to the "Forward" button with the exception that it moves forward along the series of pages. There is also the "Home" button that will return you the web page that you started browsing from.

To print an interesting document that you encounter, you merely click the "Print" button. Likewise, the other buttons along that row will pretty much do what is shown on it. The "Stop" button will stop any page in the midst of loading. This is especially convenient if the page that you are loading happens to "hang" while it is halfway finished.

Important: For further help while using netscape, you may click on the "help" option on the menu bar. This is located toward the upper right hand corner of the netscape window.

2. Files and Directories

In Unix, the information in the system is stored in files, which are sequences (streams) of characters with no structure but that imposed on them by the programs which use them. Each file is owned by a user, who has the ability to protect the file from being read, written or executed by other users. Files are contained in directories. Both files and directories have names. Directories are arranged in a hierarchical structure, a directory tree: a directory can contain files or other directories. If directory A contains directory B then A is called the parent of B, and B is called a subdirectory of A. So far, this is not much different from MS-DOS or VMS.

The highest directory in the hierarchy is called the root directory and its name is a single slash (``/''). Files and directories are denoted by means of a pathname, which can be absolute or relative. An absolute pathname starts with a slash and specifies the sequence of directories which must be traversed to reach the file from the root directory. A relative pathname specifies the sequence of directories to get to the file from the current directory.

Directories in a pathname are separated by slashes. For example,

/usr/local/bin/perl

is an absolute pathname, and

tex/unixint

is a relative pathname. Note that the slash is the ``forward'' slash (``/''), not the ``backslash'' used by MS-DOS. The current directory (also called working directory) is a useful notion because it allows you to work with the files by using just their filenames, without having to specify the path to them from the root directory.

When you log in, the current directory is your home directory. When your account was created, a home directory is made for your use. You can create your own files and subdirectories under this home directory. The system will prevent you from creating files anywhere else, except in certain temporary areas.

Files may contain text (human-readable) data in ASCII, or binary data which can include any character. Unix tries to keep most information in text files, since it has a plethora of tools for manipulating text, and they are easier for the user to work with, but in order to save space or for efficiency reasons some data, such as executable images, object files, libraries, index files, etc., must be kept in binary form.

Filesystem Concepts 

At FIU, each user's home directory is accessible from any machine through the pathname /homes/username. Also, the C-shell lets you refer to a user's home directory by specifying ~user. To list the files in user mander03's home directory, for example, you might enter:

ls -a ~mander03

When you receive a CS account you will also receive a CS home directory. This is completly independent from your UCS homedirectory. If the machine that your home directory lives on is down, you will not be able to access your files. All of our directories are accessable from UCS machines as well by typing the path of your home directory. For example, if your home directory is /home/grads/jdoe01, you would type

cd /home/grads/jdoe01

will take you to your CS home directory.

These are maintained via symbolic link and updated once a day.

Files are stored on filesystems which reside on disks. Files share the space on one filesystem, and cannot overflow the filesystem so that when a filesystem gets full, you cannot create new files or write any new information to that filesystem. To find out how much space if free in the filesystem containing the current directory, use the df (Display Filesystems) command with the current directory as its argument:

Code listing 2.1

% df .
Filesystem            kbytes    used   avail capacity    Mounted on
/dev/dsk/c0t1d0s2    3939496     472 3545084     1%      /disk/67

This shows that the current filesystem has 3545.084 megabytes free and is 1% full. When a filesystem containing the home directories of many users fills up, some of those users must delete some of their old files so that all can continue working. It is a good idea to keep your directories tidy and remove any old data which you don't really need.

User filesystems are those containing users' home directories. We have several user filesystems at FIU all of which are under /home:

  • /home/scsgrad for CS graduate students
  • /home/scsfac for CS faculty and staff

There are also filesystems that contain the binaries (runnable programs) and they are as follows:

  • /home/compsci/sun3/bin
  • /home/compsci/sun4/bin
  • /usr/local/bin

The ls command 

To get a longer, more detailed list with ls, use the -l flag. For example:

Code listing 2.2

% ls -l
total 49
-rw-r-----   1 mander03      48770 Aug 10 11:55 unix.tex
drwxr-x---   2 mander03        512 Aug 10 11:53 zor

The long list contains information which merits an explanation. The first field consists of the file permissions which are switches attached to each directory entry and determine who is allowed access to it. The first character denotes the type of entry, and is ``-'' for files and ``d'' for directories. The next nine characters are interpreted as three sets of three switches each. The first set refers to owner access; the second refers to access to others in the file's group, and the last refers to all others. Within each set, the three characters indicate permission respectively to read, write, or to execute the file as a program. For directories, ``read'' means permission to list the files in it, ``write'' means permission to create or delete files in it, and ``execute'' means permission to search the directory (access files in it, or go through it to get to a deeper file). In the above listing, all the files are readable and writable by the owner mander03, and readable by the group. The subdirectory zor is, in addition, searchable by mander03 and the group. All other access is denied.

The second field is the number of links to the file (an explanation regarding links is beyond the scope of this document). The third is the username of the owner of this file (mander03); only the owner can change the permissions. The fourth field is the size of the file in bytes. The next three fields give the date in which the file was last modified. Finally, the last field is the file or directory name.

Filenames can contain any character except for the slash, and can be very long, up to 256 characters on our system. However, filenames usually are alphanumeric strings of 14 of fewer characters. It is useful also to tag filenames with ``extensions'' according to their type, which means that C language files end with .c and TEX files names end in .tex, but these are only conventions which are by no means enforced. Unlike VMS and MS-DOS, Unix considers the dot ``.'' character like any other character. You can have several of them in a filename, etc. As was previously mentioned, filenames are case-sensitive which means that upper and lower case letters are considered different characters.

The ls command does not list files whose names start with a period ("."), unless you issue the -a flag.

Code listing 2.3

% ls -a
.                  ..                 .hidden           unix.tex
zor

As you can see, three new entries now show. The . and .. entries represent the current and parent directory, respectively. Every directory contains these two entries, which are useful for referring to the current and parent directories without having to specify a name. For example you can move up one directory level by issuing the command cd .. to change to the parent directory. Notice also there is a file named .hidden which now appears.

Another important option is -g, which, when combined with -l, makes ls show the group of each file.

Code listing 2.4

% ls -lga 
total 4
drwxr-x---   2 mander03   i6275ci       512 Mar   4 12:45 .
drwxr-x---   3 mander03   i6275ci       512 Mar   5 10:16 ..
-rw-r-----   1 mander03   i6275ci        42 Mar   4 12:34 ideas
-rw-r-----   1 mander03   i6275ci         0 Mar   3 13:15 test
-rw-r-----   1 mander03   i6275ci        42 Mar   4 12:41 thoughts
                                

We used the ``l'', ``g'', and ``a'' options as ``-lga'' to get a long listing with groups which shows all files. Most commands will let you combine options in this way. You can see the . and .. directory entries and the group i6275ci of each file. Groups allow several users access to the same file. To find out which groups you belong to, enter the groups command:

Code listing 2.5

% groups
i6275ci wheel news ucssysadm   panthersoft gsmgr dba

The ls command has many other options which can be mixed in different ways to modify its behavior. Look at the manual page using man ls to learn more.

File Permissions 

The chmod (change mode) command enables you to change the access flags on a file or a directory. The syntax for this command is:

chmod whoperm file1 file2 ...

where who is one of the letters ``u'', ``g'', ``o'', or ``a'', meaning user, group, others, or all; is either ``+'' or ``-'', meaning add or remove; and perm is ``r'', ``w'', or ``x''. For example,

chmod a+r hello.txt

gives everyone permission to read the file hello.txt

chmod og-w *.priv

removes write permission for ``others'' from all files in the current directory whose names end in .priv, and

chmod u+rwx runme

gives the user (you) all the permissions (read, write, and execute) on the file runme.

Notice that in Unix there is no explicit ``delete'' permission flag. You can delete a file if you have write permission to its parent directory.

Important: You should be very careful about giving write access to the group or others. Someone with write access to a file in your account or directory can easily erase your files.

3. File Patterns

You can also use patterns, also called wildcards to specify files. Patterns are special file specifications that can stand for one or more matching files: the asterisk ``*'' stands for any number of characters, while the question mark ``?'' stands for any one character. For example, to list only files that start with the letter ``u'' use the command ls u*.

The word ``files'' in the following tables is taken to mean files or directories. They are considered the same for the purposes of pattern matching.

Pattern Matches filenames that
* Are in the current directory (except those that start with a period)
*.* Contain a period (again, except at the beginning)
u* Start with the letter ``u''.
*.tex Have extension ``.tex''.
a?k* Have ``a'' as the first letter and ``k'' as the third.
*t?? Have ``t'' as the third letter from the end.
/tmp/* Reside in the tmp subdirectory of the root directory.
zor/* Reside in the zor subdirectory of the current directory.

One fact one should know about file patterns is that they are constructs of the shell, so that they are expanded in the command line. When you type

ls u*

the shell expands the filenames in the command line so that the ls command never sees the pattern, but instead sees

ls unix.txt unixint.aux unixint.dvi unixint.log: : :

This can have unexpected effects when one tries to rename groups of files, for example:

mv *.abc *.def

is seen by the system as

mv file1.abc file2.abc file3.abc file4.def ... fileN.def

and tries to move all the files in the current directory with extension ``abc'' or ``def'' to the last file with extension ``def''. Beware of this common mistake.

4. Input and Output

When you enter a command, Unix runs a program. A program in execution is called a process. While the process is running, it receives input from some source and produces output. Most commands generate their output to your terminal or window. The ls command, for example, prints its listing on your screen. This is called standard output. Many commands also take input from your keyboard. For example, the cat command repeats whatever you type when you invoke it without arguments. Press Control-D when you wish to signal that you are done.

Code listing 4.1

% cat
This is a test
This is a test
It prints what you type
It prints what you type
Ctrl-D
                                

The Control-D sequence usually stands for end of file for the terminal, meaning the the input stream has run out. Input from your terminal (keyboard) is called standard input. One of the most powerful and interesting concepts in Unix is input and output redirection. This means that you can redirect the standard input and output of any program. You can have the output of cat go to a file by using the > sign followed by a filename as follows:

Code listing 4.2

% ls
ideas test thoughts

% cat > names
Eve
Mary
Alexandra
Betty
Ariel
Mindy
Tatiana
Ctrl-D

% ls
ideas names test thoughts
                                

Again, you must press Control-D to indicate the end of the input. This creates a file called ``names'' with the text that you type in it. The cat command reads the names from standard input (your terminal) and produces them as standard output, which you redirected to the file names. This is a simple way to create small text files. You can redirect standard input in a similar way. For example, cat < names and cat names both display the file. The first reads from standard input which has been redirected from the file names; the second reads from the file explicitly named in the command line. You can redirect both input and output. Another way to copy a file (rather than using cp) is

cat < file1 > file2.

There is also a way to redirect a program's standard output so that it goes into another program's standard input. A group of several commands, run in such a way that the output from the previous command goes into the next, is called a pipeline. Using this feature, you can build pipelines of simple programs which perform more difficult tasks than any single command. To make a pipeline you use the vertical bar symbol (also called pipe in Unix) to separate the commands. For example,

Code listing 4.3

% grep r names
Mary
Alexandra
Ariel

% cat names | grep r | sort
Alexandra
Ariel
Mary
                                

Here, the cat command outputs the file, which goes into the grep command which only outputs the lines containing the letter ``r'', then those lines are sorted by the sort command which outputs the sorted list to standard output, your screen. Simple, isn't it? You can redirect the output of the last command to a file using > or the input of the first command using >, as in

cat < names | grep r | sort > sorted.names

One interesting fact is that Unix runs all these commands at the same time so that you are running three processes at once, each passing information to the next in an assembly-line-like fashion.

You can find out more about I/O redirection by looking in the C-shell manual with the command man csh.

5. Other Useful Commands

Getting a Hardcopy 

Printing can vary depending on the operating system one is working on. There are two environments supported by the staff of Computer Science: Unix, and Windows. The laser printers available in the labs can accept text and postscript (ps) files. Postscript is a special language developed by Adobe that allows professional typesetting on printers and other devices. Many programs, such as LaTeX and Interleaf, generate postscript to be sent to our laser printers. Note that postscript consists of imbedded text commands and begins with the header %!. If a postscript file is sent to the printer without this header, it is assumed to be text.

Below is a description of how to submit, monitor, and delete a print job from a queue on each type of system. Monitoring a queue will also display the job numbers.

a. PRINTING FROM UNIX 

lpr -P<printer> <filename>. Sends the file to the printer
lpq -P<printer> Displays the current printer status
lprm -P<printer> <job number> Removes a job from the printer

b. PRINTING FROM WINDOWS NT 

To print from Windows NT, users must first connect to a printer using the Win NT Print Manager. The steps are:

  1. Run the Print Manager application from the Main program groups.
  2. From the Printer menu select Connect to Printer and choose one of the network printers available (see printer names).

Files can be printed directly from a native Windows NT application or from the command prompt. Using the command prompt, users can send text as well as postscript files to any connected printer type:

<filename> \\SERVER\PRINTER

Please note that printer usage is restricted for the printers press and scribe. Graduate students should send their print jobs to pen or pencil during normal business hours of 9am-5pm weekdays. Also, documents that are larger than 1MB in size should be printed after hours.

Printer Names 

Printer Name Printer Type Location Access Policy
pencil HP LJ ECS 268 Faculty & Graduate Students
pen HP LJ ECS 281 Faculty & Graduate Students
press Lexmark ECS 376B Faculty
scribe HP 4 ECS 376B Faculty
np1 HP LJ ECS 251 HPDRC

Editing a file 

A text editor is a program that allows you to modify a text file in a comfortable fashion. There are several editors available in our Unix system at FIU. Two are line editors: ed, and ex. Line editors allow you to change the file one line at a time. The three main screen editors are vi, pico and Emacs. The vi editor (visual) is a standard part of every Unix system and is quite powerful, but its user interface is somewhat outdated. The Emacs editor is a more advanced editor, with a tremendously flexible lisp-based command language, but it is also bigger and takes longer to start up. The pico editor is a more user-friendly version of the emacs editor, though it does not have all of the powerful macro capabilities of emacs.

Before you use any of these full-screen editors, make sure your TERM environment variable is correctly set as explained in Section 2.6. For emacs and pico, set the TERM variable to vt100.

a. The vi Screen Editor  

To use vi, enter the command

vi filename

vi has two main modes, insert mode and command mode. When you are in insert mode, keys that you type are inserted into the text. When you are in command mode, the same keys cause different effects. vi starts up in command mode. To switch from command mode to insert mode, type ``i''. To switch back into command mode, type ESC (the escape key) or Ctrl-[. The following table lists common vi key commands.

Keys Effect of key in command mode
i Enter insert mode
a Enter insert mode after current character
x Delete character under cursor
o Open new line after current line
O Open new line before current line
r Replace one character
dd Delete current line
yy Yank current line (copy it into internal buffer)
p Put back last line(s) deleted or yanked
D Delete to end of line
0 Go to beginning of line
$ Go to end of line
arrow keys Move cursor
h, j, k, l Move cursor left, up, down, and right
Control-L Redraw screen
Control-F Move forward one screen
Control-B Move back one screen
n command Execute command n times
/ pattern RETURN Search for pattern
:n RETURN Move to line n
:w RETURN Write (save) file
:q RETURN Exit editor
ZZ Save file and exit
Note: Note that the .exrc file provides the ability to set characteristics to your vi or ex editing session. Consult the appropriate man page for configuration options.

b. The Emacs Screen Editor 

Most computer systems have many different screen editors which have been written for them, but Unix appears to have two: vi, ``because it came with the system'', and the myriad varieties of Emacs. It seems that every time someone writes a new screen editor, someone else decides that he can make Emacs do everything the new editor can do, including a perfect emulation of the new editor, so the newcomer dies, forgotten, while Emacs forges on, undaunted. Emacs is huge, containing a complete LISP interpreter, a hypertext help, and lots of other features. It is not only an editor but an intelligent programming environment. It is eminently flexible: there are Emacs emulations for vi, and for the VMS EDT editor, and Emacs modes for most programming languages which give the editor some knowledge about the syntax of the language, allowing it to help you match parentheses, fix indentation, etc. To use Emacs, enter

emacs filename

In Emacs, any regular character you type is inserted into the text. To perform editing functions, Emacs uses control keys. The following table lists the most common control keys. Here, the letter "C" shall stand for holding down the Control key, and the letter "M" shall stand for pressing the ESC key before pressing the next key.

Key Effect of Key
Control-d Delete character
Control-k Delete to end of line
Control-a Go to beginning of line
Control-e Go to end of line
Control-e Go to end of line
Control-v Move forward one pag
M-v Move back one page
C-x C-s Save file
C-x C-c Exit
C-x [ Go to beginning of file
C-x ] Go to end of file
C-space Set mark
C-w Delete from mark to cursor position
C-y Put back last thing deleted
C-l Redraw screen
C-s Start search
C-s Start search
C-g Interrupt anything
C-_ Undo last operation
C-x 2 Split screen
C-x 1 One screen
C-h Help

The Emacs editor also offers to run a tutorial when you first start it.

There is a problem with Emacs: it uses the key Control-S for many important functions. The problem is that terminals also use this key to stop output, so that when you press it, the terminal gets it first, and stops output and Emacs never sees it. For this reason, it may be better for you to run vi if you are on a terminal, although there are things one can do to get around this.

c. The pico screen editor 

The pico editor is one of the variations of the emacs editor mentioned above. pico is the editor that comes with the mail program pine, which is also available at FIU. It uses many of the same ctrl-key commands as emacs, however, one difference is that there is brief list of commands always listed at the bottom of the screen. It includes automatic text wrapping and a small spell checker. This editor is recommended for beginning unix users. To use pico, enter at the prompt:

pico filename

Standard Unix Commands 

To find out your current directory, use the pwd command. To change the current directory, use the cd command with the new directory as the argument. Without an argument, cd takes you to your home directory. To create a subdirectory, use the mkdir command with the new directory name as its argument:

Code listing 5.1

% pwd
/a/escher.cis.fiu.edu./disk/53/mander03

% mkdir zor

% cd zor

% pwd
/a/escher.cis.fiu.edu./disk/53/mander03/zor

% cd /usr/local/bin

% pwd
/usr/local/bin

To list the files in a directory use the ls command. The ls command gives you a short, alphabetically sorted list by default.

Code listing 5.2

% cd ~

% pwd 
/a/escher.cis.fiu.edu./disk/53/mander03/

% ls 
#unixint.tex# unix.txt unixint.log
unixint.tex ideas unixint.aux unixint.ps 
zor test unixint.dvi unixint.tex

To see the contents of a text file, use the cat command. If the file is longer than one screen it is better to use the more command, since it pauses after every page. For example:

Code listing 5.3

% cat ideas
nothing I can think of
in definite terms.

To copy a file, use the cp command. To rename or move a file, use the mv command. Both of these accept as arguments the source and destination. If the destination is an existing directory, the file is moved or copied into the directory. Examples:

Code listing 5.4

% ls
ideas    test     zor

% cp ideas ideas.copy

% ls
ideas             ideas.copy       test              zor

% mv ideas.copy thoughts

% ls
ideas             test              thoughts          zor

As you can see, cp copies files and mv renames them. Here are some examples of the use of mv to move files into a directory called zor.

Code listing 5.5

%ls
ideas   test    thoughts    zor

% mv thoughts zor

% mv test zor

% mv ideas zor

% ls
zor

% cd zor

% ls
ideas test thoughts

Notice in the example that zor is a subdirectory. Other useful commands are grep which allows you to search a file for a particular string of characters, and sort which sorts lines. For example:

Code listing 5.6

% cat mending.wall
something there is that does not love a wall
that sends the ground-swell under it
and spills the upper boulders in the sun.

% grep sends mending.wall
that sends the ground-swell under it

% sort mending.wall
and spills the upper boulders in the sun.
something there is that does not love a wall
that sends the ground-swell under it

In the example, grep printed only the line that contained the word ``sends'' and sort puts the three lines in order.

As you can see, Unix commands are short (some people say cryptic), and are used as mnemonics. Most names make some sense -- LiSt, Change Directory, MaKe Directory, Print Working Directory, CoPy, MoVe, Generalized Regular Expression Print. Most of these commands take multiple arguments when it makes sense. For example, when given several arguments, ls lists those files or directories only, cp and mv try to copy or move all the files except for the last one into the last one, which should be in that case a directory, and grep searches all files listed for the string specified as its first argument.

Also of worthy note, if you are using the tcsh shell, you may type [control]-D at the prompt after typing the first few letters of the command. This will list all the commands that match those first set of letters. It is particularly useful if you only remember a part of the command but don't exactly remember the entire command.

Code listing 5.7

% da
daps    date    datemsk

In the above example, [control]-D was typed immediately after typing da. The resultant list of commands are the ones in your path that start with da.

Local Commands 

There are hundreds of commands and utilities in the system to perform many tasks, both large and small. The following table lists some commands, not mentioned before in this document, with which you may wish to become more familiar. Most of these are in the directories /usr/bin, /bin and /usr/ucb, while others are local and reside in /usr/local/bin.

For help on a command, enter

Below is a chart of commands that may be executed from the prompt:

Command Purpose
arch Show the architecture of the machine
awk, nawk Pattern matching language
cal Show the calendar
calendar *Simple reminder service
cc C compiler
compress, uncompress Compress and uncompress a file
cut Extract fields from files
diff Display differences between two files
du Show disk usage by directory
egrep Extended global regular expression matcher
expr Compute expression
file Show type of file
find Find a file in a directory hierarchy
ftp Transfer files between machines
grep look for text in file
gzip, gunzip Use GNU unzip and zip (better than compress
head Display the first lines of a file
jobs List the active jobs under job control
hostname Give the name of the current machine
ln Make hard or symbolic link
nice Run program at lower priority
paste Join lines of several files
quota Show disk usage limits
reset Reset your terminal
rlogin, telnet Login to another machine on the net
rmdir Remove a directory
rsh Run shell command on another machine
rup Show which machines are up and their loads
script Make a copy of your session to a file
sed Stream editor
sort Alphabetize a file
tail Display the last lines of a file
touch Update the modification time on a file
wc Count the number of characters in a file
which Show which command is executed
whoami Tells you your username

Some Additional Commands (Not all these commands are available on all hosts)

Command Purpose
dvips Convert a DVI file to Postscript
f77 Fortran 77 compiler
g++ GNU C++ compiler
gcc GNU C compiler
gnuplot Plotting package
gs Ghostscript Postscript previewer
ispell Spell checker
kermit File transfer program
latex LaTEX document preparation system
mf Metafont font design tool
perl Powerful pattern matching and report generation language
rn Usenet News reader
rx, rz, sx ,sz Xmodem and Zmodem file transfer programs
tex TEX typesetting package
tin Usenet News reader
tn3270 IBM 3270 terminal emulation
zip, unzip Filepackingsoftware
6. The Envrionment

Each process in Unix has an environment which consists of environment variables and their values. The environment holds configuration information which is often crucial for the proper function of some commands.

To display the current environment, use the printenv command. To set an environment variable, use

setenv VARIABLE value

To display the value of a single variable you can type

echo $VARIABLE

You already saw the environment variable TERM previously. This variable sets the terminal type for full-screen programs. Environment variables have by convention uppercase names. Some of the more common environment variables are TERM, DISPLAY, PATH, NNTPSERVER. To see what your variables are set to, type

setenv

A very important environment variable is the PATH, which contains the directories, separated by colons, in which the commands which you run are searched for. If you type a command which is not in one of the directories mentioned in your PATH, the system gives the error: ``Command not found''. You should make sure your PATH includes at the very least,

/usr/bin:/usr/ucb:/bin:/usr/local/bin
7. Standard Unix Directories and Files

Unix puts programs and supporting files in standard places. It is a good idea to know where everything is so that you have a better understanding of how Unix works, and how to find things.

The /tmp directory is exactly as its name suggests. It is a place where the system temporarily stores files for certain programs that may require it. It may also be possible for users to store their files here temporarily as well. However, care should be taken that these files are not excessively large or kept in the directory for a long period of time. Furthermore, the directory is periodically cleaned out as required, and thus, files stored here are volatile.

The /etc directory holds the files which define the machine configuration. There are files describing the terminal and printer types known, the message of the day, and filesystems.

There are also instructions for what the machine should do when it boots, information about services offered, etc. Some administrative commands are also stored there. The /usr/bin and /usr/ucb directories hold the system software. These are the commands such as lpr, cp, mail, etc. Xwindows programs are stored in /usr/openwin/bin. The manual is stored in the directory /usr/man. There are several subdirectories, one for each manual section: the nroff (unformatted) sections of the manual match man* while the formatted sections match cat*.

The directory /usr/local/bin has local software installed at FIU. Some of this software consists of useful utilities. Others are complete large software systems.

There is also some important local software stored in /home/share/bin. Other important standard directories include /usr/lib, which holds the system libraries and fonts, /usr/include, which contains C include files, /usr/lang which has unbundled languages such as Pascal and FORTRAN.

8. Job and Process Control

The normal way you run a command is in the foreground, meaning that whatever you type at your terminal is fed as input to that command; you interact with it. A nice feature of the shell is that it lets you put your process in the background. The shell calls processes jobs, and numbers them 1, 2, 3, and so on. A background job releases your terminal so you get your prompt back and can continue to issue more commands, while the background job keeps running unless it needs some input from your terminal, in which case it stops. Background jobs can normally produce output to your terminal, but you can arrange for them to stop in this case, too.

To put a job in the background, issue the command the normal way, but add an ampersand (&) to the end of the command line. To list your current background jobs, use the jobs command.

Code listing 8.1

% compute pi &
[2] 27720

% echo "10000 300 ^ p" _ dc &
[3] 27725 27726
[3]     Done                    echo 10000 2000 ^ p _
        Running                 dc

% jobs
[2]   + 27720 Running                 compute pi
[3]     27725 Done                    echo 10000 2000 ^ p _
        27726 Running                 dc
                                

The shell's job listing has a number in brackets ([2] and [3], above), which is the job number, the job most recently put into the background is called the current job and is marked by a ``+''. The other number (27720, above) is the Unix process number, and is a global system number which serves as a unique ID for a process. You can also temporarily stop and put a job in the background by pressing Control-Z during the execution of that job. To restart the job in the background, use the bg command right after you press Control-Z. To bring a job back to the foreground, use the fg command, or simly type %job# where job# is the number given by the job command in brackets.

You can terminate jobs by sending them a signal. To do this, use the kill command with the process number as the argument. You can also use job numbers preceded by percent symbols.

Code listing 8.2

% kill %2
[2]     Terminated             compute pi

% kill 27726
[3]     Done                   echo 10000 2000 ^ p _
        Terminated             dc
                                

Sometimes a process will refuse to die because it catches the default terminate signal. You can then send the kill signal, which cannot be caught, to the process, using kill -9 processnumber. This ensures it will terminate.

Be careful using Control-Z. Remember that it does not exit the program as in VMS, nor does it signal end of file as in MS-DOS; in Unix, it merely stops your process and puts it in the background. The process is still there. You can log out and it will still remain in the system until it is killed. Your shell will forget about it when you log out, but the process will still be there. If you wish to show all the processes in the system belonging to you, enter the command

ps gx

then you can kill them with the kill command if you wish.

Please remember to make sure that any suspended process be killed when you are ready to log out. This way you can be sure you will leave no processes behind which might interfere with the operation of the system by consuming valuable resources.

Once more, remember that Control-Z does not kill your process, do not use Control-Z to exit the program. It looks like it works, but it doesn't.

9. For Further Reference

For specific assistance, or you can send a mail message to: request@cis.fiu.edu.

System specifications and information can also be found on the FIU Computer Science home page at http://www.cis.fiu.edu and FIU Gopher gopher.fiu.edu

For questions or problems, please call 348-2739 or visit us at ECS 282.

A large number of books have been published about Unix. Most of them give a more detailed view than was presented in this article. The O'Reilly & Associates publishing company puts out an excellent series of books regarding many facets of unix and system networks. Take a look at your favorite bookstore's computer section.

For assistance on using the Internet, take a look at "The Whole Internet User's Guide and Catalog" by Ed Krol.