Вы находитесь на странице: 1из 18

INTRODUCTION TO UNIX, VI, AND MAIL The Rockefeller University Information Technology

Last Revision: 05/31/05


Intro To Unix 1 RU-IT

Table of Contents
INTRODUCTION TO UNIX, VI, AND MAIL................................................................. 3 1. Getting Started ............................................................................................................ 3 2. Which computer should I use?.................................................................................... 3 3. Opening An Account .................................................................................................. 3 4. Logging in................................................................................................................... 4 a. Identifying your terminal ........................................................................................ 4 b. prompt ..................................................................................................................... 5 5. Logging out................................................................................................................. 5 6. Unix commands .......................................................................................................... 6 7. Files and directories .................................................................................................... 6 a. Directory Commands .............................................................................................. 7 b. File commands ........................................................................................................ 7 8. Using the Vi Editor ..................................................................................................... 9 a. Starting the editor.................................................................................................... 9 b. Moving around in a file........................................................................................... 9 c. Inserting text............................................................................................................ 9 d. Changing and deleting text ................................................................................... 10 e. Writing (saving) and quitting vi............................................................................ 10 9. Redirection................................................................................................................ 11 10. Printing Commands ................................................................................................ 11 11. Electronic Mail........................................................................................................ 12 a. Phonebook............................................................................................................. 13 Summary ........................................................................................................................... 14 Which Machine? ........................................................................................................... 14 Logging in..................................................................................................................... 14 Logging out................................................................................................................... 14 Directory Commands .................................................................................................... 14 File Commands ............................................................................................................. 15 Editing Commands........................................................................................................ 15 moving around in a file ............................................................................................. 15 inserting text.............................................................................................................. 16 changing and deleting text ........................................................................................ 16 writing (saving) and quitting vi................................................................................. 17 Redirection.................................................................................................................... 17 Printing Commands ...................................................................................................... 17 Formatting and cleaning sequence files........................................................................ 18

Intro To Unix 1

RU-IT

INTRODUCTION TO UNIX, VI, AND MAIL


In this document, UNIX commands are in courier bold; courier italics is used to indicate that a substitution is necessary. A carriage return (the Return or Enter key) follows each command. UNIX command ARE case sensitive.

1. Getting Started
There are three steps to logging in to the computer: selecting which computer to use, correctly entering your login name and password, and correctly identifying the type of terminal being used Simply Telnet to the appropriate computer, for example: telnet science.rockefeller.edu Note: You must have an account on the Science server to be able to log in.

2. Which computer should I use?


Science Rockys DNA sequencing software (GCG etc.) Statistical analysis software (BLSS, SAS, BMDP,SPLUS,SPSS) Molecular Modeling programs

3. Opening An Account
Applications for a RU IT account can be printed from the WEB; point your browser to http://it.rockefeller.edu/index.php?page=accounts and select the form you wish. When applying for a UNIX account, it is important to specify which type. The options are: Administrative E-mail Account (E-mail Only) - Limited to Mail machine. Research E-mail Account (Regular) - Includes access to Mail and Science. If you wish to use Rockys, specify Research E-mail Account with Modeling Access on the form.

Intro To Unix 1

RU-IT

4. Logging in
Your login name and initial password are assigned to you by Information Technology (IT) when you open an account. The login name is usually part of your last name and the password will be a random combination of letters and numbers. As soon as you receive your account, you should change your password. Contact the Call Center if you have any question about changing your password. After selecting the computer you wish to use, you will be prompted to fill in your login name which is followed by a return. You are then prompted for your password, also followed by a return. For security, the password is not displayed on the screen. NOTE: You cannot use the backspace key during the login process to correct mistakes. If you have made a mistake in typing you login or password, the message login incorrect appears. You will be re-prompted. Remember to repeat the process starting with your login name, not your password. If you have been successful in connecting, you will see a message giving you information about your last login with the date and time. This will look something like:
Last login: Fri Aug 30 19:25:01 Welcome Message........ TERM = (vt102)

a. Identifying your terminal


The computer you have chosen must be able to communicate with the terminal you are using. In the vast majority of cases, the terminal type will be vt102, and we have made that the default (as shown above). If you are using a terminal which is not the one identified in the TERM = prompt, supply the correct terminal code by typing it in and pressing the return. Common terminals on campus are: vt102 personal computers (IBM, IBM clones, Macintoshs) connecting via telnet sun Sun Workstations If you make a mistake while entering the terminal type, you will get the message, Unknown terminal and be reprompted to type it in again. If you did not check or change your terminal identification, log out and log in again.

Intro To Unix 1

RU-IT

b. prompt
Next you will see messages like:
Erase is set to Backspace Kill is Ctrl-U

