Log into ondemand.c3plus3.org and click the Clusters
-> Falcon Shell Access
buttons. This will open a new window/tab with a terminal interface.
--or--
You should see our Message Of The Day (MOTD)
C3 PLUS 3 HPC RESOURCES
WARNING: To protect the system from unauthorized use and to
ensure that the system is functioning properly, activities
on this system are monitored recorded and subject to audit.
Use of this system is expressed consent to such monitoring
and recording. Any unauthorized access or use of this system
is prohibited and subject to criminal and civil penalties.
___ _ _ _ ___
Welcome | _ \___ __| |___ _ | | (_)_ _ _ ___ __ ( _ )
to | / _ \/ _| / / || | | |__| | ' \ || \ \ / / _ \
|_|_\___/\__|_\_\__, | |____|_|_||_\_,_/_\_\ \___/
|__/
SYSTEM: ondemand.c3plus3.org
CORES: 8
MEMORY: 15919 MB
SUMMARY: (collected Tue Oct 18 10:15:02 MDT 2022)
build_site.py detect_chars.py docs files footer.html head.html index_template.mako insertFileIntoFileAt.sh jenkins.html navbar.html output page_template.mako root_template.mako CPU Usage (total average) = 25.00%
build_site.py detect_chars.py docs files footer.html head.html index_template.mako insertFileIntoFileAt.sh jenkins.html navbar.html output page_template.mako root_template.mako Memory used (real) = 5213 MB
build_site.py detect_chars.py docs files footer.html head.html index_template.mako insertFileIntoFileAt.sh jenkins.html navbar.html output page_template.mako root_template.mako Memory free (cache) = 10036 MB
build_site.py detect_chars.py docs files footer.html head.html index_template.mako insertFileIntoFileAt.sh jenkins.html navbar.html output page_template.mako root_template.mako Swap in use = 559 MB
build_site.py detect_chars.py docs files footer.html head.html index_template.mako insertFileIntoFileAt.sh jenkins.html navbar.html output page_template.mako root_template.mako Load average = 0.05 0.01 0.00
QUESTIONS: Submit all questions, requests, and system issues
to: help@c3plus3.org
Activate the web console with: systemctl enable --now cockpit.socket
Last login: Fri Oct 14 12:18:37 2022 from 192.168.111.14
boswald.ui@ondemand ~ ➇
When you log in you are brought to your home directory by default
pwd
Should get the response
/lfs/yourusername
No matter which server you log into, your home directory will be the same. This is the magic of distributed file systems.
By default you are running in the Bash Shell, which is how you interact with the file system, start programs etc. If you want to search for a command, include the word bash in your query. For example you could google 'bash create directory path'. Here are some of the most common and useful bash commands:
ls
- show me the contents of the current directory
mkdir <dir_name>
- create a new directory
mkdir yournamehere
cd <dir_name>
- change directory
cd yournamehere
cd ..
- change to the parent directory
Example:
boswald.ui@ondemand ~ $ mkdir workshop
boswald.ui@ondemand ~ $ cd workshop
boswald.ui@ondemand ~/workshop $ cd ..
nano <filename>
- edit (and create if necessary) a file
nano somefile.txt
rm <filename>
- delete a file
mv <filename> <destination>
- move or rename a file
man <command>
- show help documentation
which <command>
- locate the actual executable file of a command (and test whether it exists)top
- show system utilization
cat <filename>
- print the contents of a file to screen (std out)
less <filename>
- show the contents of a file interactivelyTo download data directly from the internet, use wget
Lets get some data to work with, Mycobacterium tuberculosis 16S Ribosomal RNA
wget -nc http://hpc.uidaho.edu/example-data/Myco.tb.fasta
If your data is on your local computer, you can scp
the data to the server:
scp /path/to/local/data user@server.domain.com:/path/to/destination
*Note: SCP does not deal well with spaces in paths or filenames.
Other options:
If you were really wanting to create a good phylogeny for these Mycobacterium, you would want to run MrBayes for much longer. However, you also don't want to have to stay logged into the CRC servers while the program is running. In order to keep a program running without being logged in, use the screen command.
screen
What happened? You're now running commands inside a new interactive shell that you can detach from by pressing Ctrl-A
then Ctrl-D
. Lets start a longer running MrBayes job. Edit your mb.run file so that the number of generations is 200000. And then start it.
nano mb.run
mb mb.run
Now detach from the screen with Ctrl-A
then Ctrl-D
boswald.ui@ondemand ~/workshop/Myco $ screen
[detached]
boswald.ui@ondemand ~/workshop/Myco $
And you should be able to see your MrBayes still running by using the top (or htop)command:
top -u benji
At this point you could log out, and MrBayes would continue on until it finished. You reattach with:
screen -r
When you're done with a screen, close it out by typing exit
when you're in the screen.
Now is as good a time as any to say - be a good computational neighbor. Our servers are shared by many researchers, so please don't start a computationally intensive job on a server that is already really busy (pay attention to the MOTD, or use top/htop). The servers will cope relatively well with an overloaded processor, but if you run them out of memory - first they slow down markedly as they start to use hard disk space to offload memory (called swapping). Then the system basically goes crazy and starts a process called OOM killer, which pretty much randomly kills things in a last ditch effort to keep the system from becoming completely frozen.
If you accidentally start a process running and want to stop it use Ctrl-C
(when it's running interactively). If you know the process id (from top) you can stop it with the kill command.
kill 2345
If you use the up and down arrow keys, you can scroll through all the commands you've previously entered. To see a list of all the commands you've entered, use the history command. When you have a bunch of commands in you history (it will store about 1000), pipe the history through another command like less or tail.
history
history | less
history | tail -n 40
You can write a program to do whatever you want using only Bash - but the syntax is a bit different than most other programming languages. First and foremost, spaces matter. In most programming languages the following three lines are equivalent:
a=10
a = 10
a= 10
In Bash, only the first is correct. Once you assign a value to a variable, refer to it by prepending a $
echo $a
The echo command simple means print to the screen (STDOUT). If you just enter $a
, the Bash shell will try to run the command 10 (and give you an error). Similarly, only the first of these commands will work:
if [ $a -lt 11 ]; then echo "less than eleven"; fi
if[ $a -lt 11]; then echo "less than eleven"; fi
if [$a -lt 11]; then echo "less than eleven"; fi
Let's experiment with looping and conditionals. First, let's create a new directory
cd ..
mkdir bashfun
cd bashfun
Now let's create a bunch of input files from the built in $RANDOM variable
for i in {1..50}; do echo $RANDOM > num.$i; done
As an exercise, we'll now create two directories and sort the file by whether the numbers in them are even or odd.
mkdir even odd
for nf in $(ls num.); do rn=$(cat $nf); if [ $(expr $rn % 2) -eq 0 ]; then mv $nf even/ ; else mv $nf odd; fi ; done
ls even
ls odd
cat even/
cat odd/*
Let's deconstruct the above for statement:
# when you wrap text in a $(), that tells Bash to execute the commands within
for nf in $(ls num.*) # list all the files that start with num. and loop over them
do # starts the execution loop
rn=$(cat $nf) # read the file with the name stored in nf and store it as rn
# this really only works when the file contains a single line
if [ $(expr $rn % 2) -eq 0 ] # expr tells Bash to do mathematical operations
then # % means modulo, or the remaider of integer division
# compare numbers in Bash with -lt -gt and -eq
mv $nf even/ # move the file to the even directory
else # the above if returned false, so
mv $nf odd; # move the file to the odd directory
fi # end if command
done # end for loop
All of the above commands could be put into a script, and then executed repeatedly. Here's what that would look like:
#!/bin/bash
# create a bunch of random numbers
for i in {1..50}; do echo $RANDOM > num.$i; done
# sort them
for nf in $(ls num.*); do
rn=$(cat $nf)
if [ $(expr $rn % 2) -eq 0 ]; then
mv $nf even/
else mv $nf odd
fi
done
Create a file named randomsort.sh with the above script. The first line is called the shebang line, and indicates what interpreter to use to run the script - in our case Bash (other options could be python or perl etc...). Comment lines start with a #, and are skipped over by Bash. To make this script executable, we need to set the executable bit
chmod +x randomsort.sh
Then we can execute it with:
./random_sort.sh
Why the ./
? This tells Bash to look in the current directory for the executable, which it would otherwise not do - because it is a security risk. Bash looks for executables in the $PATH
. To see what directories are currently in the $PATH
, we can just echo it out.
echo $PATH
If you've still got the modules from above loaded, you should see their direcotories listed. Unload the modules and see how the $PATH
changes.
module unload mrbayes
echo $PATH
Mostly, the module command just manipulates your $PATH
(It also can set other environment variables and load other modules).
Let's modify our script to accept a command line argument - the number of random number files to generate.
#!/bin/bash
if [ -z $1 ]; then
echo "You need to enter a number"
exit
fi
# create a bunch of random numbers
for i in $(seq 1 $1); do echo $RANDOM > num.$i; done
# sort them
for nf in $(ls num.*); do
rn=$(cat $nf)
if [ $(expr $rn % 2) -eq 0 ]; then
mv $nf even/
else mv $nf odd
fi
done
Command line arguments are passed to a script in the variables $1, $2, $3 ... etc. (the variable $0 contains the name of the script/command). At the top of the script we check to see if the $1 variable is empty (-z), and if it is the script exits. Now if we run our script with a number, it will generate that many files.
./random_sort.sh 10
Of course, there are more advanced methods to parse command line arguments.
Practice exercises: