A Quick Guide to and Xedit(created on June 19, 2001) 1

Quick Guide to UNIX and Xedit on the Undergraduate SUN Computer Laboratory Department of Mathematics and Statistics

Written by R. L. Broughton and J. S. Visch

Version 1.1: Written June 19, 2001

• THE LAB The Departmental Computer Labs are situated in the basement of the new Mathe- matics and Computer Science building - rooms 033, 035, 036, 038, with the printers in the adjacent rooms 034 and 037. There are 20 X-terminals in each room. These are served by a Sun Enterprise 450 server. The labs themselves will be open -

7am - 11pm Monday to Friday

7am - 7pm Saturday and Sunday.

Outside of normal working hours 8am - 5pm, Monday to Friday, however, a swipe Canterbury card (with permission for entry to the Mathematics and Computer Science Building) will be required for after hours access.

The Mathematics and Statistics Department expects a responsible level of behaviour in its labs. The Lab is under the overall supervision of John Spain, Room 424 (end of the corridor on the fourth floor closest to the Chemistry Building) Phone Ext 7679

• USER CODES In order to use the system you will need to use your universal usercode and password. The password may be changed by using the command passwd. Note changing your password here will not change your password at other departments, and vice versa.

If your are not registered as a user then see John Spain, A Quick Guide to UNIX and Xedit(created on June 19, 2001) 2

• LOGGING IN Activate the screen by touching a key or preferably the mouse. In the Mathematics lab a login window will appear. Type your usercode (login name) here followed by the return key. Then type your password followed by the return key.

Welcome to remote host e450-0 Common Desktop Environment (CDE) Please enter your username

OK Start Over Options Help

Login Window

Space Bar Return Key Keyboard Ctrl Keys Meta Key A Quick Guide to UNIX and Xedit(created on June 19, 2001) 3

After a small wait a series of icons and windows will appear on your screen. You are now ready to proceed to whatever you wish to do. Note: the Main window, the small window at the bottom of your screen should not be used as a working window so that it is always available for use should problems occur in the other windows.

Main • e450-0 e450-0 e450:/users/math/underg/you123>

• Main 11:19am up 17:06, 2 users, load average: 0.44, 0.34, 0.09 User tty login@ idle JCPU PCPU what you123 ttyp0 8:00am 4:22 2:26 -sh you123 ttyp1 8:00am 21 21 13 w e450:/users/math/underg/you123>

In the main window above you will notice: 1. A black arrow - this is the mouse pointer. 2. A black square - this is the mouse cursor, if you move the mouse pointer off the window, the cursor will become white with a black border. 3. A gray band at the top of the window - this indicates that the mouse pointer is currently selecting this window.

Note: to prevent damage to the screen, after a certain period of time, a screen blank operates so that if the screen goes to a state with Computer Lab name blocks plus Xs just touch the mouse to reactivate the screen.

• LOGGING OUT You may quit or exit a window by typing exit or D (which is the UNIX end of file marker). To logout of the system completely, go to your main window and type lo or exit. All windows will be closed and the system exited. Please quit any packages such as SAS, MATLAB, MAPLE etc and the editors before logging out. A Quick Guide to UNIX and Xedit(created on June 19, 2001) 4

• THE MOUSE

The movement of the mouse on the mouse pad causes the mouse pointer on the screen to move in the same direction. The shape of the mouse pointer varies in different parts of the screen. You will see a black cross, an arrow or an I-beam. If the pointer becomes an clock, that means you have to wait while the computer does something. The window must be activated by placing the mouse cursor in that window whence the prompt block becomes solid black. There are several basic techniques to use with a mouse:

- Click Left Press and release the left mouse button to select objects such as windows.

- Drag Press the left mouse button and while holding the button down, move the pointer to a new location by moving the mouse on the mouse pad and seeing the corresponding movement on the computer screen, then release the mouse button. For example you may wish to select a few lines from your window with your mouse 1 starting in position (1), then by dragging the mouse down to position (2) the corresponding 2 text will be highlighted (reversing of black and white) as you move down(not before).

