...
The Terminal window
- Macs and Linux have a Terminal programs program built-in – find it now on your computer
- Windows optons:Windows 10Command shell 10 or later has ssh and scp in Command Prompt or PowerShell (may require latest Windows updates)
- Open the Start menu → Search for Command
- Open the Start menu → Search for Command
Expand | |
---|---|
|
...
- See https://docs.microsoft.com/en-us/windows/wsl/install-win10
- We recommend the Ubuntu Linux distribution, but any Linux distribution will have an SSH client
...
| |
If your Windows version does not have ssh in Command Prompt or PowerShell:
|
...
|
...
|
...
|
...
More advanced options for those who want a full Linux environment on their Windows system:
|
...
...
...
...
- A full Linux environment, including X-windows for running GUI programs remotely
- Complicated to install
|
From now on, when we refer to "Terminal", it is either the Mac/Linux Terminal program, Windows Command Prompt or PowerShell, or the PuTTY program.
SSH
ssh is an executable program that runs on your local computer and allows you to connect securely to a remote computer. We're going to use ssh to access the stampede2 Lonestar6 compute cluster at TACC, where the remote host name is stampede2ls6.tacc.utexas.edu.On Macs or Linux, you run ssh from a Terminal window. To invoke a Linux Terminal window if you have the Windows subsystem for Linux installed, double-click on the icon for the Linux distribution you installed (e.g. Ubuntu).
In your local Terminal window:
Code Block | ||||
---|---|---|---|---|
| ||||
ssh <your_TACC_userID>@stampede2userID>@ls6.tacc.utexas.edu # For example: ssh abattenh@ls6.tacc.utexas.edu |
- Answer yes to the SSH security question prompt
- Enter the password associated with your TACC account
- Wait for your 2-factor authentication code to arrive via SMS or app, then type it in
Expand | ||
---|---|---|
| ||
If you're using |
...
PuTTY as your Terminal from Windows:
|
...
|
...
|
...
|
The bash shell
You're now at a command line! It looks as if you're running directly on the remote computer, but really there are two programs communicating:
- your local Terminal
- the remote Shell
There are many shell programs available in Linux, but the default is bash (Bourne-again shell).
The Terminal is pretty "dumb" – just sending your typing what you type over its secure sockets layer (SSL) connection to TACC, then displaying the text sent back by the shell. The real work is being done on the remote computer, by programs called by the bash shell.
...
Setting up your environment
Create some
...
symbolic links and directories
First we will create a few directories and links we will use (more on these later).
...
Code Block | ||||
---|---|---|---|---|
| ||||
cd # makes your Home directory the "current directory"cd ln -s -f $SCRATCH scratch ln -s -f $WORK2$WORK work2work ln -s -f /work2work/projects/BioITeam ln -s -f /work2/projects/BioITeam/projects/courses/Core_NGS_Tools CoreNGS /projects/courses/Core_NGS_Tools CoreNGS |
Symbolic links (a.k.a. symlinks) are "pointers" to files or directories elsewhere in the file system hierarchy. You can almost always treat a symlink as if it is the actual file or directory.
Tip | |||||
---|---|---|---|---|---|
$WORK | |||||
Tip | |||||
$WORK2 and $SCRATCH are TACC environment variables that refer to your Work2 and Scratch file system areas. Work and Scratch file system areas. They are like variables in other programming languages, in that they have a name (WORK, SCRATCH) and hold a value ($WORK, $SCRATCH) To see the value of an environment variable, use the echo command:
|
...
Expand | |||||||
---|---|---|---|---|---|---|---|
| |||||||
The ln -s command creates a symbolic link, a shortcut to the linked file or directory.
Want to know where a link points to? Use ls with the -l (long listing) option.
|
...
Code Block | ||||
---|---|---|---|---|
| ||||
mkdir -p ~/local/bin cd ~/local/bin ln -s -f /work2work/projects/BioITeam/common/bin/launcher_creator.py ln -s -f /work2/projects/BioITeam/common/bin/launcher_maker.py |
Tip | ||
---|---|---|
| ||
The tilde character ( ~ ) is a pathname shortcut that means "home Home directory". We'll see more of it later. $HOME is an environment variable set by TACC that also refers to your home Home area directory. |
Setup your login profile (~/.bashrc)
...
When you login via an interactive shell as you did above, a well-known script is executed by the shell to establish your favorite environment settings. We've set up a common login script for you to start with that will help you know where you are in the file system and make it easier to access some of our shared resources. To set it up, do perform the steps below:
Warning | |||||
---|---|---|---|---|---|
If you already have a .bashrc set up, make a backup copy first.
You can restore your original login script after this class is over. |
...
Code Block | ||||
---|---|---|---|---|
| ||||
cd cp /work2work/projects/BioITeam/projects/courses/Core_NGS_Tools/tacc/bashrc.corengs.stampede2ls6 .bashrc chmod 600 .bashrc |
...
Since .bashrc is executed when you login, to ensure it is set up properly you should first log off stampede2 ls6 like this:
Code Block | ||||
---|---|---|---|---|
| ||||
exit |
Then log back in to stampede2ls6.tacc.utexas.edu. This time your .bashrc will be executed and you should see a new shell prompt:
Code Block |
---|
stamp2ls6:~$ |
The great thing about this prompt is that it always tells you where you are, which avoids you having to issue the execute the pwd (present working directory) command all the timeevery time you want to know where you are. Execute these commands to see how the prompt reflects your current directory.
Code Block | ||
---|---|---|
| ||
mkdir -p ~/tmp/a/b/c cd ~/tmp/a/b/c # Your prompt should look like this: stamp2ls6:~/tmp/a/b/c$ |
The prompt now tells you you are in the c sub-directory of the b sub-directory of the a sub-directory of the tmp sub-directory of your Home directory ( ~ ).
So why don't you see the .bashrc file you copied to your home directory? Because all files starting with a period (dot files) are hidden by default. To see them add the -a (allall) option to ls:
Code Block | ||||
---|---|---|---|---|
| ||||
cd ls -a |
To see even more detail, including file type and permissions and symbolic link targets, add the -l (long listing) switchoption:
Code Block | ||
---|---|---|
| ||
ls -la |
Tip | ||
---|---|---|
| ||
Your new ~/.bashrc files bashrc file defines a ll alias command, so when you type ll it is short for ls -la. |
...
Code Block | ||||
---|---|---|---|---|
| ||||
#!/bin/bash # TACC startup script: ~/.bashrc version 2.1 -- 12/17/2013 # This file is NOT automatically sourced for login shells. # Your ~/.profile can and should "source" this file. # Note neither ~/.profile nor ~/.bashrc are sourced automatically by # bash scripts. However, a script inherits the environment variables # from its parent shell. Both of these are standard bash behavior # by bash scripts. # In a parallel mpi job, this file (~/.bashrc) is sourced on every # node so it is important that actions here not tax the file system. # Each nodes' environment during an MPI job has ENVIRONMENT set to # "BATCH" and the prompt variable PS1 empty. ################################################################# # Optional Startup Script tracking. Normally DBG_ECHO does nothing if [ -n "$SHELL_STARTUP_DEBUG" ]; then DBG_ECHO "${DBG_INDENT}~/.bashrc{"; fi ###################### # SECTION 1 -- modules # There are 3 independent, safe ways to modify the standard module setup: # 1) Use "module save" (see "module help" for details). # 2) Place module commands in ~/.modules # 3) Place module commands in this file inside the if block below. modules if [ -z "$__BASHRC_SOURCED__" -a "$ENVIRONMENT" != BATCH ]; then export __BASHRC_SOURCED__=1 module load launcher fi ############ # SECTION 2 -- environment variables if [ -z "$__BASHRCPERSONAL_SOURCEDPATH__" -a "$ENVIRONMENT" != BATCH ]; then export __BASHRCPERSONAL_SOURCEDPATH__=1 module load launcher module load git fi ############ # SECTION 2 -- environment variables if [ -z "$__PERSONAL_PATH__" ]; then export __PERSONAL_PATH__=1 # for NGS course export LANG="C" # avoid the annoying Perl warnings on cds, etc. export PATH=.:$HOME/local/bin:$PATH export ALLOCATION=UT-2015-05-18 # Group is G-816696 export BIWORK=/work2/projects/BioITeam export PATH=.:$HOME/local/bin:$PATH fi # For better colors using a dark background terminal, un-comment this line: #export LS_COLORS=$LS_COLORS:'di=1;33:fi=01:ln=01;36:' # For better colors using a white background terminal, un-comment this line: #export LS_COLORS=$LS_COLORS:'di=1;34:fi=01:ln=01;36:' export LANG="C" # avoid the annoying Perl locale warnings export BIWORK=/work/projects/BioITeam export CORENGS=$BIWORK/projects/courses/Core_NGS_Tools export BI=/corral-repl/utexas/BioITeam export PATH=.:$HOME/local/bin:$PATH # For better colors using a dark background terminal, un-comment this line: # export LS_COLORS=$LS_COLORS:'di=1;33:fi=01:ln=01;36:' # For better colors using a white background terminal, un-comment this line: # export LS_COLORS=$LS_COLORS:'di=1;34:fi=01:ln=01;36:' fi ########################/utexas/BioITeam export ALLOCATION=OTH21164 # For ls6 Group is G-824651 ##export ALLOCATION=UT-2015-05-18 # For stampede2 Group is G-816696 ########## # SECTION 3 -- controlling the prompt if [ -n "$PS1" ]; then PS1='stamp2ls6:\w$ '; fi ################################## # SECTION 4 -- Umask and aliases and umask #alias ls="ls --color=always" alias ll='"ls -la'" alias lah="ls -lah" alias lc="wc -l" alias lhhexdump='lsod -A x -t x1z -lhv' umask 002 ############################################# # Optional Startup Script tracking if [ -n "$SHELL_STARTUP_DEBUG" ]; then DBG_ECHO "${DBG_INDENT}}"; fi |
So what does the common this login script do? A lot! Let's look at just a few of them.
...
The first line is the she-bang. Even though the expression is inside a shell comment (denoted by the # character), it tells the shell (bash) what program should execute this file – in this case, bash itself.
...
The login script also sets an environment variable $BIWORK to point to the shared directory /work2work/projects/BioITeam, and another environment variable $CORENGS to point to the specific sub-directory for our class.
Code Block | ||||
---|---|---|---|---|
| ||||
export BIWORK=/work2work/projects/BioITeam export CORENGS=$BIWORK/projects/courses/Core_NGS_Tools |
Environment variables are like variables in a programming language like python or perl (in fact bash is a complete programming language). They have a name (like BIWORK above) and a value (the value for BIWORK of $BIWORK is the pathname /work/projects/BioITeam). Read more about environment variables here: More on environment variables.
...
You can use these environment variables to shorten typing, for example, to look at the contents of the shared /work2work/projects/BioITeam directory as shown below, using the magic Tab key to perform shell completion.
...
Code Block | ||||
---|---|---|---|---|
| ||||
# hit Tab once after typing $BIWORK/ to expand the environment variable ls $BIWORK/ # now hit Tab twice to see the contents of the directory ls /work2work/projects/BioITeam/ # type "pr" and hit Tab again ls /work2work/projects/BioITeam/pr # type "co" and hit Tab again ls /work2work/projects/BioITeam/projects/co # type "Co" and hit Tab again ls /work2work/projects/BioITeam/projects/courses/Co # your command line should now look like this ls /work2work/projects/BioITeam/projects/courses/Core_NGS_Tools/ # now type "mi" and one Tab ls /work2work/projects/BioITeam/projects/courses/Core_NGS_Tools/mi # your command line should now look like this ls /work2work/projects/BioITeam/projects/courses/Core_NGS_Tools/misc/ # now hit Tab once # the shell expands as far as it can unambiguously, # so your command line should look like this ls /work2work/projects/BioITeam/projects/courses/Core_NGS_Tools/misc/small # now hit Tab twice # You should see 3 filenames, all starting with "small" # small.bam small.fq small2.fq # type a period (".") then hit Tab twice again # You're narrowing down the choices -- you should see two filenames ls /work2work/projects/BioITeam/projects/courses/Core_NGS_Tools/misc/small # small.bam small.fq # finally, type "f" then hit Tab again. It should complete to this: ls /work2work/projects/BioITeam/projects/courses/Core_NGS_Tools/misc/small.fq |
...
Here's how the common login script adds your $HOME/local/bin directory to the location list – recall that's where we linked several useful scripts – along with a special dot character ( . ) that means "here", or "whatever the current directory is". In the statment statement below, colon ( : ) separates directories in the list.
...
Code Block | ||||
---|---|---|---|---|
| ||||
########## # SECTION 3 -- controlling the prompt if [ -n "$PS1" ]; then PS1='stamp2ls6:\w$ '; fi |