分享

Introduction to UNIX in SEAS

 weicat 2007-08-01
UR School of Engineering

Introduction to UNIX in SEAS

Introduction

UNIX is a special kind of program called an operating system. An operating system is the interface between a computer user and the computer hardware. In the School of Engineering and Applied Sciences (SEAS), a large number of computer workstations and time sharing systems which use the UNIX operating system are used for education, research and administration. This tutorial is intended to help users make effective use of those computer systems.

Most of what follows is intended to be general information which applies when using UNIX computer facilities in any department of the School of Engineering. In some cases, especially at the outset, some references are made to specific computers and resources in the Departments of Chemical, Electrical and Mechanical Engineering, and in the institute of Optics.

Conventions

Throughout this document the following conventions will be used:

Text appearing in the Helvetica Normal and Bold fonts, such as this, is instruction and narrative. Text appearing in the Courier font such as
SunOS UNIX (nova.ceas.)
represents text which the computer system prints.

Text appearing in the Courier Italic font such as
ls -a my_dir
represents text which you type at the computer keyboard.

The symbols [RETURN] and [CR] both mean that you are to press the carriage return key on your keyboard. The symbol [ESCAPE] means that you are to press the escape (Esc) key on your keyboard.

Finding Help

If there is a single most important point to be made by this document and tutorial, it‘s that help is available in the form of people and documentation. You may contact any member of the Computer and Networking Group by telephone, email, or by visiting their offices to ask questions or to discuss methods for getting work done on our computers. Additionally, user manuals are available in several locations, most notably in the computer laboratories.

Computing Resources Available in the SEAS Departments

School-wide (SEAS) Systems

The primary system within the School of Engineering is NOVA (nova.seas.). This system provides for general interactive computing for all SEAS members, for academic (course-related) work and for research work. NOVA provides substantial file service for SEAS, and is the SEAS web server at this time.

A second important SEAS system is SLEDGE. SLEDGE is a multiprocessor Sun system that is not intended for simple general computing (please don‘t read mail, news, etc. there). SLEDGE is a compute server for those large jobs that either needs lots of memory and/or will run for long periods of time (e.g., longer than about 30 minutes). Like NOVA, SLEDGE is available for all members of SEAS. SLEDGE will be retired from service before the end of 2001, as it is now quite old, and is far slower than any desktop system.

HORNET is a new member of the SEAS computing cluster. HORNET is an Intel system running Linux (a version of UNIX). Linux provides a wealth of software, and performs quite well. All member of SEAS may use HORNET; do remember it is a shared resource, and thus one should not use an unfair amount of that resource.

ESSEX is another new member of the central SEAS host cluster. ESSEX is a Sun Ultra running Solaris. It will be taking over many of Nova‘s duties, especially file and information serving.

BILBO is the final member of the central SEAS cluster. BILBO is not intended for logins or computing - it provides our Usenet news service, and is already at the edge of its computational ability to handle that load.

Now for the individual departments..

Electrical Engineering

In ECE, the machines GALAXY and NEBULA are available as a general interactive servers. These machines are well suited for reading mail, and other tasks which are not computationally intense. While NEBULA currently provides the disk space used by the majority of ECE‘s users, this will change within the next few months (early-mid 2000). GALAXY is currently running under SunOS 4.1.3. NEBULA is a new system, running Solaris 2.5.1 (SunOS 5.5.1), and is faster than GALAXY. GALAXY may be upgraded or retired sometime in 2001-2002.

ECE also provides a computing lab in CSB 527. That room contains fourteen Sun Ultra workstations running Solaris 8. This facility is available to all members of ECE, although you do need to obtain key-code access to the rooms, and courses have access priority. These systems are intended for academic coursework. They are not intended to be used as a bank of compute engines accessed remotely. They are intended to be used primarily by someone sitting at the console.

ECE also has a dedicated mail server, known as VALHALLA. VALHALLA collects and distributes mail for ECE. Users are prohibited from directly using VALHALLA, since a heavy user load could seriously disrupt email (one doesn‘t need to login to VALHALLA to read ECE email, email is available on any ECE machine). VALHALLA was upgraded in early 2001. VALHALLA is also the file and information server for ECE.