• e450 • e450

This is the first line you wish to select This is the first line you wish to select This is the second line you wish to select This is the second line you wish to select This is the third line you wish to select This is the third line you wish to select This is the fourth line you wish to select This is the fourth line you wish to select This line you do not wish to select This line you do not wish to select

- Click Middle Clicking the middle button inserts a copy of what you have selected to your current posi- tion.

- Click Right Clicking the right button selects everything from the previous position of the cursor to the point where you clicked the right mouse. A Quick Guide to UNIX and Xedit(created on June 19, 2001) 5

• MENUS To obtain a menu, move the mouse pointer away from any windows(as shown in the diagram below) and click on one of the mouse buttons. Keeping the mouse button pressed, you can then move the mouse pointer along the menu items to a specific item, releasing the mouse button selects that item. e.g. A New Window may be activated by moving the mouse cursor to the background and pressing the left button; selecting the item New Window from the application menu (it will highlight) and letting the button go. When the skeleton profile appears on the screen, it may be positioned where you wish before clicking the left button to activate. Once activated a new e450 icon will appear here

Main • e450-0 e450-0

Applications New Window Editor TextEditor Matlab Maple SAS Netscape(WWW) Netscape Mail • Main Webmail 11:19am up 17:06, 2 users, load average: 0.44, 0.34, 0.09 Calculator User tty login@ idle JCPU PCPU what Clipboard you123 ttyp0 8:00am 4:22 2:26 -sh you123 ttyp1 8:00am 21 21 13 w

Other items appear on this menu including Editor which selects the Xedit editor and Matlab which brings up a Matlab window. The right-hand button will bring up a Window operations menu. - Menus for use within an X-window (the e450 window in this case). To view the menus within an X-window, you must also press the control key at the same time. - Moving windows to the foreground. To move a window to the foreground, place the mouse cursor in the grey band at the top of the window and click the left button. Note that the F3 function key will also do this.

If you have too many windows at once on your screen, you can

- quit a window by typing exit in that window. - iconize the window so you can recall it again, by clicking on the • in the small box at the top left-hand of the window. An icon will appear in the icon list, with an • and the window may be reactivated by clicking on the icon X. A Quick Guide to UNIX and Xedit(created on June 19, 2001) 6

• FILES UNIX is a directory based operating system, with a tree-like file structure with a / denoting a directory. Thus you will find yourself automatically at the level of your usercode directory on logging in. For example if you have code you123 (your universal usercode) then you will be at:

/users/math/underg/you123

This directory is referred to as your home directory. Files within a directory are used to store text, pictures or specially formatted pro- grams. File and Directory Names: Filenames may contain any character aside from the /, which is reserved as the separator between files and directories in a pathname. Spaces within filenames are not advised as they are exceptionally hard to use. Although there is a limit on the filename length, for practical purposes you can assume that your filename can be as long as you like. Filenames must be unique within a directory, but can be the same as filenames from other directories.

• WILDCARDS There are 3 special characters which are called wildcards, these are ∗,?, and [ ], which can be used to specify multiple filenames simultaneously. ∗ - An asterisk is replaced with any number of characters in a filename. e.g. fr∗ would match fred, frog, free.ps, etc. if those files were in that directory. ? - A question mark is replaced by any single character. e.g. ?at would match cat, rat, sat, etc. but not brat. [ ] - Square brackets can surround a choice of letters you would like to match. e.g. [wC]atch would match watch and Catch, but not Watch, catch, or wCatch You can use multiple wildcards and combinations to suit your needs. A Quick Guide to UNIX and Xedit(created on June 19, 2001) 7

• UNIX COMMANDS A list of the more common and useful commands is included. For a fuller list see the online manual pages or consult one of the many unix books in the physical sciences library. A unix command may or may not have arguments. An argument can be an option or a filename. The general format for a unix command is:

command option(s) filename(s)

