Introduction to Unix Joey Azofeifa Dowell Lab Short

+ Introduction to Unix Joey Azofeifa Dowell Lab Short Read Class Day 2 (Slides inspired by David Knox)

+ Overview of Computer Architecture Central Processing Unit “CPU” Random Access Memory “RAM” Input / Output Devices (I/O) Disk Storage …how we do we manage these resources

+ The Operating System (OS) is responsible for managing the resources Central Processing Unit “CPU” Random Access Memory “RAM” Input / Output Devices (I/O) Disk Storage

+ How do we interact with the OS? Today: through the shell/command line Central Processing Unit “CPU” Random Access Memory “RAM” Input / Output Devices (I/O) Disk Storage

+ Directory trees encode file system = /joeyazo/Desktop/Lab/Talks/2015/Short. Read. Day_2

+ Why are they called directory trees? … 2013 … … 2014 … … … 2015 …

+ Logging into Vieques n Open your terminal (MAC) or Pu. TTy (PC) n Login onto the server: n ssh username@vieques. colorado. edu Do you see this?

+ Moving through your directories/folders (pwd, ls, cd) n $pwd “this provides the current directory tree”, what do you see? n $ ls “stands for list”, lists the contents of the working directory (or the director/folder you are currently in) n $ cd /projects/sreadgrp/homeworkfiles “stands for change directory and provide the file desination you want to go to” n $pwd (what do you see now? ) n $ls (what do you see? ) …now move back into your home directory (shortcut: $ cd ~) “$___” means You run this command

+ Copying files from place to another (cp) n $<command> <options> <parameters> n Make a folder (make sure you are in your home directory, ($cd ~) or ($cd /Users/your. User. Name/ ) )! n n $mkdir Day 2 n $cd Day 2 n $pwd Copy a file into your new folder! n cp <file path> (what you want to copy) <destination path> (where you want it to go) n $cd /projects/sreadgrp/homeworkfiles/genomes/S 288 c/ n $cp saccharomyces_cerevisiae. gff /Users/your. User. Name/Day 2/ n $ls –l /Users/your. User. Name/Day 2/ (what do you see now? ) Tab complete is your best friend! “$___” means You run this command

+ Using Wild Cards (*) n $ ls *. txt means list all files that end with. txt (this is called a “regular expression”); ls *. fasta means list all the files that end with. fasta. n You can use this * prefix with most unix commands n Make a new folder in Day 2/ called fasta. Files/ n n n $mkdir Fasta. Files (make sure you are in /Users/your. User. Name/Day 2/; “cd” in if you need to and check through “pwd”) $cd /projects/sreadgrp/homeworkfiles/genomes/S 288 c/ $ls *. fasta what do you see now? $cp *. fasta /Users/<you username>/Day 2/Fasta. Files $ls /Users/<you username>/Day 2/Fasta. Files what do you see now? Make a new folder gff. Files in /Users/your. User. Name/Day 2/ n n $cd /Users/your. User. Name/Day 2/ $mkdir gff. Files $mv *. gff. Files/ (mv stands for moves; remember you need to be /projects/sreadgrp/homeworkfiles/genomes/S 288 c/ or give full path for mv wild card command! ) “$___” means $ls –l gff. Files/ (what do you see now? ) You run this command

+ Looking at the contents of your files (wc, head, tail, cat) n $cd /Users/your. User. Name/Day 2/Fasta. Files n $head orf_coding_all. fasta (what do you see) n n $tail orf_coding_all. fasta (shows the last 10 lines by default) n n (similar to the “head” command, show the last 100 lines ) $wc orf_coding_all. fasta (what do you see? , wc stands for word count) n n By default head shows the first 10 lines, we can make it arbitrary $head -100 orf_coding_all. fasta (shows the first 100 lines) (now show the first 200 lines) $wc –l orf_coding_all. fasta (what do you see ? ) $wc –help (this gives you all the command options you can use with wc) Now find the byte count, how many megabytes is that? Remember for one megabyte there 1, 000 bytes. $cat orf_coding_all. fasta (prints the ENTIRE contents of the file…I wouldn’t run this out right? WHY? ) “$___” means You run this command

+ Removing Files (rm) beware… n Change directories into Day 2/Fasta. Files/ n n $cd /Users/your. User. Name/Day 2/Fasta. Files Remove the file orf_coding_all. fasta; remove template $rm <path. To. File. You. Want. To. Remove> n $rm orf_coding_all. fasta n $ls (what do you see now? ) n Recopy orf_coding_all. fasta from /projects/sreadgrp/homeworkfiles/genomes/S 288 c/ n $cp /projects/sreadgrp/homeworkfiles/genomes/S 288 c/orf_coding_a ll. fasta /Users/your. User. Name/Day 2/Fasta. Files “$___” means You run this command

+ Redirecting output (| and >) n Find all the lines that contain “>”; use the “grep” command stands for get regular expression n n Lets count the number of lines that contain “>” n n $grep “>” orf_coding_all. fasta (what happened? ) $grep “>” orf_coding_all. fasta | wc –l Now lets send (redirect) all the lines containing “>” to a new file; here we sending the output from one command to a file! n $grep “>” orf_coding_all. fasta > header_lines n $header_lines (what do you see now? ) “$___” means You run this command

+ Searching through files (grep) n $cd /Users/your. User. Name/Day 2/gff. Files/ n $grep ’FLO 11' saccharomyces_cerevisiae. gff n now count the number lines that just contain “FLO”; how many do you see? “$___” means You run this command

+ Searching through your directory trees (find) n command skeleton: find <root directory to start search and move down> -name <regex pattern> n Find all gff files from /projects/sreadgrp/ n n This is a little advanced; take all the output from find and run a command over them! n n $find /projects/sreadgrp/ -name "*. gff*” Skeleton find <root directory to start search and move down> name <regex pattern> -exec <command here> {} ; Take the output from find, grabbing. gff files and count number FLO 11 ocurrences n $find /projects/sreadgrp/ -name "*. gff*" -exec cat {} ; | grep ". *FLO 11. *" | wc -l “$___” means You run this command

+ The Last Bit: File Permissions (chmod) n Template: $chmod <parameter> <file. Name> n Change into Day 2/Fasta. Files/ n n $cd /Users/Your. User. Name/Day 2/Fasta. Files Change the file permissions so that YOU can read, people in your group can read and execute and others can just read n $chmod u=rwx, g=rx, o=r orf_coding_all. fasta n the user can read, write, and execute it; n members of your group can read and execute it; and n others may only read it. n Change the filer permissions so that EVERYBODY can read, write and execute orf_coding_all. fasta “$___” means You run this command

+ All DONE!
- Slides: 17