Finally, ECE has a web server, HENRY. This system is also known as WWW. Like VALAHALLA, HENRY is a service system and users are prohibited from logging in. Please remember to reference the ECE web server as ‘WWW‘ and not as ‘HENRY‘, as that service may be moved to another machine at anytime for performance or reliability reasons. HENRY is scheduled to be upgraded from a Sun LX running Solaris 2.5.1 to a Sun Ultra-1 running Solaris 8 by mid-autumn 2001.

Mechanical Engineering

In ME, the primary interactive and compute server is ISAAC, a Sun Ultra running Solaris 2.5.1.

In addition to ISAAC, ME has a server FULCRUM. FULCRUM serves as a mail and web server for ME. In addition FULCRUM provides most of the disk space for ME users. Due to the number of tasks that FULCRUM is being asked to do, users are asked to stay off of FULCRUM.

The GMLAB facility contains a number of Sun Ultra workstations; access is granted by the department for certain courses. It is not a general computing facility.

Institute of Optics

Optics provides three UNIX machines named MOE, FINE and XRAY. MOE provides mail and file service for the Institute of Optics, and is available for general computing. FINE is a new Sun Ultra running Solaris 7.0, and is substantially faster than Moe. We strongly recommend using FINE rather than MOE for most interactive computing needs. XRAY (xray.optics., also known as www.optics.) is an Intel platform running Linux 7.0, and provides web service and anonymous ftp service for Optics.

Chemical Engineering

Chemical Engineering has a departmental UNIX machine, known as OZ. OZ serves as a mail server, file server, ftp server, and web server as well as a general purpose interactive session server.

BioMedical Engineering

BioMedical Engineering (BME) is the newest department within SEAS. BME has a system, bionic.bme. which serves as their primary interative computing host. BME members are urged to transition from using Nova as their primary host to Bionic. Bionic may be used for reading email, news, general and scientific computation. It is much faster than Nova, has much more memory, and a much larger inventory of software.

Accessing the facilities

There are five main ways in which you can access the computing facilities (i.e., in which you can get to a login: prompt).

1. Direct use of a workstation in one of the Computer Labs To use the computers in the workstation labs, simply sit down at a workstation in one of the labs. The screen will appear something like the following:

SunOS UNIX (moe.optics.)
login:

The name of the computer will appear in the parentheses. Note this method is not very common anymore; most sytems have some type of graphical-user-interface (GUI) login screen.

2. Connecting from networked computers. In order to connect to one of the general interactive session computers (Bionic.bme, Galaxy.ece, Nebula.ece, Oz.che, Fine.optics, Moe.optics, Nova.seas, Isaac.me - or any appropriate UNIX host) via the campus wide area network, use a SecureShell (SSH) or RLOGIN program to connect to an appropriate host. TELNET is decprecated; it will soon be turned off on most SEAS UNIX hosts. But for historical reasons, here is an example of a telnet session:

uhura-deke 10% telnet galaxy.ece. [RETURN]
Trying 128.151.160.40 ..........
Connected to galaxy.ece.
Escape character is ‘^]‘.
SunOS UNIX (galaxy.ece.)
login:

Users of personal computers, such as Macintosh or IBM PC compatible computers, often have a telnet application. By running this application, a connection to the desired host is established and a login: prompt is displayed. It is much better if you get one of the free SecureShell client programs and use that rather than Telnet.

Many systems also provide for ‘rlogin‘ connectivity, which is a nicer connection than telnet. From another UNIX system, you would connect something like:

119% rlogin nebula.ece.
Last login: Fri Jan  9 12:07:59 from dagger.ceas.roch
Sun Microsystems Inc.   SunOS 5.5.1     Generic May 1996
University of Rochester Department of Electrical Engineering
______________________________________________________________________________
1%

SecureShell logins are similar to RLOGIN, with the added benefit that the session is encrypted. Telnet and Rlogin allow other individuals to "sniff" (read on the network as it is transmitted) your password (or any sensitive text). SecureShell protects you (and us) from that. We strongly urge all users to convert to SecureShell conenctions. For more information, see our page on SecureSHell use in SEAS.

