WORKSHOP QUITO - DAY 3

Getting started in shell


Let’s get started with the Virtual Machine!

First, let’s increase the amount of memory allocated to the machine so that it can run a bit faster. On the Virtual Box, click Settings, then System. On the Motherboard tab, drag the pointer to be halfway between the total number of memory available (for me this is 4GB or 4096).

If you downloaded the VM before July 23, please type the following command.

conda update -p "$HOME/Applications/BioBuilds" -y fastx-toolkit libgd
conda install -p "$HOME/Applications/BioBuilds" -y -c ipyrad ipyrad=0.7.1
conda install -p "$HOME/Applications/BioBuilds" -y numpy=1.12.1

You also should reconfigure the sleep options. Click the blue mouse icon inside the virtual machine, go to Settings, then Power Manager, then Display. Set sleep to “Never” by scrolling the bars all the way to the left.

The linux environment

File systems

Remember - Whenever you call the full path, you can reach the file from anywhere on your computer. Relative paths will change based on your current location.

Unix

Here are some commands you will use all the time, we will review them as we proceed with the lesson

Command Translation Examples
cd change directory cd /absolute/path/of/the/directory/
Go to the home directory by typing simply cd or cd ~
Go up (back) a directory by typing cd ..
pwd print working directory pwd
mkdir make directory mkdir newDirectory creates newDirectory in your current directory
Make a directory one level up with mkdir ../newDirectory
cp copy cp file.txt newfile.txt (and file.txt will still exist!)
mv move mv file.txt newfile.txt (but file.txt will no longer exist!)
rm remove rm file.txt removes file.txt
rm -r directoryname/ removes the directory and all files within
ls list ls *.txt lists all .txt files in current directory
ls -a lists all files including hidden ones in the current directory
ls -l lists all files in current directory including file sizes and timestamps
ls -lh does the same but changes file size format to be human-readable
ls ../ lists files in the directory above the current one
man manual man ls opens the manual for command ls (use q to escape page)
grep global regular
expression parser
grep ">" seqs.fasta pulls out all sequence names in a fasta file
grep -c ">" seqs.fasta counts the number of those sequences
cat concatenate cat seqs.fasta prints the contents of seqs.fasta to the screen (ie stdout)
head head head seqs.fasta prints the first 10 lines of the file
head -n 3 seqs.fasta prints first 3 lines
tail tail tail seqs.fasta prints the last 10 lines of the file
tail -n 3 seqs.fasta prints last 3 lines
wc word count wc filename.txt shows the number of new lines, number of words, and number of characters
wc -l filename.txt shows only the number of new lines
wc -c filename.txt shows only the number of characters
sort sort sort filename.txt sorts file and prints output
uniq unique uniq -u filename.txt shows only unique elements of a list
(must use sort command first to cluster repeats)



Handy dandy shortcuts

Shortcut Use
Ctrl + C kills current process
Ctrl + L
(or clear)
clears screen
Ctrl + A Go to the beginning of the line
Ctrl + E Go to the end of the line
Ctrl + U Clears the line before the cursor position
Ctrl + K Clear the line after the cursor
* wildcard character
tab completes word
Up Arrow call last command
. current directory
.. one level up
~ home
> redirects stdout to a file, overwriting file if it already exists
>> redirects stdout to a file, appending to the end of file if it already exists
pipe (|) redirects stdout to become stdin for next command

Keep in mind: Good judgment comes from experience experience comes from bad judgment go make mistakes