These messages indicate that the backspace key will erase characters and the key combination CTRL-u will erase an entire line. These keys will not work correctly while you are entering your login name and password. Other system messages may or may not follow. Finally you will see a prompt on an empty line. The prompt will show which computer you are using and display a number in parenthesis. For example: science(1) The prompt indicates that you are fully logged in and the computer is ready to do your bidding, given in the form of Unix commands. The number in parenthesis is a count of how many commands you have given during your login session.

5. Logging out
When you are finished working, make sure you log out - disconnect from the computer you have been using. To do this, type: logout or use the keys, control-d (hold down the control key and type a lower case d). NOTE: Make sure you logout completely before terminating telnet program or shutting down your Mac or PC.

Intro To Unix 1

RU-IT

6. Unix commands
Communicating your wishes to the computer under Unix requires the use of Unix commands. In the simplest case, it may only be necessary to enter the name of the command to get the computer to function for you. However, in most cases you will need o type in the name of the command, plus a few other things. An extremely useful command is the man command, which prints on-line manual pages for other Unix commands on your screen. To use it, type in man plus the name of he command you wish to learn about. For example, entering man ls will bring up the manual page for the ls command. Unix commands may also be modified by including flags on the command line. The table below (see 7a Directory Commands) shows 3 different models of the ls command, two with flags. These flags, and all others pertinent to the ls command, are explained on the on-line manual page.

7. Files and directories


The UNIX system is organized into files and directories. These can be compared to files and folders on a PC, or even the files and folders found in an old fashioned file cabinet. Files may contain text which we can read, or binary code, which we cannot read but can run as programs under Unix. Directories may contain files (text or binary), or other directories (call subdirectories). Upon login, you are automatically placed in your home directory. This is a directory created specifically for you. It is yours to work in, as well as create files and subdirectories of your own. Unix provides specialized commands for creating, viewing and otherwise manipulating files and directories. These are listed below.

Intro To Unix 1

RU-IT

a. Directory Commands
When you log in to any Unix-run computer, you automatically placed in your home directory. This is a directory created specifically for you, as part of your account. You may begin working there or you may create a sub-directory in which to work. A directory may be created, removed, and may have its contents listed. You can change from one directory to another and find the pathname (full name) of any directory. Below is a table of directory-related commands. ls ls l ls F mkdir name rmdir name rmdir cd name list; lists the contents of a directory. long listing of everything in the current directory; gives information about permissions, ownership, date, and size. will put a slash (/) after every directory make directory; creates a directory with the name you supply. removes the name directory if it is empty. The command must be given from the directory (the parent directory) where the sub-directory was created. The directory must be empty before it can be removed. change directory; moves to the directory named after the command. Without giving the name of a directory to change to, cd always takes you to your home directory. cd .. will move up one level. present working directory; displays the full pathname of the directory you are currently in.

pwd

b. File commands
more name look at the contents of a file one page at a time. To move to the next page, use the space bar. Two commands within more are: q quit; returns your prompt b back; go back one page cp name newname copy; make a duplicate of a file leaving the original file untouched. cp name directory puts a copy of a file in a sub-directory (this directory must already exist). The name of the new file is identical to the original.

Intro To Unix 1

RU-IT

mv name newname renames a file mv name directory rm name grep string name(s) Search for a string in one or more files moves a file from one directory to a sub-directory (this sub-directory must already exist). remove; deletes a file. You will be asked to confirm the deletion with a y (yes)

Intro To Unix 1

RU-IT

8. Using the Vi Editor


The vi (visual) editor is a full screen editor allowing you to create or edit files. This editor may also be used from with the electronic mail program. It is critical to have your terminal correctly identified before beginning vi. If you have not responded to the TERM= prompt correctly, log out and log back in again.

a. Starting the editor


To create a new file, vi name where name is the name of the file you want to create. If the file already exists, use its name for name .

b. Moving around in a file


Ctrl-u Moves the window up a half screen full. Ctrl-d Moves the window down a half screen full. right and left arrows Move cursor in the direction of the arrow. up and down arrows Move cursor in the direction of the arrow. b Move the cursor back one word at a time (to the left). w Move the cursor forward one word at a time (to the right). 1G Move to the first line of the file. G Move to the end of the file. /pattern Search for a pattern (parts of words, numbers, or combinations) which follows the /. To find the next instance of the pattern, use n. :set nu Display line numbers in the file.

c. Inserting text
i a :r name :$r filename Begins inserting text immediately before the cursor. Press ESC to stop inserting test. Begins appending text immediately after the cursor. Press ESC to stop appending text. Paste an already existing file (filename) into your text. Paste an already existing file (filename) at the end of your text.

