Introduction To Unix, Vi, and Mail: The Rockefeller University Information Technology
Introduction To Unix, Vi, and Mail: The Rockefeller University Information Technology
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
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.
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)
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.
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
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
dw x dd u
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
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
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
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.
dw x dd u
Intro To Unix 1
RU-IT
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
Intro To Unix 1
RU-IT