Any user interaction with any "super computer" will require using a command line interface known as a shell. This will be the means that you login to ACISS and run various commands, submit jobs, etc.

Experience has shown that students no longer have any experience in the command line environment so going through these tutorials is a must as you will be running code on ACISS. For the PC platform, you will be installing VirtualBox which will allow the unix Operating System (OS) to run on your own hardware (e.g. your PC laptop).

For Mac users see the static documentation below regarding getting to the command line interface.

Note in general, any actual command syntax is shown in purple font below.

Getting Started with Virtual box:

    Install VirutalBox with the virtual machine name Shells. This can be installed using a thumb drive that you can get from the TA.

    After installing and opening your console looks like this

    Hit the Green Arrow to start


The advantage (big one) of Virtual Box is you get a windowing interface to ACISS. An alternative for old or poor laptops is to use PuTTy (www.putty.org) for a single ssh login window.
Booting up the Virtual Machine and logging into ACISS is shown in the Video Tutorial
For Mac Users: Applications-->Utilities-->Terminal.app

    Now ssh into ACISS as described in the previous video tutorial
Important Notes

  • man commandname brings up help pages; for instance, man ls

  • Unix is Case Sensitive; Ls, LS, lS, and ls would all be interpreted as different commands (some of these will be invalid commands)

  • Execute by typing the command and hitting return

  • If you've made a typo, the easiest thing to do is hit CTRL U to cancel the whole line

  • If your feeling screwed hit CTRL C (this terminates the current running command and gets you back to the shell prompt)

  • Spaces matter in the unix command line; ls -l works but ls - l does not work (don't ask why).

  • arguments (flags) are things that are input into the command; for instance ps -afe feeds three arguments to the ps command

  • Be aware that your backspace and/or delete key may not work as expected in some shells and the arrow keys might not also work as expected

  • Basic list of UNIX commands; Try all of these in your shell login. Commands are issued when you see the shell prompt

    1. ls lists your files
      • ls -l lists details of files
      • ls -a lists hidden files as well
      • ls -tl lists files in date order with details

    2. more filename shows the first part of the file on your screen; space bar pages; q quits --- young people and those more adept than me like to use the less filename command instead of more. I'm old and slow so can only handle more.

    3. mv file1 file2 moves file to new name; mv dir1 dir2 moves directory (dir1) to a new directory

    4. cp file1 file2 copies a file; cp -r dir1 dir2 copies a directory

    5. rm file1 removes a file; use rm -i to protect against stupidity

    6. wc file1 tells you how many lines, words, and characters there are in a file

    7. gzip (or gunzip) file1 compresses or uncompresses a file; gzip produces files with the ending '.gz' appended to the original filename

    8. touch file1 modifies the timestamp of a file; can also creates a NEW file name of 0 length; i.e. touch craig will create a filename craig
    Directory Structure

    Basically consists of top level directory and sub directory. For instance everything with a / at the end of this directory listing (ls) is a subdirectory.





    the exact form the listing is maybe shell or terminal client dependent.
  • mkdir dirname makes a new directory (e.g. mkdir craig)
  • cd dirname goes to that directory ( cd craig goes to the directory you just made)
  • pwd tells you what directory your currently in
  • cd .. moves you back up one directory (cd . does nothing)
  • cd puts you back at your home directory
  • cd ~username puts you in that username's top directory which will have read access (i.e. you can look at what's in there; for instance, cd ~rasmus should scare you).
  • cd ~/papers will take you to the subdirectory papers in your home directory
  • rm -rf craigdir if you want to forceably remove all the files in the directory called craigdir; you shoud always use rm -rif craigdir to protect yourself from stupidity.


  • Do this

    • mkdir craig
    • cd craig
    • mkdir craigup
    • cd craigup
    • touch genius
    • ls

      to produce
    • cd ..
    • rm -rf craigup
    Basic Shell Commands, pipes and file management

  • cat file --- list file to a screen continuously (stupid to use on big files --- use less instead)

  • | is the unix pipe command - can be used as many times on the command line as you want; try ls -lt | more

  • * is the shell wildcard; ls *.txt would show all files ending in .txt

  • grep or fgrep will find regular expressions (usually text) in a file name

  • find is a highly useful feature that allows you to find specific files

  • file provides information about a particular file (whether is binary, text, image, etc e.g. file filename )

    If you want similar bash shell commands consult this resource
  • Details and Examples

    A shell, like the C-shell (csh), contains a number of internal commands that are generally useful. These commands differ from shell to shell and there area a large number of shell commands and shell scripting examples to follow (see also below)

  • cat file | more uses the unix shell pipe | which routes the cat command through the more command

  • cat file1 file2 file3 > outfile add files together into outfile

  • cat *.txt > outfile add all .txt files together

  • cat file1 file2 | fgrep craig will find which file contains the expression craig

  • find . -name \*.f90 -print | more will find all files in all subdirectories starting with the directory you're in that have extension of f90 (Fortran code default extension) and print them on your screen. If you have a lot of these then pipe it through more. Always best to run this in your home (e.g. top) directory. Note the \* is necessary so the find command properly recognizes the * character



  • Shortcuts

    Its important to go through life miniziming keystrokes. For example you really don't want to name a file this_is_what_I_did_today.txt

    set filec allows for auto file tab completion

    history command recalls the history of commands in the shell; set history = 8 sets your history buffer to the last 8 command lines

    to directly recall any previous command type !!

    Depending on terminal emulation the up arrow will also repeat the previous command.

    command line subsitution - uses the ^ character in the C-shell
    Well okay suppose you actually named your file this_is_what_I_did_today.txt (go ahead and touch that filename for practice). How do you avoid typing out the filestring each time you want to do something with it? (like rm the damn thing).

    How about cat this (and now hit tab) and that will complete the filename as long as nothing else is named this in your directory; to find the file type ls *tod* or wc this (tab completion) to run wc on that stupidly long filename

    if you want to execute a command again then type !17 meaning you want to again run the 17th command in your history list :



    Suppose you have a series of filed names called dataout1, dataout2, dataout3, ... dataout101. Some of these files have the keyword craigup in them. So you might type cat dataout17 | fgrep craigup ---- if you want to do the same operation on file dataout51 the just type ^17^51 and hit that will run the previous cat command on file datout51
    Xwindows (real computer scientists hate X; just ignore then, like awk it just fucking works.

    A very long story here which we will skip. This is a mechanism that will send windows back to your Virutal client. To active this feature then ssh in to ACISS with the flag -X

    ssh -X username@aciss

    See Video
    Aliases and setup files

    This is another convenient thing to set up as a short cut. I will use the C shell example which makes use of a file called .cshrc --- any "." file is a hidden file that can only be seen with the ls -a command. The .cshrc file contains a list of aliases that are shorthand to run various commands.

    Again refer to the stunning video


    a very good alias is this alias rm "rm -i" this allows you to now, by default, feed the -i flag to rm
    File Operations and file permissions

    Mostly this is just copying (cp source_file to destination_file), moving (mv), editing (your favorite editor, deleting (rm), etc but in the right panel this shows how to do this on files in other people's directories

    Files have three kinds of permissions, read (r), write (w) and executable (x) and three kinds of owners: a) you the user/owner, b) a group (this is generally not applicable) and c) the world. Any file which is world writable means that anyone can delete it - however, you have to go out of your way to make a world writeable file.

    the chmod command is how you modify permissions and you should man chmod for that help file. You can use chmod with just numeric input (see man page) but I find it more intuitive to use the oug convention (other, user, group).
  • cp ~dkmatter/supercow/gcarlin.wmv . will copy that file (a big file) to your directory (the last . means to copy it to the directory that your currently located in)

    cd ~dkmatter and do ls -l to see permissions



    Anything that is a directory has a d at the start of the permission string. Most all files by default are world readable or -rw-r--r--

  • If I were to execute this command: chmod o+w list2 then I will have made list2 world writeable which means you could delete it and that would have been a stupid thing for me to do.



    Where chmod does matter is if your editing an executable script (see below) in some text editor and you produce a file called runme.txt --- you want to chmod oug+x to make that an executable file.

  • Shell scripting

    There are myriad of things that one can do with a shell script which is a shell specific excutable for running a bunch of commands.

    People that are good at shell scripting a) save a shitload of time and b) generally get good jobs

    There are at least a billion shell scripting example web sites this one is straightfoward

    In general shell scripting is a good an efficent way for doing lots of different kinds of file operations through the use of foreach or while loops (see linked documentation)

    Let's do this on ACISS in a C-shell

  • make a text file called rr using any editor
  • in the first line put #!/bin/csh then edit this in

    echo "What the hell is this" > craigshead
    wc craigshead
    echo "duh" > cc1
    cat cc1 >> craigshead
    more craigshead
    mailx -s "really" rasmus@uoregon.edu < craigshead
    rm craigshead
    

  • chmod oug+x rr
  • /. rr (runs the script from the directory that it is located in)
  • Editing the Command line and Command line file operations

    There are a lot of shell builtins that are quite useful. These days, most people ignore them and write programs instead. That is a mistake - it is much better to uses these builtins. They include

    • sort
    • head or tail (operates on beginning or end of file)
    • cut (difficult to use correctly)
    • awk (seems stupid but it works)
    • sed (command line editor)


    There are many others. You can man each of these commands for the help pages but they are generally opaque. It is best to just practice on a data file shown as shown to the right.
    First cp ~dkmatter/sciprog/master1.txt .

  • grep -i "HURR" master1.txt > new.txt (this creates a new file with only lines that contain HURR in them)

  • sed /s/NAMED//g new.txt > new1.txt (this removes the word NAMED whereever it appears and is taking up one of the data fields and creates the new file new1.txt). A common problem in lots of raw data sets are unnecessary columns (fields) of data and you want to remove them before submitting the data file for analysis

  • awk '{print $1 FS $6 FS $7}' new1.txt > new2.txt (this explicitly tells the file new1.txt to output only columns 1, 6 and 7 to the new2.txt file)

  • sort -n -k 2 new2.txt > new3.txt (this produces the final data file which is sorted by column 2)

    Now you have trimed the raw data file into scientifically useful input. tail -100 new3.txt | more will let you look at the last 100 lines of the file.

  • ACISS and UNIX system stuff

    Here we give you various tools that will help with program compilation, program running, inspecting the state of the system, killing your jobs or processes etc,etc.

    For system load and performance use the top command. (man top for more info)

    Disk or memory management --- run these on ACISS and man them to figure it out
    • quota -v
    • df -k (system disk capacity)
    • du -k (your own disk usage).


    To compile and run a fortran progam with extension of .f90 :
    • gfortran -c prog.f90 (will create a prog.o file)
    • gfortran -o RUN prog.o (creates an executable file called RUN)


    The command ldd to run on an executable shows the libraries that are linked to the program. This is sometimes useful if your program can't run because its missing a library.

    /tmp is the scratch directory cd /tmp puts you there where you can make junk files without tying up system resource.

    For python

    • load module python
    • python
    • when you see >>> your in python


  • path is a command that determine the directory structure to look for executibles; the command which program name will find a program if it is in our path. Try which python

    You are not allowed to run large programs on a head node, so you should use qsub to request a compute node"
    
          qsub -I
    
    Or
    
         qsub -X -I
    


    Note if you ssh into login.aciss you will not be on the headnode.

    Your assigned node will be contained in your prompt (might depend on shell). For example, in C-shell in this sessinon I have been assigned node cn2.



    Note that /tmp space is node dependent so one node's /tmp space is not another node's /tmp space. Therefore, keep track of the node your on in the shell prompt.

  • Craig Wisdom here and Examples:

  • top shows the overall system load, memory resources and the like --- generally this is not useful for you to run

  • ps -afe | fgrep yourusername --- this will return all of your processes and PIDs (process ID). This is useful if you want to forcefully kill a process via kill -9 PID

  • for a quick look at ACISS users try ps -afe | fgrep bash

  • try this:
    • alias gf gfortran
    • cp ~dkmatter/exam/122.f90 .
    • gf -c 122.f90
    • gf -o runme 122.o
    • ldd run (lists the linked libraries)
    • ./runme (to run the program - which won't do anything sensible for you)


    Now try this python example:

    • load module python
    • python



      This example is also in your first homework assignment.

      YOu can also run python directly from the command line using a script: python script.py

      Here is a simply python script to try this on:

      edit a file called t.py

        a=2
        b=4
        c=a+b
        print c

      now python t.py

      PS - please google on I-python Notebook as an important tool to use.

      The PATH environment variable is used to search for executable files.
            echo $PATH
      
      Add directories to your path with
      
           export PATH=$PATH:path_to_new_directory
      
      Allow the module system to set paths to executables.  Try the following commands:
      
          echo $PATH
          module avail python
          module load python/2.7.9
          module list
          echo $PATH
      
      Did your path change?
      
      To load compilers:
      
          module avail gcc
          module load gcc/5.3
          which gfortran
      
      Look at the batch status with the qstat command:
      
          qstat
      
      Pipe to grep to see your jobs in the queue
      
          qstat | grep user_name
      
      Also,
      
          man qstat
          qstat -u user_name
      
      Later you will see how to write a script so that you can submit your own jobs to the queue with the command,
      
          qsub script_name.pbs
      


  • How Computer Scientists Talk to Each Other
    the links to material in the right pane are for more advanced stuff

    These are quite useful if your using a UNIX workstation full time but generally not needed in the command line environment.
  • Variables in the Unix environment

  • Typical Editors

      If you have no familiarity with an editor you should probably just try, in a windowed environment (e.g. ssh - X) gedit --- documentation for gedit can be found here