Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

...

Expand
titleOther Windows ssh/Terminal options

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:

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.

...

Now execute the lines below to set up a login script, called ~/.bashrc. [Note the tilde ( ~ ) is shorthand for "my Home directory".]

When you login via an interactive shell, a well-known script is executed to establish your favorite environment settings. The well-known filename is ~/.bashrc (or ~/.profile on some systems), which is specific to the bash shell.

We've set up pre-created 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, perform the steps below:

...

Warning

If you already have a .bashrc set up, make a backup copy first.

Code Block
languagebash
cd
ls -la  ~
# Do you see a .bashrc file? If so, save it off
cp .bashrc .bashrc.beforeNGS

You can restore your original login script after this class is over.

...

The great thing about this prompt is that it always tells you where you are, which avoids you having to execute the pwd (present working directory) command every time you want to know what the current directory is. Execute these commands to see how the prompt reflects your current directory.

Code Block
languagebash
# mkdir -p says to create all parent directories in the specified path
mkdir -p ~/tmp/a/b/c
cd ~/tmp/a/b/c

# Your prompt should look like this:
ls6:~/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 ( ~ ).

Your login script has configured this command prompt behavior, along with a number of other things.

...

Tip
titleDon't use cat for large files

The cat command just displays the entire file's content, line by line, without pausing, so should not be used to display large files. Instead, use a pager ( like more or less) or look at parts of the file with head or tail.

...

. For example:

more ~/.bashrc

This will display one "page" (Terminal screen) of text at a time, then pause. Press space to advance to the next page, or Ctrl-c to exit more.

You'll see the following (you may need to scroll up a bit to see the beginning):

...

Code Block
languagebash
titleSetting environment variables to useful locations
export BIWORK=/work/projects/BioITeam
export CORENGS=$BIWORK/projects/courses/Core_NGS_Tools
export
ALLOCATION=OTH21164

Environment variables are like variables in other programming languages like python or perl (in fact bash is a complete programming language). 

They have a name (like BIWORK above) and a value (the value of $BIWORK is the pathname of the shared /work/projects/BioITeam directory). Read more about environment variables here: More on environment variables.

To see the value of an environment variable, use the echo command, then the variable name after a dollar sign ( $ ):

Code Block
languagebash
echo $CORENGS
echo $ALLOCATION

...

We'll use the $CORENGS environment variable to avoid typing out a long pathname:

Code Block
languagebash
ls $CORENGS

shell completion

You can use these environment variables to shorten typing, for example, to look at the contents of the shared /work/projects/BioITeam directory as shown below, using the magic Tab key to perform shell completion.

...

Code Block
languagebash
titleSplit a command across multiple lines
ls6:~$ ls ~/.bashrc \
> local~/.profile

Notice that the shell indicates that it is not done with command-line input by displaying a greater than sign ( > ). You just enter more text then Enter when done.

...