Intro To Unix 1

RU-IT

d. Changing and deleting text


r R cw Changes the character under the cursor by replacing it with whatever you type next. Replaces text with whatever you type next, starting with the character under the cursor, and moving to the right typing over old text, until you press the ESC key. Changes a word replacing it with whatever is typed next. Signal the end of the changed text by pressing ESC. The word to be changed begins at the cursor and extends to the right, ending at the first blank space. 3cw changes 3 words. Deletes the word under the cursor. The word to be changed begins at the cursor and extends to the right, ending at the first blank space. Deletes the character under the cursor; 3x deletes three characters. Deletes the entire current line; 3dd deletes 3 lines beginning with the current line. Undo the last command. This is a toggle and will switch back and forth between undo and redo.

dw x dd u

e. Writing (saving) and quitting vi


:wq :w name Write (save changes) and quit. This is the most common way of saving a file and exiting vi. Write the file to a new file (make a copy of the existing file).Parts of the file may be written to a new file using line numbers. For example, :10,25w name :q! would create a new file with lines 10 through 25. Quit without saving the changes to the file.

Intro To Unix 1

RU-IT

9. Redirection
Periodically, you may need to save the results of a program so that you could print them or use them with some other programs. UNIX has two redirection characters which make this possible. | command sends the results or one command to another; for example, if you have a very long directory listing, you might give the ls command piped to more to give you control of the display ls -l /usr/public/sequence/practice| more > filename save the results of a command or program in a file. For example, if you want to keep the results of an ls in a file, you would give the command: ls -l /usr/public/sequence/practice> filename >> filename add to the end of an already existing file

10. Printing Commands


There are several printers, located in the Users Area, which are available to the public. To send files to these printers, use the command specific to the printer you wish to use followed by the file name. The printers commands are: hppr lpr npr Postscript laser printer. 8 1/2 by 11 inch page Wide paper (132 characters per line); tractor fed page (fastest) 8 1/2 by 11 inch tractor fed page; fast -near typewriter quality

For the printers with tractor fed paper, it is wise to use the command pr to page the file before sending it to the printer so that the text does not print over the perforations. The pr command will also put the name of the file on each page and number the pages. For example, to send your cak.db.5 file to the npr printer using this command, you would type the following: pr dickens | npr In this command, the pipe | allows you to send the results from one command (pr) to another command (npr).
Intro To Unix 9 RUCS

Intro To Unix 1

RU-IT

11. Electronic Mail


The program used to send and receive electronic mail is the Mail Handler, or mh. Mail may be sent to anyone on campus with an electronic address and to anyone around the world who is connected to Bitnet or the Internet. Note: Sending and receiving e-mail on mail.rockefeller.edu e-mail server is not authorized using the mail or mh commands. The sequence database servers may also be addressed by using the same mail system. The commands are as follows: inc Pick up your mail; (incorporate). scan List the messages in your mailbox. show message_number Look at a piece of mail. show message_number > filename Make a file of a mail message. show message_number | printer_name Send a message to a printer. rmm message_number Remove a piece of mail. next Display the next piece of mail. prev Display the previous piece of mail. comp Compose mail and send it out. You are prompted for address - To:, complimentary copy - cc:, and the subject of the message - Subject:. The message is then typed after the dashed lines. End message with Ctrl-d. The prompt (What now?:) appears. Type send if you want to send the message or q d to delete the message and to quit. To use the vi editor within mail, choose edit vi. (See the :r command in vi for adding a file to the mail message) repl message_number Reply to a mail message; the address will be filled in. Your electronic address is simply your login name if the person sending you the mail is within the university. If they are from outside of the university, they can send mail to you at either of the following addresses depending on which network they have: login@rockvax.rockefeller.edu login@rockvax.bitnet Internet address Bitnet address

Substitute your login name for login.

Intro To Unix 1

RU-IT

a. Phonebook
There is an on-line version of the University phonebook which lists all names, room number, box number, extension, lab, and login name if there is one. The phonebook may be accessed with two commands: alpha lastname will show you the phonebook listing for whatever name is substituted for lastname. sound lastname allows you to type an approximation of a last name; you must have the first letter of the name correct. Here is an example of a sound listing: sound popowiz Surname | Given Name | Phone | Title Login | Box No. | Room | Lab --------------------------------------------------------------------------------------Pfaus pfaus Popowicz tony | James | Box:275 | Anthony | Box:264 | 8671 | TSH 506 | 8112 | TSH B5 | Postdoctoral Fellow | Pfaff Lab | Assistant Director, | Information

Intro To Unix 1

RU-IT

Summary
Which Machine?
science rockys mail Most of the sequencing programs & statistics packages Molecular Modeling Electronic mail; mail to the sequence servers

