Computer Labs


Introduction to UNIX

This tutorial contains step-by-step instructions for using the UNIX Operating System on University of Texas at Dallas (UTD) UNIX Servers, such as apache and infoserv. This document assumes basic computer knowledge. Throughout this document, the terms “host” and “server” will be used interchangeably, because they both mean essentially the machine that you connect to and execute or manipulate files on. The University servers are designed to be very structured and well supported UNIX systems.

This is a lengthy document. To facilitate ease of movement, the following links are provided to each major section:

Logging in, Changing your password, and Logging out
Executing UNIX commands
Directory and file commands
Printer commands
Editing commands
Electronic Mail

In addition, each major section includes a top link, which returns the reader to this table of contents.

Because each of the servers has a different purpose, different applications are available on each server. Some of the major servers and the applications/languages available on each include:

apache   FORTRAN
  C/C++
  Pascal
  FrameMaker
  MATLAB
  Netscape
  SAS (You may refer to Using SAS under UNIX for more complete information on the SAS system.)
razor testing (or beta) applications

For a complete command list, see UNIX Commands .

Logging In, Changing Your Password, and Logging Out

You may access a UNIX server from a PC through the UTDNet menu on or off campus by:

• selecting the menu option for the desired server, such as “ APACHE (Applications Server) ”

• telnet to the server from another UNIX host by typing, for example, telnet apache when you are already logged into another machine, such as inca. Remember that although you are logging in to apache you remain logged in to inca; therefore, to completely log out, first log out of apache and then inca (in this example).

• by entering (for example) apache from a WYSE terminal, or by directly entering your username and password on a SUN work station or NCD Terminal at the machine login prompt. For more information on dialing in from off-campus, see TCS's Communicating with the UTD Computer System from Off Campus. For more information on connecting to UNIX Servers on-campus, see Using the Campus Ethernet and the UTDNet Menu Software.

You must have a user account, including a user (or login) name and password, set up on the UNIX platform before you can login. To get a faculty sponsored UNIX account, fill out the Academic Computer Account Request Form and request UNIX on it. For an On-demand instructional UNIX account, or to obtain an Account Request Form, see the computer assistants (CAs) in the Jonsson Computing Center (UNIX lab) or McDermott Microcomputer Center. Please allow at least 24 hours from the time you have turned in the account request form until the account becomes active.

