Linux Basics - Shell Bootcamp

The Unix Shell

When you log into UNIX/LINUX system, then is starts a program called the Shell. It provides you with a working environment and interface to the operating system. Usually there are several different shell programs installed. The shell program bash is one of the most common ones.

finger <user_name> # shows which shell you are using
chsh -l# gives list of shell programs available on your system (does not work on all UNIX variants)
<shell_name> # switches to different shell

Screen

Starting a New Screen Session

screen # Start a new session
screen -S <some-name> # Start a new session and gives it a name

Commands to Control Screen

Ctrl-a d # Detach from the screen session
Ctrl-a c # Create a new window inside the screen session
Ctrl-a Space # Switch to the next window
Ctrl-a a # Switch to the window that you were previously on
Ctrl-a " # List all open windows. Double-quotes " are typed with the Shift key
Ctrl-d or type exit# Exit out of the current window. Exiting form the last window will end the screen session
Ctrl-a [# Enters the scrolling mode. Use Page Up and Page Down keys to scroll through the window. Hit the Enter key twice to return to normal mode.

Attaching to Screen Sessions

From any computer, you can attach to a screen session after SSH-ing into a server.

screen -r# Attaches to an existing session, if there is only one
screen -r# Lists available sessions and their names, if there are more then one session running
screen -r <some-name> # Attaches to a specific session
screen -r <first-few-letters-of-name> # Type just the first few letters of the name# and you will be attached to the session you need

Destroying Screen Sessions

Terminate all programs that are running in the screen session. The standard way to do that is: Ctrl-c

Exit out of your shell: exit

Repeat steps 1 and 2 until you see the message: [screen is terminating]

There may be programs running in different windows of the same screen session. That’s why you may need to terminate programs and exit shells multiple time.

perl-ne'print if (/my_pattern1/ ? ($c=1) : (--$c > 0)); print if (/my_pattern2/ ? ($d = 1) : (--$d > 0))'my_infile>my_outfile# Parses lines that contain pattern1 and pattern2.# The following lines after the pattern can be specified in '$c=1' and '$d=1'.# For logical OR use this syntax: '/(pattern1|pattern2)/'.

Exercise 2

Delete some of the files generated by csplit
Concatenate single fasta files from (step 1) into to one file with cat (e.g. cat file1 file2 file3 > bigfile).
BLAST two related sequences, retrieve the result in tabular format and use comm to identify common hit IDs in the two tables.

Exercise 3

Run HMMPFAM search with proteins from Exercise 1 against Pfam database (will take ~3 minutes)