Chemistry 350
Course Manual
 

Mainframe Applications

Preliminaries
FTP
Terminal Window
Pico Editor
Unix Commands

 

Preliminaries, Programs and Documents

Before you can log on to your Mason mainframe computer account, you must activate it. Connect to GMU using your computer's network connection and follow the instructions in the Basics chapter in this Manual to activate your account.

There are several terminal and FTP programs available as freeware, shareware, or retail products. The classrooms and computing labs at GMU use the SSH Secure Shell and Secure File Transfer clients, an integrated pair of programs. See the Courseware section of the Chemistry 350 web site for download information.

As you work through this topic, you will need to download these three documents:

Files and Directories

Managing Files and Directories with UNIX Commands

File and Directory Permissions

 

This is an additional document about restoring deleted files: File Recovery.pdf

 

Using the “Zip” utility in Windows

[These instructions are written for Windows XP.]

There are variations on how you organize your documents and folder(s) before zipping. This example is for compressing (“zipping”) a file and a folder of files that are within the same folder.

  • In My Documents, create New Folder. Move (or copy) the file(s) and folder(s) you want to zip to New Folder.

  • Right-click on New Folder. Choose Send To and then Compressed (zipped) Folder.

The zipped file is created in the next higher level directory (My Documents) with the name New Folder.zip.

 


File Transfer Protocol (FTP)

There are times, such as when you construct or edit a web site on your PC, you must upload and download files between your computer and the mainframe. The easiest way to transfer files ("to FTP") in a Windows environment is to use an FTP program. If such a program is not available, alternate instructions are given at the end of the Unix commands section.

 

Secure Shell File Transfer

After you install the program, you must connect for the first time and configure the FTP client.

Connecting

  • Open SSH Secure Shell Transfer client from a desktop icon or from the Start menu.
  • Click the Quick Connect icon or choose File | Quick Connect...
  • You will see the Connect to Remote Host dialog box. The host name for your Mason account is shown below. In the User Name: box, type your own user name.

    connect dialog

 

  • Click [Connect].
  • If the Host Identification box appears, click "Yes".
  • When the Unauthorized Access Prohibited message appears, click [OK].
  • In the Enter Password dialog box, type your Mason account password.
  • Click [OK].
  • When you are ready to stop, choose File | Disconnect. Close the window.

 

Configuring

First, on the menu bar, choose View | Customize... and then click on the Options tab. Check the box that says "Show Screen tips on tool bars". This will help you lean the meaning of the toolbar icons.

 

Confirm or change these features:

  • Choose Edit | Settings... In the left pane, expand "Global Settings" by clicking on the "+" in the box.
  • Expand "File Transfer"
  • Click on "Advanced".
  • Uncheck the box labeled "Preserve original destination permissions". The default file permissions should be 644 and the default directory permissions should be 755.
  • Click on "Mode".
  • Check the box "Auto select" under File Transfer Mode
  • The right-hand pane (ASCII extensions) should include the file extensions .txt, .htm, .html, .bat. If one or more of these are missing, click on the New(Ins) icon (very faint -- there are only two icons) and type the extension in the box and then press [Enter].
  • Click on the [OK] button at the bottom of window to exit the settings.
  • Choose File | Save Settings.

 

Helpful Hints about files

These hints compare/contrast common file manipulations in the Remote system window with Windows:

You cannot delete a folder that is not empty. You must first open the folder and delete the contents and then delete the folder. (In Windows, you can delete a folder and its contents in one operation.)

If you drag a file from one directory to another, the file is copied, not moved. Press the Refresh button to see the results of the operation. In Windows, for files and folders within the same root directory, dragging to a new location results in a move.

 

Transferring files

The File Transfer window consists of three panes, as shown below.

  • The left-hand pane represents the Local View and lists the file and directory contents on your PC. (Look at the Address window.)
  • The right-hand pane represents the Remote View and lists the file and directory contents in your Mason account. (Look at the Address window.)
  • The bottom horizontal pane represents the Transfer View and lists the files and folders that have been transferred between the Local and Remote computers. [You can remove this pane by choosing View | Transfer View from the menu.]

Think of the Mason mainframe computer being at a higher level than your PC and you are located with your PC. When you transfer a file from a PC to Mason, the file is "uploaded" ( "put") . When you transfer a file from Mason to a PC, the file is "downloaded" ("get").

 

Uploading ("putting") files from a Local PC to the Remote system

  • In the Remote system pane, select and open the directory that you want to transfer the file(s) to.
  • In the Local system pane, select and open the folder on your PC that contains the file(s) you want to transfer.
  • Select the Local file(s) that are to be transferred (press the Ctrl key to select multiple files) and drag and drop the highlighted file(s) to the Remote directory pane.

Alternatively, you can use the Upload Dialog facility:

  • In the Remote system pane, select and open the directory that you want to transfer the file(s) to.
  • Click on the Upload Dialog icon or press ^U or choose Operation | Upload Dialog from the menu.
  • In the Upload - Select Files window, find and select the file(s) you want to transfer from your PC.
  • Click on [Upload] button to transfer the file.

 

Downloading ("getting") files from the Remote system to a Local PC

  • In the Local computer pane, select and open the directory on your PC that you want to transfer the file(s) to.
  • In the Remote system pane, select and open the folder that contains the file(s) you want to transfer.
  • Select the Remote file(s) that are to be transferred (press the Ctrl key to select multiple files) and drag and drop the highlighted file(s) to the Local directory pane.

Alternatively, you can use the Download Dialog facility:

  • In the Local computer pane, select and open the directory on your PC that you want to transfer the file(s) to.
  • Click on the Download Dialog icon or press ^D or choose Operation | Download Dialog from the menu.
  • In the Download - Select Files window, find and select the file(s) you want to transfer from your Mason account.
  • Click on [Download] button to transfer the file.

 

ASCII and Binary Files

Before you begin, you need to understand the basics of file transfer so that your files are not corrupted during transfer. There are two modes of transfer, ASCII and binary.

ASCII (American Standard Code for Information Interchange) is a set of 128 symbols, of the sort you see when you type from your keyboard, that can be interpreted and displayed on any computer. ASCII files are sometimes called “plain text” or “raw data” files and don’t have formatting codes. Notepad and Pico text files are ascii files. Almost all computers use ASCII code to represent text and so most programs can open ASCII text files. ASCII files will generally have the file extension .txt.

Binary files include special formatting codes that are associated with only certain programs. Binary files include sound, images, executable program files, compressed files, etc. Word processing and spreadsheet files are usually binary files. Even though a Word document might look like text only, there are many other characters used that control formatting, for example. Other non-text parts of a document might contain images. Some file extensions that denote a binary file are .doc, .exe, and .zip. You can see some of the special formatting if you try to open a binary file in a text reading program such as Notepad. To preserve the formatting, these files cannot be treated in a "standard" way and so must be transferred in "binary" mode. (Try opening an Adobe .pdf file in Notepad to see the special formatting characters.)

When you are transferring files between your PC and the mainframe, you must transfer the file according to its format, ASCII or binary; otherwise, the output may become unreadable. So, .txt, .cgi scripts, and most .htm files are transferred in ascii mode and everything else is transferred in binary mode. If you are in doubt, choose an “autodetect” setting for the transfer. If there is not an autodetect, then choose binary for all transfers.

Here are some practice examples.

 


Terminal Program

SSH Secure Shell

This application is a Windows-based terminal emulator. After you install the SSH, you must connect for the first time and configure the terminal client.

Connecting

  • Open SSH Secure Shell from a desktop icon or from the Start menu.
  • Click the Quick Connect button or choose File | Quick Connect...
  • You will see the Connect to Remote Host dialog box. The host name for your Mason account is shown below. In the User Name: box, type your own user name.

    connect dialog

  • Click [Connect].
  • If the Host Identification box appears, click "Yes".
  • When theUnauthorized Access Prohibited message appears, click [OK].
  • In the Enter Password dialog box, type your Mason password (not your e-mail password).
  • Click [OK].