UNIX is case sensitive; that is, it knows the difference between upper and lower case letters. (Most commands and system directories are in lower case. User names are also in lower case; therefore, you should not login with upper case letters. Be sure to enter your username and initial password exactly as it is printed by the Account Management System, on the sheet you received for the UNIX platform. Also remember that you are held accountable for any activities done under your account, and it is therefore quite important to keep your password private.

Logging In

After connecting to a UNIX host by one of the ways mentioned above, enter your username (case is significant!) at the login prompt; e.g., suppose your username is jsmith. You would enter:

login: jsmith

You will now be prompted for your password as shown:

password:

Type your password (again, pay attention to case) at the password prompt and press Enter. Your password will not appear as you type it; i.e., your password is not echoed to the screen. Some messages similar to these will be displayed on your screen:

Last login: Tue Oct 8 08:43:12 from apache.utdall

You will receive a BASH shell prompt such as {apache:~} and you are now ready to begin working.


Changing Your Password

You will want to change your password to one that you will remember, but that another person would not be able to guess. You change your password with the nispasswd command. Changing your password here will only change your password on the UNIX platform . First, type in the command:

{apache:~} nispasswd

You will be prompted to enter your old password once and your new password twice as follows:

Enter login(NIS+)password:

Password must contain at least two alphabetic characters and at least one numeric or special character.

Enter new password:
Re-enter new password:
NIS+ password information changed for jdoe
NIS+ credential information changed for jdoe

Should you forget your password, see the computer assistant (CA) in the Jonsson Computing Center to get a new one. Please allow 24 hours for your account to become active.

Logging Out

To leave UNIX when you are logged in to a WYSE terminal or from Dialup, enter the log out command:

{apache:~} log out

Alternatively, you may press Control-d (to disconnect). Please make sure you are totally logged out before leaving the terminal. You can recognize this when you again have the same prompt that was displayed before you logged in.

If you are running X-Windows, such as from an NCD term in Jonsson lab, you must depress the “setup” button on the upper-right corner of your keyboard. Click on the “Login” menu in the “Console Window” that appears and select the “Log out” option. Re-affirm the log out when prompted, and wait until the “Login Chooser” menu is displayed. Remember, simply closing all your xterm windows may not log you out.

top

Executing UNIX Commands

Help on UNIX

To obtain complete on-line information on UNIX commands, use the man command to display manual pages. Type man followed by the command you need help on. For example, if you need help on the compiler gcc, enter:

{apache:~} man gcc

If you are not sure of the command, you may enter the man -k subject command, where subject is replaced by the topic you want to search for help on. It will list the headings of commands that are related to the subject. For example, to view a list of commands related to the topic ‘directory:’

  {apache:~} man -k directory
cd (1)   - change working directory
chdir (2) - change current working directory
chdir (3F) - change working directory
chroot (2) - change root directory
ls (1) - list contents of a directory
mkdir (1) - make a directory
mkdir (2) - make a directory file
pwd (1) - working directory name

You could then use man to get more information about whichever command seems most relevant. The number in parentheses is the manual section. The UNIX manuals are divided into 9 major sections:

  1. System Maintenance Commands   6. Computer Demonstrations
2. System Calls 7. Devices and Network Interfaces
3. C Library Functions 8. Administration Commands
4. File Formats 9. Device Drivers
5. Headers, Tables, and Macros  

In many cases, the same topic will be in multiple sections (e.g. mkdir in the above example). By default, the man command displays the first section it finds the topic in. To override this, you can type man -s# topic for a particular section.

{apache:~} man -s2 mkdir

man calls a command known as more to display the manual page.
Use the following keys to control the scrolling capabilities while using more:

  Spacebar   scroll forward one screen at-a-time.
Return scroll forward one line at-a-time.
b move back one screen.
q quit man pages.
/string search forward for that character string.

You will often need to use certain keyboard keys such as the Back Space key. Depending upon the terminal type you are using, the key actually labeled Back Space may not work. First, try the Delete key, then Back Space, and finally Control-H (or Ctrl-H).
Certain control characters are used to perform such tasks as correcting mistakes with command line input and stopping/starting screen output. The control characters are entered by holding down the Control key and pressing one other keyboard key. The Control key is displayed on your screen as the caret (^) symbol.

Key   Function
Control-W Erases the last word altered on the command line.
Control-U Erases everything entered on the command line.
Control-C Interrupts execution of current command.
Control-S Stops screen output.
Control-Q Starts screen output.
Control-D End-of-file.
Control-Z Suspend command (advanced users only).
Up Arrow Recall Previous Command (scroll backward).
Down Arrow Recall Previous Command (scroll forward).

Note: If you find your terminal “frozen” pressing Control-Q can unlock it.

top

Directory and File Commands

Listing Available Files

Use the ls command to list the files in a directory. For example:

  {apache:~} ls
Mail cakewalk.cls public_html
News dead.letter  

Use the -a option to list all files (includes your dot files such as .bash_profile, which you usually won’t care to see):

  {apache:~} ls -a
. .bash_profile .xsession
.. .localhosts Mail

Use the -l option to display a long listing of files and directories, which includes permissions, hard link count, file ownership, file size in bytes, modification date and time, and file or directory name:

  {apache:~} ls -l
drwxr-xr-x 2 jsmith sn 512 May 17 11:26 Mail

You may put all the options, or “switches,” together for a complete listing of all files. Because this list will scroll faster than is readable, you may pipe (“|”) it through the more command, as such:

  {apache:~} ls -la | more

Note: This command has actually already been programmed into your environment as the shortcut, or “alias,” dir. This means that anytime that you type dir, the command ls -la|more will be executed instead. To see which other aliases we’ve provided you with, type alias at the command line. For information on how to make your own aliases, which you can insert into your own .bashrc or .cshrc file to have them load automatically each time you log in, view the man page on alias.

Directory Commands

To display the name of your current directory, use the pwd command (print working directory). For example:

{apache:~} pwd
/home/zen/jsmith

You may also have noticed that your prompt tells you which server you are logged into. To the right of the host name, your current directory is also displayed. In the example above the user is in his home directory, which is denoted by the tilde ~, or ~jsmith. To change your current directory to a new directory, use the cd directory_name (change directory) command. If you do not specify the directory name, you will be placed in your home directory. cd .. will take you up one level in the directory structure.

To create a new directory, you may use the mkdir command (make directory).

mkdir test

You can then use the ls command to see that the new directory is there. To remove a directory, you must first make sure that you delete all the files in that directory, including “dot files” and then use the rmdir command (remove directory) For example:

rmdir test

Disk Space

To find out how much disk space you are allotted, use the quota command:

  {apache:~} quota -v
Disk quotas for jsmith (uid 12345):
Filesystem usage quota limit timeleft files quota limit
/home/zen 5698 10000 15000   153 25000 50000

This shows you which directory contains your home directory, how many 100 kilobytes you are using, how many you are allotted( ie: your “quota”), and what the absolute limit is. You may use the command du to see a listing of your disk usage by directory. Keeping your disk usage below your quota will ensure that you avoid any penalties for excessive disk-space usage.

File Commands

The more command will display files to your screen. More information about using it can be found in the man command section above.

more .bash_profile

The cp command (like MS-DOS COPY) copies a file. You first specify the name of the file you want to copy and then the name of the file to be the copy. The following cp command copies the contents of the file payroll.tst to a file called payroll.old.

cp payroll.tst payroll.old

The mv command (like MS-DOS rename) changes the name of a file, or moves it to a new location.

mv output.dat results1

The rm command (like MS-DOS DEL) removes files.

rm a.out

The chmod command allows you to change access rights, “permissions,” for the user (i.e.: you), members of your group (i.e.: other CS students), and all other users to access your files and directories. You control their permissions to read, write, and execute. The syntax is then : chmod ugo+/-rwx filename where you may use any combination of u, g, or o, either + or -, and any combination of r, w, or x, to respectively add or subtract the indicated permissions from the users that you specified. For example, if you create a public_html directory to have your own web page, you will need to give other users access to read from that directory and change to that directory, but you will probably want to disallow others from writing to that directory:

  {apache:~} chmod go+rx public_html
{apache:~} chmod go-w public_html
{apache:~} ls -l
drwxr-xr-x 2 jsmith sn   512 Sep 27 20:31 public_html/

From this line of the directory listing you can see first that this is a directory, second that the read, write and execute permissions are enabled for the user, and third that group users then other users each have read and execute permissions, but no write permission. Generally you want to disallow other users to write to your files.

top

Printer Commands

Printing is done by the lp command. The general syntax is lp -d printer_name filename. The only available printer is ljacc (for the laser printer in the Jonsson UNIX Lab). For example:

lp -d ljacc textfile.1

Note: The line printer can only print pure text files-- Not postscript or graphics. For great preprogrammed printing options, such as double-sided printing, look at any of the options listed on the first page of a print-out. You may also use the genscript filename command for fancy printing. To print on your locally-attached PC printer, use the special UTD-developed command: printpc filename and then, as instructed on the screen, press Alt-W. To see the status of your print jobs, use

lpq -Pprinter_name or lpstat printer_name

top

Editing Commands

The UNIX servers have three editors available. They are:

pico   This is a very easy to use and simple editor that is recommended for beginning users. Pico is documented in the TCS publication Using the Pico Editor under UNIX. Pico can be run by typing pico filename.
emacs Emacs is an extremely powerful editor that is recommended for advanced users. Emacs can be run by typing emacs filename. To exit Emacs, press Ctrl-X Ctrl-C.
vi vi is the standard UNIX editor. It is not recommended because it is hard to learn and not as powerful as Emacs. vi is documented in the TCS publication Getting Started with VI. vi can be run by typing vi filename. You may exit by entering Esc :q!.

top

Electronic Mail

Electronic Mail can be sent by either the Pine or Elm programs. Pine is the recommended package and can be invoked by typing pine. It is very simple to use, but if you need more information, see the TCS's Electronic Mail on the UNIX System. Elm is for more advanced users and can be run by typing elm.

top