This lab is mainly about getting you set up for the rest of the semester. I'll get you somewhat familiarized with the shell environment, but encourage you to explore on your own - this will only help you in your (grad) student careers.
Restart your lab computer into Debian (Windows: shut down, restart).
You will be working on a machine that is called redoubt.ees.nmt.edu
. It sits in my office and
has all the software required for this class installed and running. I created logins for you. These should be tested now:
christine, emily, zach
ssh -Y USERNAME@redoubt.ees.nmt.edu
; obviously you'll replace USERNAME
with your actual
user name.
passwd
and set you password to something reasonable. If, after the lab, I can still login with the default password you'll get points deducted.
Note that you don't have to be in an ITC lab to log into this machine. If you feel so inclined, you can log into this machine from your own laptop at home (unless it's down for some reason, then you should send me an email and let me know about it).
Note also, that this system is currently backup up daily, but I recommend saving scripts etc, you're working on to a different machine (Dropbox should work, Google Drive should work, scp
to your local machine is a good idea)
The first thing you'll do is copy a some default settings into your home directory:
redoubt:~> cp /home/.tcshrc ~
redoubt:~> source ~/.tcshrc
~
or /home/USERNAME
, note that the command
cd
without any parameters always gets you back $HOME
). The file
.tcshrc
is basically a SHELL script that is executed on each login to set your environment. The second
line sources that file, i.e. it's being executed. A lot of environment variables are being set and programs are now in your PATH
and hence directly accessible to you form the command line.
redoubt:~> gd2p.pl
. That's a command line front-end we'll use for GPS
processing later. Copy the LAST 2 lines of the output into your lab report file In addition, try executing
insarApp.py --help
and copy the FIRST 2 lines of output into your lab report file.
.tcshrc
:
redoubt:~> gedit ~/.tcshrc &
.tcshrc
in a text editor (gedit). If you are experienced with other editors such as
vi, emacs
feel free to use these. I won't have time to explain how they work to you, though. The &
sends the
editor process in the background and you still can use your terminal.
setenv GEOP555 /data/GEOP555
to the file. This creates a new environment variable GEOP555
and sets its
value to the directory /data/GEOP555
. Save the file, go to the command line and activate the changes through:
redoubt:~> source ~/.tcshrc
redoubt:~> cd $GEOP555
redoubt:~> ls
redoubt:~> mkdir $USER
redoubt:~> ls -lisa
$USER
, don't forget the '$'). Copy the output
of the ls
command into the report file. This new directory will be your working directory for this class.
In ~/.tcshrc
change this line setenv GEOP555 /data/GEOP555
to setenv GEOP555 /data/GEOP555/$USER
so you will
be able to cd
directly into this directory via:
redoubt:~> cd $GEOP555
$GEOP555
a lot in future labs.
Type these commands and follow the output on the screen. I want you to get to know this world a bit better:
> cd /usr/bin
> ls
> ls | more
> man more
> man man
> cd ~
> pwd
> whoami
> echo $USER
> cd $GEOP555
> matlab &
&
pushes the new process in the background which allows you to continue using this terminal window.
A useful thing to know is that with the up
and down
arrows you can browse through the history of your commands. Quite handy if you
just typed a very long command and you want to do something quite similar again (Well, it that case it might be time for some shell scripting).
You can learn more about existing environment variables by using env | more
.
Copy the output from the history
command into your lab report
Execute this sequence of commands, to create a directory in your workspace to work in for this lab:
> cd $GEOP555
> mkdir lab01
> cd lab01
Below I give a list of UNIX commands which I find useful and you'll use some of these now.
Download the file FAIR.pfiles while in $GEOP555
using wget
(You could
create a subdirectory mkdir lab01
, if you wanted to be organized):
> wget http://grapenthin.org/teaching/geop555/lab01/FAIR.pfiles
Each of the commands given in the tables below does something and creates output that that can be piped into
the others (multiple pipes are perfectly fine: command1 | command2 | command3 | ... | commandN
).
The general syntax of Unix commands given in the man-pages
is generally something like command [options] file(s)
. This means you write the command
name on the command line, you get to chose whether you want to use any of the options the command offers (square brackets
usually indicate that things can be left out), and then you operate on one or more files. Here are the commands:
command | useful options | explanation |
ls | -l, -s, -t, -r | list files in current directory |
wc | -l, -c, -w | count lines, characters (bytes), words |
head | -#### (### represents number) | output first part of a file |
tail | -#### (### represents number) | output last part of a file |
diff | compare files line by line | |
sort | -n -r -k | sort lines of text files |
history | none. | lists history of commands |
df / du | -k -h | show available disk-space / space used by files |
cat | display / concatenate files | |
top | -n | show process statistics, for piping use top -n 1 as it keeps running otherwise |
Type ...
> less FAIR.pfiles
> wc -l FAIR.pfiles
wc
stands for wordcount, but it does more):
> grep -v # FAIR.pfiles | wc -l
#
sign in them, then we pipe (|
) it into wc
, which gives us
the number of data points. Give me the number of data points in your report.
OK, one last thing before the plotting:
> grep -v # FAIR.pfiles | awk '{print $1,$4,$5,$6}' > FAIR.plot
#
in them, then we pipe it into awk
and print columns 1,4,5, and 6. The output
gets redirected into a new file FAIR.plot
via the output redirection >
. You can omit > FAIR.plot
and
everything ends up in you console again.
Now, use any tool you are comfortable with (matlab, python, gnuplot, ...) to write a short script that loads FAIR.plot
and provides
a figure with 3 subplots of, respectively, column 2,3,4 (in FAIR.plot) over column 1. What are the columns again? Label your axes! Make sure NOT
to plot continuous lines, but circles/dots for each data point.
If you're into Matlab, here is a list of functions that might be of help (Python's matplotlib uses the same function names and syntax.).
textread
: read a text filetextscan
: read a text file differentlyfigure
: creates a canvas which to draw onsubplot
: creates "tiling" of the canvas, so you can have multiple plots in 1 figureplot
: plots one data set over the other.xlabel
: label x-axisylabel
: guess!title
: guess again!FAIR.plot
file you createdrg <at> nmt <dot> edu | Last modified: August 23 2017 19:00.