3. Access via a dial-up network connection (PPP or SLIP). Many individuals now make use of an ISP (Internet Service Provider) to give them an internet connection at home. This method of connection is similar to ‘2‘ above. The UR does not have a preferred vendor for ISP services; you may use any reasonable ISP. Unless you are also using use of VPN software configured to work within the UR‘s VPN setup, you may not have full access. Again, see ITS (274-HELP) for details. You may also wish to look at our email restrictions that are affected by this.

In addition to those facilities physically located within the departments of the School of Engineering and Applied Sciences, Academic Technology Services (formerly the UR Computing Center) provides several terminal rooms, personal computer labs and workstation labs on the River Campus. These, too, may be used to access the computer facilities of the School of Engineering and Applied Sciences.

One brief word on how to decide when to use a workstation as opposed to a terminal. A simple terminal session can be used for many types of computing activities, including reading mail or news, editing text files, and running virtually all standard UNIX utility programs. A graphics workstation is intended for those users that run programs requiring a window system environment. Such programs would include many of the Engineering CAD programs and word processing programs.

Logging In and Out

To log in to UNIX computers there are three things that you need to know: user name, password, and terminal-type.

USER NAME: This is your individual identification for the systems. This is most often your last name or a variation of it. All user names are lower case, as are almost all UNIX commands.

PASSWORD: Your password is a secret set of characters that you must type in order to gain access to the computer. You should NEVER give out your password to anyone, including the systems administrator.

TERMINAL-TYPE: The terminal type is name or designator for the type of terminal you are using. If you are using a terminal emulator computer program, like Versaterm or Kermit, check with the documentation on the program to determine the terminal emulation being used. In many cases, this setting is automatically determined by the host computer at login time - but not always.

The following example shows a sample login session which makes use of this information:

SunOS UNIX (oz.che.)
login: kaser [RETURN]
Password: MY_PASSWORD [RETURN]
Last login: Thu Sep 19 14:17:58 from mac1
SunOS Release 4.1.3 (GENERIC) #1:Tue Mar 6 17:27:17 PST 1994
University of Rochester Department of Chemical Engineering
_______________________________________________________
Please contact a member of the systems staff if you have
questions or need  assistance (send mail to "problem").
You are logged onto oz.che.
On NIS domain URCHE, mail domain CHE.Rochester.EDU
_______________________________________________________
You have new mail.
TERM = (vt100) [RETURN]
oz-kaser 1%

Your password will not be displayed on the screen when you type it, so as to make sure that other users do not see it.

The message that is given after you log in is called the MOTD or Message Of The Day. You should read this message every time you log in. The system staff uses the MOTD to keep users informed on important items like scheduled computer down time or temporarily unavailable services.

In the example, "oz-kaser 1%" is what is called your prompt. Your user name will be displayed in place of kaser. The cursor is the point at which the next character typed will be placed. This is usually denoted by a block that may or may not be flashing.

The next thing you need to know is how to log out of the computer. This is done by typing the word logout at a prompt, followed by [RETURN]. This ends your session on the computer.

oz-kaser 1% logout [RETURN]
Logged off Tue Sep 24 10:43:02 EDT 1994

This takes care of the basics of logging into and out of a UNIX computer.

