Skip to content

Instantly share code, notes, and snippets.

@nickfogle
Last active August 29, 2015 14:00
Show Gist options
  • Save nickfogle/11299389 to your computer and use it in GitHub Desktop.
Save nickfogle/11299389 to your computer and use it in GitHub Desktop.
Linux Dev Installs
# Intermediate bash - Keyboard shortcuts
• Ctrl + A: Go to the beginning of the line you are currently typing on
• Ctrl + E: Go to the end of the line you are currently typing on
• Ctrl + F: Forward one character.
• Ctrl + B: Backward one character.
• Meta + F: Move cursor forward one word on the current line
• Meta + B: Move cursor backward one word on the current line
• Ctrl + P: Previous command entered in history
• Ctrl + N : Next command entered in history
• Ctrl + L: Clears the screen, similar to the clear command
• Ctrl + U : Clears the line before the cursor position. If you are at the end of the line,
clears the entire line.
• Ctrl + H : Same as backspace
• Ctrl + R: Lets you search through previously used commands
• Ctrl + C : Kill whatever you are running
• Ctrl + D: Exit the current shell
• Ctrl + Z: Puts whatever you are running into a suspended background process. fg
restores it.
• Ctrl + W : Delete the word before the cursor
• Ctrl + K: Kill the line after the cursor
• Ctrl + Y : Yank from the kill ring
• Ctrl + _: Undo the last bash action (e.g. a yank or kill)
• Ctrl + T: Swap the last two characters before the cursor
• Meta + T: Swap the last two words before the cursor
• Tab: Auto-complete files and folder names
# Deploy Node.js App to Heroku
# Execute these commands on your EC2 instance.
*Note that -qO- is the English letter not zero.*
1) Install heroku and git
> `sudo apt-get install -y git-core`
> `wget -qO- https://toolbelt.heroku.com/install-ubuntu.sh | sh`
> `which git`
> `which heroku`
2) Store Code on Github
> `git push origin master`
*to pull code, use `git pull --rebase`
3) To deploy, Login and set keys in Heroku
> `heroku login`
> `ssh-keygen -t rsa`
> `heroku keys:add`
4) Push to Heroku
> `cd webApp`
> `heroku create`
> `git push heroku master`
# Download chromosome 22 of the human genome
> `wget ftp://ftp.ncbi.nih.gov/genomes/Homo_sapiens/CHR_22/hs_ref_GRCh38_chr22.gbk.gz`
> `gunzip hs_ref_GRCh38_chr22.gbk.gz`
> `less hs_ref_GRCh38_chr22.gbk.gz`
> `cat hs_ref_GRCh38_chr22.gbk.gz # hit control-c to interrupt`
# First part of files: Head
Look at the first few lines of a file (10 by default). Surprisingly useful for debugging and
inspecting files.
> `head --help`
> `head *gbk # first 10 lines`
> `head -50 *gbk # first 50 lines`
> `head -n50 *gbk # equivalent`
> `head *txt *gbk # heads of multiple files`
> `head -q *txt *gbk # heads of multiple files w/o delimiters`
> `head -c50 *gbk # first 50 characters`
# Extract Columns: Cut
Pull out columns of a file. In combination with head/tail, can pull out arbitrary rectangular
subsets of a file. Extremely useful for working with any kind of tabular data (such as data
headed for a database).
> `wget ftp://ftp.ncbi.nih.gov/genomes/Bacteria/\`
> `Escherichia_coli_K_12_substr__W3110_uid161931/NC_007779.ptt`
> `head *ptt`
> `cut -f2 *ptt | head`
> `cut -f2,5 *ptt | head`
> `cut -f2,5 *ptt | head -30`
> `cut -f1 *ptt | cut -f1 -d’.’ | head`
> `cut -c1-20 *ptt | head`
# Numbering lines: nl
Number lines. Useful for debugging and creating quick datasets. Has many options for
formatting as well.
> `nl *gbk | tail -1` determine number of lines in file
> `nl *ptt | tail -2`
concatenate columns: paste
Paste together data by columns.
> tail -n+3 *ptt | cut -f1 > locs
> tail -n+3 *ptt | cut -f5 > genes
> paste genes locs genes | head
# sort by lines: sort
Industrial strength sorting command. Very powerful standalone and in combination with
others.
> sort genes | less # default sort
> sort -r genes | less # reverse
> sort -R genes | less # randomize
> cut -f2 *ptt | tail -n+4 | head
# uniquify lines: uniq
Useful command for analyzing any data with repeated elements. Best used in pipelines with
sort beforehand.
> cut -f2 *ptt | tail -n+4 | sort | uniq -c | sort -k1 -rn #
> cut -f3 *ptt | tail -n+4 | uniq -c | sort -k2 -rn # output number
> cut -f9 *ptt > products
> sort products | uniq -d
# line, word, character count: wc
Determine file sizes. Useful for debugging and confirmation, faster than nl if no intermediate
information is needed.
> wc *ptt # lines, words, bytes
> wc -l *ptt # only number of lines
> wc -L *ptt # longest line length, useful for apps like style checking
> `sudo apt-get update`
> `sudo apt-get install python-software-properties python g++ make`
> `sudo add-apt-repository ppa:chris-lea/node.js`
> `sudo apt-get update`
> `sudo apt-get install nodejs`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment