Introduction to UNIX, VI and SSH


1) When you log in the first time, a Web browser and a UNIX shell (dark blue screen) should open automatically. The Web browser works the same as a browser on a PC. The UNIX shell is a screen into which you can run UNIX commands (e.g., file or directory manipulations, launching simulation programs, etc.). 

2) You can minimize any window (to icon size) by clicking (left mouse button) on the dot:
on the top right corner of that window. The window will then shrink to become a small square icon. You can restore the window by clicking anywhere on the icon. 

3) If you click your right mouse button on the above dot, you'll find that you get a list of options of things to do with the window, including changing the size, moving it, etc. You can also kill the window completely by selecting the "Exit" option. 

4) If you killed your Web browser and would like to start a new one, you can either run the command:
        netscape &
from one of your UNIX shells, or you use the Toolchest:
on the upper left corner of your screen. For the latter, click on the "Internet" tab and choose "Open Web Browser". 

5) The toolchest can also be used to open additional UNIX shells -- click on "Desktop" and select "Open Unix Shell". 

6) Finally, the toolchest can be used to log out your session -- click on "Desktop" and select "Log Out". NOTE: you will always be prompted to confirm your logout -- don't walk away until you've clicked "yes".



1) Listing the current directory:  pwd

kumgmw01 1% pwd


2) Listing the contents of a directory:  ls

kumgmw01 2% ls

Desktop            dumpster           nsmail               stu11.outbox

MGMcourse      exercise1          public_html


3) Changing current directory:  cd {directory}

kumgmw01 3% cd exercise1

kumgmw01 4% pwd


kumgmw01 5% ls

eps.pdb             tutorial1.txt


4) Change the name of a file or directory:  mv {old name} {new name}

kumgmw01 6% mv tutorial1.txt Tutorial1.txt

kumgmw01 7% ls

Tutorial1.txt       eps.pdb


5) Copy a file:  cp {old name} {new name}

kumgmw01 8% cp Tutorial1.txt temp

kumgmw01 9% ls

Tutorial1.txt       eps.pdb             temp                 temp


6) Make a new directory:  mkdir {name}

kumgmw01 10% mkdir newdir

kumgmw01 11% ls

Tutorial1.txt       eps.pdb             newdir               temp


7) Move a file into another directory:  mv {file} {directory}

kumgmw01 12% mv temp newdir

kumgmw01 13% ls

Tutorial1.txt       eps.pdb             newdir

kumgmw01 14% cd newdir

kumgmw01 15% ls



8) Move back one directory:  cd ..

kumgmw01 16% pwd


kumgmw01 17% cd ..

kumgmw01 18% pwd



9) cp one directory to another:  cp -r {old name} {new name}

kumgmw01 19% ls

Tutorial1.txt       eps.pdb             newdir

kumgmw01 20% cp -r newdir newdir2

kumgmw01 21% ls

Tutorial1.txt       eps.pdb             newdir               newdir2


10) Verbose listing of a whole directory:  ls -l {directory}

kumgmw01 22% ls -l newdir2

total 30

-rw-r--r--    1 stu11    user       15241 Jan 20 08:13 temp


11) Get immediately back to home (start) directory:  cd

kumgmw01 23% pwd


kumgmw01 24% cd

kumgmw01 25% pwd



12) mv file from another directory to the current directory:  mv {full path} .

kumgmw01 26% mv /usr/people2/stu11/exercise1/newdir2/temp .

kumgmw01 27% ls

Desktop            dumpster           nsmail               stu11.outbox

MGMcourse      exercise1          public_html        temp


13) View the contents of a file:  cat {file}

kumgmw01 28% cat temp

[a whole pile whips past -- you can use the scroll bar to see what you missed]


14) View the contents of a file a bit at a time:  cat {file} | more

kumgmw01 29% cat temp | more

[first page is shown; hit {Enter} to see next line, {space bar} to see next

page, or "q" to quit]


15) Exit your UNIX session

kumgmw01 30% exit



1) Start in your home directory and open the file "temp" into your vi editor:

     vi temp


2) Experiment using the arrow keys to move around the document


3) You can speed up the process by typing a number before hitting the arrow

   key.  For example keying in:


   will take the cursor down 12 lines.  This attribute works with many of the

   other commands below.


4) Other useful keystrokes are:

·  "0"  (takes you to the beginning of the current line)

·  "b"  (takes you to the beginning of the current word)

·  "e"  (takes you to the end of the current word)

·  "E"  (takes you to the end of the line)

·  "G"  (takes you to the end of the file)

·  [Ctrl] "b"  (hit both keys simultaneously:  takes you one page backward)

·  [Ctrl] "f"  (hit both keys simultaneously:  takes you one page forward)


5) You can delete material with the following keystrokes:

·  "D"  (erases all characters from the current one to the end of the line)

·  "dd"  (deletes the current line)

·  "de"  (deletes the current word)

·  "x"  (deletes the current character)

·  "X"  (deletes the previous character)

·  "."  (redoes your last action)


6) You can undo your last deletion with the following:

·  "p" reinserts the most recently character/line right after the current character/line

·  "P" reinserts the most recently character/line just before the current character/line

·  "u" undoes the most recent action


7) You can enter input/modify mode by hitting any of the following keys:

·  "a"  (allows you to input text after the current character)

·  "A"  (allows you to input text at the end of the current line)

·  "i"  (allows you to insert text just before the current character)

·  "I"  (allows you to insert text just before the current word)

·  "o"  (allows you to input text in a new line just after the current one)

·  "O"  (allows you to input text in a new line just before the current)

·  "r"  (allows you to type one new character over the current character)

·  "R"  (allows you to begin entering as much text as you want -- you will type over the first line, but will start on a fresh line when you hit [Enter])

·  "s"  (allows you to substitute a new character for the current one)

·  "S"  (erases everything in the current line, letting you input new text)


   NOTE: once you have entered input/modify mode, you will remain in this mode until you hit the [Esc] key.  If you can't remember if you're in input mode or not, it's often sensible to hit the [Esc] key anyway -- often saves people from accidentally messing stuff up.


   Also NOTE: once you have escaped from input/modify mode, you can undo your

   last editing effort by hitting "u"


8) as long you're not currently in input/modify mode, you can enter search

   mode by typing either "/" or "?"

·  /sometext  (finds the next instance of the string "sometext" in the text an puts your cursor there)

·  ?othertext  (same as above, but searches upwards through the file for a previous instance of the string "othertext")


9) as long you're not currently in input/modify mode, you can enter command

   mode by typing ":"


   Useful file manipulation commands include:

·  :q!  (exits vi without saving anything)

·  :w  (writes the current contents to the original file name)

·  :w file1  (writes the current contents to a new file called "file1")

·  :w! file1  (writes the current contents to a file called "file1", even if the file already existed)

·  :wq  (saves the current contents to the original file name and quits vi)


   and some useful commands for manipulating portions of the files include:

·  :5  (moves cursor to line number "5")

·  :set nonumber  (turns off line numbering)

·  :set number  (turns on line numbering)

·  :1,20 w! file2  (writes the contents of lines 1-20 to the file "file2")

·  :5,25 s/teh/the/  (searches ever line from 5-25 and replaces the first instance of the text "teh" in each line with "the")

·  :5,25 s/teh/the/g  (searches ever line from 5-25 and replaces all instances of the text "teh" with "the")



In order to carry out some of the exercises in this course, you will need to

access the MGM Lab's Athlon cluster.  This computer can't be accessed by

regular internet tools like "telnet" and "ftp" due to security concerns. 

instead they are accessed by "ssh" (secure shell) and "sftp" (secure ftp).


ssh is similar to telnet, but with slightly different syntax.  depending on

which account you have, you will be able to access the cluster with one of the

following commands:

·  ssh -1 stu11

·  ssh -1 stu12

·  ssh -1 stu13


You will be prompted for a password -- it will be the same one as you were

given for the MGM Lab SGI.  You should be able to perform all of the same UNIX

commands that you used in the previous tutorial.


The syntax for sftp is as follows:

·  sftp

·  sftp

·  sftp

you will again be prompted for that same password.  sftp is intended for file

transfer only, so you can't do nearly as much as you could with ssh.  The valid

commands are as follows:

·  cd {directory name}  (change directories on kumgmc01)

·  pwd  (list the path for the current directory on kumgmc01)

·  lcd {directory name}  (change directories on your local machine)

·  ls  (list contents of current directory on kumgmc01)

·  get {file}  (get a file from the current directory on kumgmc01 and write it to the current directory on your local machine)

·  put {file}  (put a file from the current directory on your local machine to the current directory on kumgmc01)

·  quit  (quits the sftp session)




David Johnson
Access to more than 40 computational chemistry software programs and databases
High-performance computational tools accelerate drug discovery and minimize costs
Analyze complex, multidimensional data sets to rapidly generate biological insights
KU Today