We do recommend an alternative method of logging into most of our systems. Most (but not all) UNIX systems in SEAS now provide Secure Shell service - this is a secure connection method, that provides an encrypted tunnel for your communications. Secure shell connections can be obtained by using the ‘slogin‘ command rather than the ‘rlogin‘ command (e.g.

slogin hornet.seas.

Secure shell clients are available for Windows (Win95/98/ME/NT/2K/XP) systems. We recommend one named ‘Putty‘. We are researching Secure Shell clients for MacOS. If you travel with a laptop, and need to connect to systems at the UR, or work from home, we strongly recommend the use of secure shell connections.

The UNIX File System

Each user of a UNIX computer system has a "home directory", which is a portion of the shared system disk in which that user can store files. In order to make effective use of your home directory, it is helpful to understand the basics of the UNIX file system layout.

For those familiar with the Macintosh, think of a UNIX directory as a folder on a Macintosh disk. Within that Macintosh folder there may be more folders, applications and documents. A UNIX directory, such as your home directory, is similar. It contains files, some of which may be programs or text files or even other directories. The following diagram represents a UNIX directory and a few files.

                              root
_______________|____________________
|         |         |               |
unix       etc       home            bin
__________|     _____|_____       __|_____
|        |     |          |      |      |
passwd    motd  kaser       deke   ls    diff
_______|__       __|_____
|        |       |      |
mbox      bin    mbox    prog.c

In this way, a UNIX directory is like an upside down tree. The "root" of the tree is at the top, and the branches of the tree extend downward. Every named point on the tree is a "file", but those files which can contain other files are "directories". In this example, the following are directories: etc, home, bin, deke, and kaser. The "root" is a directory too. The files "unix", "motd", "passwd", and "mbox" are not directories, because they are not able to contain other files.

The directories "deke" and "kaser" in this example are the home directories for the users of the same name. Note that within these home directories, the users "deke" and "kaser" have stored some files and directories.

Files: Names, ownership and permissions

Every file has a set of characteristics which include, among other things, its name, its ownership and the access permissions granted to individuals or groups of users.

A file on a UNIX system may be named with a string of alphabetic and numeric characters. Any mixture of upper and lower case is allowed. Characters not allowed in a file name, or which should for other reasons be avoided, include the [SPACE] character, and the following punctuation characters:

# | = ^ ( ) ; : & < > * ? [ ] $ ‘ ` /~

Within a directory, no two files may have the exact same name.

Every file has an owner. In most cases, the owner is the user that created the file. The file also has an associated group, which identifies a group of users that may have some special access privileges to the file.

The permissions which are associated with a file grant read, write, and execute permission to the user (the owner), group and to others.

The permissions are represented as a string of characters, such as

	drwxrwxrwx

If the first character is a "d", the file is a directory, and if the first character is a "-", then it is a plain file. the next 9 characters are the permissions. The first "rwx" grants read, write, and execute permissions to the user. The second three grant permissions to the group, and the third to other users.

	   -rwx     rwx     rwx
^^^     ^^^     ^^^
|       |      |_______ permissions for other users
|       |
|       |_______ permissions for the group
|
|_______permissions for the user (the owner)

Some examples:

drwxrwxrwx   a directory which is readable and writeable to all users
-rw-rw-rw-   a file which can be read and written by all users.
-rwxrwxrwx   a file which can be read, written and executed by all users.
-rwxr-xr-x   a file which can be read, and executed by all users, but
written (modified) only by the owner.
-rwx------   a file which can be read, written and executed only by the owner.
-rw-rw----   a file which can be read and written by the owner and members of
the group.

Look back to the previous diagram representing a UNIX directory and a few files.

When the user "kaser" logs in, he starts out in his "home directory", which is also called "kaser". The "pwd" (Print Working Directory) command shows this.

galaxy-kaser 1% pwd [RETURN]
/home/systaff/kaser

Note that the full name (also called the absolute path name) of the home directory of user kaser is /home/systaff/kaser. This says that the directory "kaser" is within the directory "systaff", which is within the directory "home", which is below the root directory (called "/"). The mbox file within this directory, for example, has an absolute path name of /home/systaff/kaser/mbox.

The "ls" command lists files. The "-l" option causes the list to include additional information, such as ownership, permissions, size and the date and time of the last modification.

curly-kaser 2% ls [RETURN]
mbox	bin/
curly-kaser 3% ls -l [RETURN]
-rwx------ 1 kaser		1536 Oct  9 11:30 mbox
drwxr-xr-x 2 kaser		 512 Oct  8 14:23 bin/

These commands and others will be discussed in the next section.

Note: is is very important that you store research project related material in directories/disks provided by that project, and not in your home directory.

Basic UNIX Commands

The basic commands are those that you absolutely need to know in order to work within the UNIX environment. Commands are program names, like man, cat, mail, or ls. Arguments are additional things typed after a command that the program will use to affect its behavior. Command options are among the possible arguments.

galaxy-kaser 1%  ls -l my_dir [RETURN]
In this case, ls is the command and -l my_dir are arguments.

A description of some of the basic commands, with examples, follows:

ls - list the contents of a directory

Useful options are -a and -l. The -a option lists all files in a directory including the "dot" or "hidden" files. The -l option lists a directory in long form, showing permissions, number of links, owner, size in bytes, and time of last modification for each file.

augustus-kaser 40% ls [RETURN]
Archives        get.ftp*
augustus-kaser 41% ls -a [RETURN]
./        .ftp      Archives     get.ftp*
../       .test
augustus-kaser 42% ls -l [RETURN]
total 31
-rw-r--r--  1 kaser       20669 Dec 12  1990 Archives
-rwxr-xr-x  1 kaser        4207 Jun 22  1990 get.ftp*
augustus-kaser 43% ls -la [RETURN]
total 35
drwxr-xr-x  2 kaser         512 Sep 24 15:39 ./
drwxr-xr-x 37 kaser        2560 Sep 24 15:11 ../
-rw-r--r--  1 kaser           0 Sep 24 15:39 .ftp
-rw-r--r--  1 kaser           0 Sep 24 15:39 .test
-rw-r--r--  1 kaser       20669 Dec 12  1990 Archives
-rwxr-xr-x  1 kaser        4207 Jun 22  1990 get.ftp*
augustus-kaser 44%

passwd - change password information.

The passwd program allows users to set their login password. When changing a password, passwd prompts for the old password and then for the new one. You must supply both, and the new password must be typed twice to forestall mistakes. This can only be done on a departmental machine and not one of the School machines.

gauss-deke 21% passwd [RETURN]
Changing NIS password for deke on valhalla.
Old password:(type your old password) [RETURN]
New password:(type your new password) [RETURN]
Retype new password:(retype your new password) [RETURN]
NIS entry changed on valhalla.
gauss-deke 22%

man - display the reference manual page.

All user commands have manual pages that can be read on-line using the program man. One useful argument to man is the "-k" option. This option gives a list of commands or descriptions that match the keyword.

galaxy-kaser 2% man -k ref [RETURN]
bib, listrefs (1)  - bibliographic formatter
man (1) - display reference manual pages
galaxy-kaser 3% man ls [RETURN]
LS(1)				USER COMMANDS			LS(1)
NAME
ls - list the contents of a directory
SYNOPSIS
ls [ -aAcCdfFgilLqrRstu1 ] filename ...
DESCRIPTION
For each filename which is a directory, ls lists the
contents of the directory; for each filename which is a
file, ls repeats its name and any other information
requested. By default the output is sorted
alphabetically.  When no argument is given, the current
directory is  ....

pwd - print the current working directory

This command is used to determine your location in the file system.

oz-kaser 44% pwd [RETURN]
/home/systaff/kaser
oz-kaser 45%

cat - display the contents of a file

Cat displays the contents of a file on the screen without any breaks for screen size. It is a good way to display short files.

more - browse or page through a text file

More is another way to display the contents of a file on the screen. More will give you one screen‘s worth of information at a time. This is very useful for looking through long files. More scrolls up to display one more line in response to a [RETURN] - it displays another screenful in response to a [SPACE].

Additional Commands

Once some files have been created, some additional commands can be used to remove, rename, or make a copy of a file.

To move or rename a file, use the move command, mv. To copy a file you can use the copy command, cp. The rm command can be used to remove or delete a file.

moe-kaser 1% ls [RETURN]
commands1	login		printing
moe-kaser 2% cp printing printing.new [RETURN]
moe-kaser 3% ls [RETURN]
commands1	login		printing	printing.new
moe-kaser 4% mv printing.new example [RETURN]
moe-kaser 5% ls [RETURN]
commands1	example		login		printing
moe-kaser 6% rm example [RETURN]
rm: remove example? y [RETURN]
moe-kaser 7% ls [RETURN]
commands1	login		printing
moe-kaser 8%

These commands will help in the organization of your files.

Remembering the UNIX file structure that was discussed earlier, we can make directories or folders so that the organization of files is easily remembered. To create a directory use the command mkdir dir-name. Once you have created a directory you can move files into it. To remove an empty directory you can use the command rmdir dir-name.

Once you have created a new directory, you may want to change directories to make that sub directory your current working directory. To do this use the

	cd dir-name 
command. These command will be illustrated in the next example.
fulcrum-kaser 1% ls [RETURN]
commands1	login		printing
fulcrum-kaser 2% mkdir intro [RETURN]
fulcrum-kaser 3% ls [RETURN]
commands1	intro/		login		printing
fulcrum-kaser 4% mv login intro [RETURN]
fulcrum-kaser 5% ls [RETURN]
commands1	intro/		printing
fulcrum-kaser 6% cd intro [RETURN]
fulcrum-kaser 7% ls [RETURN]
login
fulcrum-kaser 8% rm login [RETURN]
rm: remove login? y [RETURN]
fulcrum-kaser 9% cd .. [RETURN]
fulcrum-kaser 10% ls [RETURN]
commands1	intro/		printing
fulcrum-kaser 11% rmdir intro [RETURN]
fulcrum-kaser 12% ls [RETURN]
commands1	printing
fulcrum-kaser 13%

Note the "/" after the listing in #3. This designates a directory so you can easily distinguish between files and directories. In #9 you will notice the command

cd .. The ".." refers to the directory immediately above the current directory in the directory tree.

Mail

Another widely used command is mail, the interface to the electronic mail system. As this topic is discussed in detail in the Email tutorial, it will be handled here in a very brief way.

To send mail, you‘ll first need to know the recipients email address. Within a department, or on a given computer, this is simply the user name or login name. To find out the user name for someone using their real name, use the command finger.

bilbo-kaser 1% finger kassabian [RETURN]
Login name: deke      In real life: Dikran Kassabian
Directory: /home/systaff/deke       	Shell:
/bin/csh
Last login Thu Aug 22 15:16 on ttyp0 from harn
Mail last read Thu Sep 26 15:14:08 1991
bilbo-kaser 2%

Once you know this information you are ready to send mail to that person using the mail command, as shown in the following example.

bilbo-kaser 1%  mail deke [RETURN]
Subject: test mailing.[RETURN]
This is an example of sending mail to someone with the
user name of deke.  What you type on the screen is exactly
what the user deke will receive so remember to type
[RETURN] when you get to the end of a line.  Once the body
of the letter is complete you can end the mail message by
typing "." on a line all by itself.
-Bob Kaser
.
Cc: kaser [RETURN]
bilbo-kaser 2%

The Cc: line allows for a carbon copy to be sent to another user or to yourself. Just type the user name and then return. If more than one user is to get a carbon copy, separate the user names with a ",".

The mail command with no arguments allows for reading mail, as shown in the following example. Type the number of the message you want to read and then [RETURN]. This will display the message on the screen for you to read.

theseas-kaser 1% mail [RETURN]
Mail User‘s Shell (7.2.3 5/22/91): Type ‘?‘ for help.
"/var/spool/mail/kaser": 2 messages, 0 new, 2 unread
>1  U  Bob Kaser  1 [RETURN]
Message #1
From: Bob Kaser 
Date: Thu, 26 Sep 91 15:30:48 EDT
To: deke@ceas.
Subject: test mailing.
Cc: kaser@ceas.
This is an example of sending mail to someone with the
user name of deke.  What you type on the screen is exactly
what the user deke will receive so remember to type
[RETURN] when you get to the end of a line.  Once the body
of the letter is complete you can end the mail message by
typing "." on a line all by itself.
-Bob Kaser
MAIL-Msg 1 of 2> q [RETURN]
Updating "/usr/spool/mail/kaser": saved 2 messages
theseas-kaser 3%

When you "quit" from mail, all undeleted mail will remain in your system mailbox.

This gives you the basics of the command mail. To obtain more information on this command, please see the tutorial notes on Electronic Mail.

Printing

Printing files from a UNIX computer is done by issuing the lpr command. This will print your file to the default printer.

To find out what printers are available from the computer you are logged in to, you can issue the command printers.

galaxy-kaser 1% printers [RETURN]
csb-527 (Default printer)
hpn-416
csb-office
hpn-office
galaxy-kaser 2%
galaxy-kaser 2% lpr file [RETURN]

Prints to the default printer. To print to a printer other than the default, use lpr -Pprinter

galaxy-kaser 2% lpr -Phpn-416 file [RETURN]

Prints the printer named hpn-416.

You can expect the printed copy in a few minutes if the printer is not already busy printing other files.

To find out the status of your print request you can use the command lpq. The lpq commands tells you how many files are waiting in the print queue. Again to examine the queue of a printer that is not the default use lpq -Pprinter.

galaxy-kaser 2% lpq [RETURN]
csb-527 is ready and printing
Rank   Owner  Job  File	        Total Size
active kaser  17   /etc/printcap  1825 bytes
galaxy-kaser 3%

Printing should be done for final copies of files and not for proofing. If you printed a file and then realize that it was not the file you wanted to print use the lprm command to remove the print job from the queue.

galaxy-kaser 3% lprm 17 [RETURN]
kirchoff.ece.: dfA017bilbo dequeued
kirchoff.ece.: cfA017bilbo dequeued
galaxy-kaser 4%

The above message from the machine that the printer is connected to shows that the print job has been terminated. You can also use the same option when removing a print job from a printer that is not the default.

galaxy-kaser 4% lprm -Phpn-416 23 [RETURN]
volt.ece.:dfA023bilbo dequeued
volt.ece.:cfA023bilbo dequeued
galaxy-kaser 5%

Creating Files: The VI Editor

Files on a UNIX system are created in a variety of ways. Some files, such as your mbox, are created by a program that you run. Other times, you may wish to create a text file on your own, either from scratch or by modifying some existing file. In these cases, a text editor is called for. Vi is one of several available text editors, and will be discussed here briefly. For a more complete discussion of text editors, word processors and document formatting software, please see the tutorial on Editors and Formatters.

The vi editor operates in two basic modes: the text insertion mode (in which you type the characters you want to include in your file), and the command mode (in which you operate upon the text, by moving or deleting text).

When first started, the vi editor is in command mode. To enter the insert mode in order to begin typing your text, press the i key. At this point, anything you type will appear on the screen just as if you were using a typewriter. At the end of each line, just as on a typewriter, you should press the [RETURN] key. When you are through typing and want to return to command mode, press the [ESCAPE] key.

Once in command mode, the arrow keys on your keyboard can be used to move around the body of the text. If your keyboard does not have arrows, the following keys can be used to move the cursor:

	h	- move back one space
j	- move down one line
k	- move up one line
l	- move forward one space

Some other operations available in command mode:

	x	- delete the character beneath the cursor
dd	- delete the current line of text (and put it into a buffer)
dw	- delete from the cursor to the end of the word
yy	- "yank" the current line into a buffer
p	- place the content of the buffer into the file at the
current cursor location.

To return to text insertion mode from command mode:

	i	- begin inserting text at the cursor location
a	- begin appending text at the position following
the cursor
A	- begin appending text at the end of the line
o	- open a line beneath the current line for text insertion.
O	- open a line above the current line for text insertion.

To return to command mode after any of these insert commands, press the [ESCAPE] key again. When you aren‘t sure of the current mode (command or insert), press the [ESCAPE] key to make certain that you are in the command mode.

When in command mode, some of the commands used to write the file to the disk are:

	:w	- write the file to disk
:q	- quit the editing session
:q!	- quit the editing session without updating the file
:wq	- write the file and quit

For more information on Vi, see the Vi section of the Editors and Formatters Tutorial, where you can also a more complete discussion of text editors, word processors and document formatting software, in general


For more advanced discussion of Unix, proceed to the Intermediate Unix Tutorial.


Prepared by John Simonson, Bob Kaser and Deke Kassabian

Last modifed: Friday, 18-Aug-2006 11:22:34 EDT

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多