Logging in
login: password: TERM = (vt102) the prompt for your login name prompt for your password prompt for your terminal type. Type in correct terminal type if not a z1

Logging out
logout or ctrl d Disconnect from the Rockefeller computers.

Directory Commands
ls ls -l ls -F mkdir name rmdir name list; lists the contents of a directory. long listing of everything in the current directory; gives information about permissions, ownership, date, and size. list files and directories with a / after directory names make directory; creates a directory with the name you supply. removes the name directory if it is empty. The command rmdir must be given from the directory (the parent directory) where the sub-directory was created. The directory must be empty before it can be removed. change directory; moves to the directory named after the command. Without giving the name of a directory to change to, always takes you to your home directory. present working directory; displays the full pathname of the directory.

cd name cd pwd

Intro To Unix 1

RU-IT

File Commands
more name look at the contents of a file one page at a time. To move to the next page, use the space bar. Two commands within more are: q quit; returns your prompt. b back; go back one page cp name newname copy; make a duplicate of a file leaving the original file untouched. cp name directory puts a copy of a file in a sub-directory. The name of the new file is identical to the original. mv name newname renames a file mv name directory rm name remove; moves a file from one directory to another directory. deletes a file. You will be asked to confirm the deletion with a y (yes).

Editing Commands
vi name

moving around in a file


Ctrl-u Moves the window up a half screen full. Ctrl-d Moves the window down a half screen full. right and left arrows Move cursor in the direction of the arrow. up and down arrow b w right). 1G G /pattern :set nu Move cursor in the direction of the arrow. Move the cursor back one word at a time (to the left). Move the cursor forward one word at a time (to the Move to the first line of the file. Move to the end of the file. Search for a pattern (parts of words, numbers,etc.) which follows the /. To find the next instance of the pattern, use n. Display line numbers in the file.

Intro To Unix 1

RU-IT

inserting text
i a :r name :$r filename Begins inserting text immediately before the cursor. Press ESC to stop inserting test. Begins appending text immediately after the cursor. Press ESC to stop appending text. Paste an already existing file (filename) into your text. Paste an already existing file (filename) at the end of your text.

changing and deleting text


r R cw Changes the character under the cursor by replacing it with whatever you type next. Replaces text with whatever you type next, starting with the character under the cursor, and moving to the right typing over old text, until you press the ESC key. Changes a word replacing it with whatever is typed next. Signify the end of the changed text by pressing ESC. The word to be changed begins at the cursor and extends to the right, ending at the first blank space. 3cw changes 3 words. Deletes the word under the cursor. The word to be changed begins at the cursor and extends to the right, ending at the first blank space. Deletes the character under the cursor; 3x deletes three characters. Deletes the entire current line; 3dd deletes 3lines beginning with the current line. Undo the last command

dw x dd u

Intro To Unix 1

RU-IT

writing (saving) and quitting vi


:wq :w name Write (save changes) and quit. This is the most common way of saving a file and exiting vi. Write the file to a new file (make a copy of the existing file). Parts of the file may be written to a new file using line numbers. For example, :10,25w name :q! would create a new file with lines 10 through 25. Quit without saving the changes to the file.

Redirection
| command sends the results or one command to another; for example, if you have a very long directory listing, you might give the ls command piped to more to give you control of the display ls -l | more > filename save the results of a command or program in a file. For example, if you want to keep the results of an ls in a file, you would give the command: ls -l > filename >> filename add to the end of an already existing file

Printing Commands
lpr hppr npr pr Wide paper (132 characters per line); tractor fed page Postscript printer 8 1/2 by 11 inch tractor fed page; fast -near typewriter quality add title, page number, and space file to send it to tractor fed printers. pr file | npr

Intro To Unix 1

RU-IT

Formatting and cleaning sequence files


prepseq Menu driven program to identify, clean, and format sequences Electronic Mail inc Pick up your mail; (incorporate). scan List the messages in your mailbox. show message_number Look at a piece of mail. show message_number > filename Make a file of a mail message. show message_number | printer_name Send a message to a printer. rmm message_number Remove a piece of mail next To display the next piece of mail. prev Display the previous piece of mail. comp Compose mail and send it out. You are prompted for address - To:, complimentary copy - cc:, and the subject of the message - Subject:. The message is then typed after the dashed lines. End message with Ctrl-d. The prompt (What now?:) appears. Type send if you want to send the message or q d to delete the message and to quit. To use the vi editor within mail, choose edit vi. (See the :r command in vi for adding a file to the mail message) repl message_number Reply to a mail message; the address will be filled in.

Intro To Unix 1

RU-IT

Вам также может понравиться