Note: If you are only able to access the SSH File Transfer Program, after connecting to it as explained in the previous section, choose from the menu Window | New Terminal. You will be automatically connected to the terminal shell.

You can have more than one terminal window open at a time.

You are now at the mason command line prompt and can type Unix commands or start the Pico editor.

When you log in to the system, you are in your home directory. You will see either the osf1.gmu.edu> prompt or the mason2.gmu.edu> prompt or the mason> prompt.

Remember: Commands are case-sensitive. Captial and lowercase letters are not interchangeable.

Logging out

When you are ready to quit your session, type exit or logout and the press [Enter] at the prompt. Do not just close the window. After issuing the command close the terminal window to prevent a quick restart (see status bar at bottom of shell window to understand this)..

 

Configuring

Session Log -- During quizzes or for other reasons, you may need to keep a log file of your activity in the terminal window. When you begin a session, choose File | Log session... In the File name box, type log (or any other name you wish).

Make sure it is saved as a text file. In the Save in: box, choose a directory such as My Documents or Desktop, or choose the Removable Drive letter for your flash drive. Click the [Save] button. Do not save the log session in the default SSH directory.

If you do save the log session in the SSH default directory, and then cannot find the directory folder, do this: Open Windows Explorer in Folders view. From the menu choose Tools | Folder Options | View and then check the box next to "Show hidden files and folders". Click OK. You should then be able to search for and find the log session in the previously hidden SSH folder.

 

 


Pico Editor

To access the text editor Pico, type pico at the mason system prompt. You can begin typing on the blank page (New Buffer).

The main commands can be seen on the bottom of the buffer. Although the letters are shown in uppercase, use lowercase when giving the commands. The ^ character denotes the Ctrl key pressed simultaneously with the letter key. Here is a link to a Pico Tutorial site.

To open an existing file in pico, type pico filename at the mason system prompt (easier if the directory containing the file is the working directory when you invoke Pico). Or, open pico first, then use the command ^R to specify the filename. (It is not necessary to type the letters in uppercase.)

You can insert a file within a file by "reading" the second file when another file is open in Pico using the ^R command. This is similar to pasting text into a Word or Notepad document.

 

^G or F1

Display help text.

^F

Move Forward a character.

^B

Move Backward a character.

^P

Move to the Previous line.

^N

Move to the Next line.

^A

Move to the beginning of the current line.

^E

Move to the End of the current line.

^V or F8

Move forward a page of text.

^Y or F7

Move backward a page of text.

^W or F6

Search for (where is) text, neglecting case (upper or lower case text).

^L

Refresh the display.

^D

Delete the character at the cursor position.

^Shift 6 (^^)

Mark cursor position as beginning of selected text.

^K or F9

Cut selected text (displayed in reverse characters).

^U or F10

Uncut (paste) last cut text inserting it at the current cursor position.

^I

Insert a tab at the current cursor position.

^J or F4

Format (justify) the current paragraph.

^T or F12

To invoke the spelling checker

^C or F11

Report current cursor position

^R or F5

Insert an external file at the current cursor position.

^O or F3

Output the current buffer to a file, saving it.

^X or F2

Exit pico, saving buffer.

 


Managing A Mason Account Using Unix Commands 

The mainframe computer doesn't have a graphical user interface (GUI), only a command line interface. You should know some Unix commands to effectively manage your Mason account. Unix is the operating system for the Mason cluster and the commands you type on the terminal screen are executed by the OS. The structures of a mainframe and a PC with respect to directories and files are similar, so an understanding of the graphical arrangement of folders and files in Windows aids in visualizing directories and files in DOS and Unix.

A brief, interesting overview of Unix can be found at the Bell Labs site.

Below is a short list of useful Unix comands. The words shown in italics are variables to be typed by the user.

After each of the commands given, press [Enter]. You don't get any feedback from UNIX unless you've made an error.

The letter(s) that may appear after the hyphen (-) are part of a command, called options or switches or flags (all synonymous). The options refine the command in some particular way.