While there aren’t any fixed set of rules for UNIX commands and arguments, you can use the following rules for most situations: - Commands are entered in lowercase. i.e. dir, not DIR. - Options modify the way in which a command works. Options are usually denoted by single letters prefixed by a dash (-). i.e. ls -l ∗ - Multiple options in one command line can be set off individually. In some cases you can divide them after a single dash. i.e. ls -l -a ∗ is equivalent to ls -la. - The argument “filename” is the name of the file you wish to use. Should you miss-spell the filename, then you will get an error message such as “filename: no such file or directory” or “file not found”. - You must insert spaces between commands, options and filenames. - Options come before filenames. - More than one command can be written on one line by the use of the semicolon (;), and will be implemented in consecutive order.

Note: . denotes the current directory .. denotes the parent directory

cat type a cat or file e.g. cat kea.m type Type out the contents of the file kea.m .

cd change directory cd e.g. cd pas Change to subdirectory pas. e.g. cd .. Move up one step in directory tree. e.g. cd ../SASwork Move up one step in directory tree and down to SASwork.

cp copy cp or e.g. cp proj1.m proj2.m copy Copies file proj1.m to file proj2.m e.g. cp ˜tui/seed.food ./kea Copies seed.food from directory user tui to the subdirectory kea of the current directory. A Quick Guide to UNIX and Xedit(created on June 19, 2001) 8

dir list files dir e.g. dir This DOS command will also work. List all files in current directory. e.g. dir q* List all files (and subdirectories) whose names start with q.

ls list files ls (short) e.g. ls List all files in current directory. e.g. ls q* List all files (and subdirectories) whose names start with q.

ll list files ll (long) e.g. ll List all files in current directory with at- tributes, including hidden files (those which start with a “.”). e.g. ll q* List all files (and subdirectories) whose names start with q, however now all the attributes are given.

man help from online man manual e.g.man man View a detailed description of the man com- mand. e.g. man -k copy Gives a one line summary of all commands to do with copying. See also xman

md make directory md mkdir e.g. md projs Make a directory named projs

more view file with more pauses e.g. more proj1.m View the file proj1.m pausing after each screen. e.g. more a*.f View all the files whose names start with an a and end with a .f, one after the other. More also has several options, a list of which you can access by typing h whilst within more. A Quick Guide to UNIX and Xedit(created on June 19, 2001) 9

mv move/rename mv files e.g. mv kea1 kea2 Rename the file kea1 to file kea2 - if there was a kea2 it is overwritten. This differs from the DOS rename.

rm remove/erase rm e.g.rm temp.m Removes the file temp.m. The remove com- mand is aliased to rm -i which is the safer interactive remove that prompts you for con- firmation. The effect is permanent - you can- not undelete a file.

rmdir remove directory rmdir e.g. rmdir temp Removes the subdirectory temp from the cur- rent directory.

xman help xman & Brings up a help window for the on-line man- ual. More convenient than man

killproc kills /system/killproc processes e.g. /system/killproc Will kill all processes xedit. Ideal when you have several xedit windows open which you wish to close all at once. Should you wish to kill only one process type ps to find out the process number (the number given on the left) and then type killproc followed by the process number

kill -9 kills kill -9 processes Only allows you to kill one process at a time Type ps to find out the process number (the number given on the left) and then type kill -9 followed by the process number A Quick Guide to UNIX and Xedit(created on June 19, 2001) 10

• THE FUNCTION KEYS The function keys may be used for certain operations. To date it appears that the following keys have the given effects. F1 Remove window from screen and tag icon.

F2 Refresh screen.

F3 Move window to foreground.

F4 Move window to background.

F5 Toggles zooming of window. (It also brings the window to the foreground)

F6 Toggles locking of cursor on window.

F7 Moves cursor to current window.

F8 Refresh all windows.

F10 Destroys the window. • USEFUL CONTROL KEY COMBINATIONS - ctrl- Terminates the current process. Once terminated, it has to be restarted. - ctrl-s Pauses output from a program that is writing to the screen. - ctrl-q Restarts output after a pause by ctrl-s. - ctrl-u Clears the current input line. - ctrl-z Stops the current process running, fg allows you to continue running the pro- cess. Should you not wish to continue running the process, then do kill the process using “kill the process number found by typing ps”. • PRINTING See “Computer Guide #1 Printing for Undergraduates” for details on how to print on our network. • EMAIL AND THE INTERNET All students can access email and the internet via the use of Netscape. See “Computer Guide #3 Using Netscape”. The above guides are available on the Maths Department web page hppt://www.math.canterbury.ac.nz/documentation.shtml. A Quick Guide to UNIX and Xedit(created on June 19, 2001) 11

• XEDIT - Using the editor xedit This is a screen editor that utilizes the mouse. To use xedit, first type in an X-window

xedit yourfile.m & or choose “Edit” from the Applications Menu. An xedit window will now appear, as shown below.

• xedit Quit Save Load yourfile.m This section is where you can modify the name of your file. Use Control-Sˆ and Control-R to Search. Control-W to Delete. File yourfile.m opened read - write. ˆThis section just gives you information, although you can use it as a scribble

yourfile.m Read - Write ˆ

This section is where you write your file.

← This is a scroll bar, which will only ap- pear if the amount of text gets too long. Moving the pointer here, allows you to move up(click right mouse button) or down(click left mouse button) the document. You can also scroll using the middle mouse button in either direction. Should your text get too wide, a simi- lar scroll bar will appear at the bottom of the xedit window

Press the “return key” at the end of each line COMMANDS click with left mouse button on box

Quit Quits the current editing session. If any changes have not been saved, xedit displays a warning message, allowing the user to save the file. Save If file backups are enabled, xedit stores a copy of the original, unedited file then overwrites the file with the contents of the edit window. The filename is taken from the Text directly to the right of the Load box. Load Loads the file named. A Quick Guide to UNIX and Xedit(created on June 19, 2001) 12

User Commands for the editor xedit The following keystroke combinations are defined The Meta key is the one marked with a ◊ Notation: Ctrl-f means that while you hold down the control key, type f. Note: xedit is in general case sensitive.

Commands for Characters Ctrl-f Forward Character Ctrl-b Backward Character Ctrl-h Delete Previous Character Ctrl-d Delete Next Character

Commands for Words Meta-f Forward Word Meta-b Backward Word Meta-h Delete Previous Word Meta-d Delete Next Word Meta-D Kill Word Meta-H Backward Kill Word Meta-Delete, Meta-Backspace Delete Previous Word Meta-Shift Delete, Meta-Shift Backspace Kill Previous Word

Commands for Lines Ctrl-a Beginning Of Line Ctrl-e End Of Line Ctrl-j Newline And Indent Ctrl-k Kill To End Of Line Ctrl-m Newline Before Cursor Ctrl-o Newline After Cursor Ctrl-p Previous Line Ctrl-n Next Line Ctrl-z Scroll One Line Up Meta-z Scroll One Line Down

Commands for Paragraphs Meta-] Forward Paragraph Meta-[ Backward Paragraph Meta-q Form Paragraph Meta-k Kill To End Of Paragraph

Commands for Pages Meta-v Previous Page Ctrl-v Next Page

Commands for Files Meta-< Beginning Of File Meta-> End Of File Meta-i Insert File

Miscellaneous Commands Ctrl-s Search/Replace Forward Ctrl-r Search/Replace Reverse Ctrl-w Kill Selection Ctrl-y Unkill Ctrl-c Insert Current Selection Meta-y Insert Current Selection Ctrl-l Redraw Display Ctrl-t Transpose Characters Ctrl-u Multiply by 4 Ctrl-g Multiply Reset

In addition, the pointer may be used to cut and paste text: Button 1 Down Start Selection Button 1 Motion Adjust Selection Button 1 Up End Selection (cut) Button 2 Down Insert Current Selection (paste) Button 3 Down Extend Current Selection Button 3 Motion Adjust Selection Button 3 Up End Selection (cut)