Unix help is provided by the man command (stands for manual). To get help for the 'list' command, for example, type man ls. If you don't know the exact command you need, then search for the command by using a keyword. For example, man -k mail will display all commands that have the word 'mail' in their description. There is usually more than you want to know!

Remember, Unix commands are case-sensitive. Don't interchange upper and lower case letters. The symbol ^ means to press the [Ctrl] key and the next shown character(s) simultaneously. The slashes in DOS and Windows are backslashes (\) while the slashes in Unix are frontslashes (/).

 

 

^c

interrupts scroll-by

clear

clears the screen

quota -v

information about the storage limits of your account(s)

pwd

print working directory (shows current directory)

cd name

cd ..

cd or cd ~

cd /

changes to a directory down one level

moves up one directory

changes to the home directory (user's login directory) from anywhere

changes to the root directory (top level directory) from anywhere

ls

ls -p

ls -l

ls -a

ls -al

ls -ap

ls -alp

ls filename

ls -R

lists contents of directory (except "dot" files)

lists contents of directory (except "dot" files) and places a "/" after a directory name

lists (long) detailed information about each file in the directory

lists as above, including "dot" files (all)

 

 


lists the specified file if it exists in the current directory

lists all subdirectorories and their contained files

find ~/ -name filename

finds and displays the pathname to a file in your home directory or its subdirectories

cat filename

more filename

page filename

displays contents of file on screen

displays contents of file on screen one page at a time

cp oldname newname

copies a file

mv oldname newname

renames a file ("move")

mv filename directoryname

moves a file to another directory

rm filename

rm -i filename

removes (deletes) a file

asks if you are sure

mkdir name

makes a new directory as a subdirectory to the current directory

rmdir name

rmdir -i name

removes (deletes) a directory

asks if you are sure

chmod

change mode (see File Permissions document)

pico

pico filename

invokes a simple full-screen editor

opens pico with filename file displayed

passwd

change login password

telnet domain

log on to a remote computer (telnet mason.gmu.edu)

whatis command

displays a one-line description of a command

who | more

lists users on the same system you're logged into, one page at a time

w

(what) gives some of the same information as "finger," plus information on the processes being run by the users and some information about the host computer

w userid

(what) Gives process being run by the named individual user

finger lastname or username

gives information on all users with that last name or specific user

history

displays previous commands typed

logout

exit

logout

date

displays date and time

cal m yyyy

displays a calendar for a given month of a given year. E.g., cal 1 2001 displays a calendar on the screen for Jan., 2001 (cal 2001 displays the whole year)

The letter(s) that may appear after the hyphen (-) are part of a command, called options or switches or flags (all synonymous). The options refine the command in some particular way.

Here are some practice problems using some of the commands in the table above.

Redirecting a Command

The "greater than" symbol, >, redirects the output of a UNIX command. For example, typing the command ls -a directs (prints) the output of the command (in this case the directory listing) to the screen; typing ls -a > filename redirects the output of the command (in this case a list of the contents of the directory) to a new file. You will not see the directory list printed on the screen -- it has been redirected. You can think of this process also as "saving" or "storing" the command output in a file.

The redirect feature can be helpful if you download and print the file to look at later.


 

Excellent on-line references can be found in the Help section of this website.

 


Things that are useful to know,
but you are not responsible for learning

 

Personalize the Command Line Prompt Note: this may no longer work -- 2007

You can personalize the prompt on your UNIX screen so that it shows something other than the hostname of the computer you are working on. For example, my prompt is SWS>

The information is in your .login file. But before you begin altering it, copy it to another file name. At the system prompt type
cp .login old.login [Enter]. Type ls -a to be sure both the old and new file names appear.

Type pico .login When the .login file appears, scroll down the screen with the down arrow until you reach the line set prompt= . Delete the line. Then type a new line in its place: set prompt="whateveryouwant>" Exit and save the file by pressing [Ctrl]-X . Press y (yes) to save modified buffer. Press [ENTER] to save with the default file name. The new prompt will not appear until you log out and log back in again.

 


Disaster Prevention Note: this may no longer work -- 2007

Another useful set of commands to include in your .login file is one that will prevent you from removing (deleting), copying, or moving files until you answer "yes" or "no":

alias rm '/bin/rm -i'
alias cp '/bin/cp -i'
alias mv '/bin/mv -i'

Type these commands as new lines in your .login file using the pico editor. Remember to save a copy of your existing .login file, as above, before altering it.

 


How can you use numbers to change permissions?

If you check the configuration settings for SSH-FTP (see Manual instructions), you can specify default permissions for files and directories expressed as a string of three numbers such as 644 and 755 instead of a string of letters, +, and - to denote permissions. And instead of issuing the command chmod a-wx,u+w, for example, you could type chmod 611.

The simplest way to use numbers is to assign values to the three permissions thusly:

read = 4; write = 2; execute = 1; no permission = 0

The numerical values for each permission granted are totaled for each entity and represented in the order (as usual) user, group, others. So for the permission string rwxr--r--, the 3-digit number would be 744 [(4+2+1), (4), (4)]. The number 511 can only mean r-x--x--x.

Where do the numbers 4, 2, and 1 come from? As you might expect, they are a base-10 conversion from base-2 (binary) notation. Each of the three permissions given to any entity (u, g, o) can be either given (1) or not given (0). Here are the binary possibilities:

attribute r w x binary to base-10
no permissions 0 0 0

0

execute only 0 0 1

1

write only 0 1 0

2

read only 1 0 0

4

write and execute 0 1 1

3

read and execute 1 0 1

5

read and write 1 1 0

6

read, write and execute 1 1 1

7

You can see the number and letter correspondence in SSH-FTP. Right-click on any file or folder in the Remote system pane. Choose Properties. Check or uncheck the permissions boxes and watch the numbers change. Be careful not to lose your own permissions!


Transferring files without an FTP program

Before FTP windows programs such as SSH were developed, files were up- and down-loaded using commands after establishing an ftp connection between two computers. The commands can be remembered if you think of your local PC as where you are and so you would PUT a file on the mainframe from the PC and you would GET a file from the mainframe to place on your PC. You cannot do this from SSH or any Windows shell program.

  • Press the [Start] button, then click on Run....
  • Type ftp mason.gmu.edu in the "Open" box and then click [OK]. A Window will open and inform you that you are connected.
  • Login with your Mason username and password when prompted. The command line prompt wil be ftp>.  You can type some of the usual Unix commands when running ftp; the responses are a little more friendly. However, some commands are different (e.g. use del instead of rm). Type help at the prompt to see a list of commands.
  • Type cd .. to go to the root directory of your PC, C:\ (or you can stay where you are).

    While running ftp, anytime you want to change the directory on your PC, type lcd path where lcd stands for local change directory and path is the DOS path like you see in the address box in Windows Explorer. For example, to change to your floppy drive, type lcd A:\.

To transfer a file from the mainframe to your PC:

  • Change to the mainframe directory that contains the file you want to transfer (cd path).
  • Change to the PC directory in which you want to receive a copy of the file (lcd).
  • To ensure that the transfer will take place in binary mode, type binary (or bin) and then press [Enter]. (If you want to change to ASCII transfer mode, type ascii.)
  • Type get filename and then press [Enter]. You should then see a message stating that the transfer was complete. Check your local directory in Windows Explorer to confirm the file was transferred.

To transfer a file from your PC to the mainframe:

  • Change to the local PC directory that contains the file you want to transfer (lcd).
  • Change to the mainframe directory in which you want to receive a copy of the file (cd path).
  • To ensure that the transfer will take place in binary mode, type binary (or bin) and then press [Enter]. (If you want to change to ASCII transfer mode, type ascii.)
  • Type put filename and then press [Enter]. You should then see a message stating that the transfer was complete. Check to confirm the file was transferred by typing ls.

When you are finished, type quit. The system will respond with "Goodbye" and the window will close.