Skip to content

Instantly share code, notes, and snippets.

@Phillip-a-richmond
Last active August 31, 2020 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Phillip-a-richmond/a22f4e967c1fd56235f77fbe1c7936f8 to your computer and use it in GitHub Desktop.
Save Phillip-a-richmond/a22f4e967c1fd56235f77fbe1c7936f8 to your computer and use it in GitHub Desktop.
# Session Commands
# Actual commands from Session1 (green text)
#ssh wc-guest01@orcinus.westgrid.ca
pwd
cd /global/scratch/EOT_Tutorials/
ls /global/scratch/EOT_Tutorials/
mkdir /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND
cd ./IntroToLinux/RICHMOND
cd /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/
pwd
cd ../
pwd
ls
cd ./RICHMOND
pwd
cp /global/scratch/EOT_Tutorials/IntroToLinux/Files/genes.gtf /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/
ls -l -h /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes.gtf
chmod ugo=rwx /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes.gtf
ls -lhtr /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes.gtf
more /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes.gtf
less /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes.gtf
head /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes.gtf
tail /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes.gtf
#cat /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes.gtf
head /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes.gtf
head /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes.gtf > /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/SomeLines.gtf
rm /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/SomeLines.gtf
grep “PAX6” /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes.gtf
grep “PAX6” /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes.gtf > /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/PAX6.gtf
wc /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/PAX6.gtf
man wc
wget ftp://ftp.ncbi.nlm.nih.gov/pub/clinvar/tab_delimited/variant_summary.txt.gz
gunzip ftp://ftp.ncbi.nlm.nih.gov/pub/clinvar/tab_delimited/variant_summary.txt.gz
gzip /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/variant_summary.txt.gz
ls /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/
cd /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/
cp PAX6.gtf PAX6_hg19.gtf
more genes.gtf
chmod ugo=rwx PAX6.gtf
grep “CDS” PAX6.gtf
exit
# Detail on the commands
# Print Working Directory (pwd)
pwd
# Change Directory (cd)
## Basic
cd <filepath>
cd /global/scratch/EOT_Tutorials/IntroToLinux/
## Up a directory in the filesystem
cd ../
## To a relative directory
cd ./Session1/
## To your home directory
cd ~
# or just type cd alone
cd
# Make a directory (mkdir)
mkdir /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/
# Move File (mv)
## Basic
### mv <filepath1> <filepath2>
mv /home/richmonp/test.txt /global/scratch/EOT_Tutorials/IntroToLinux/Files/test.txt
## Rename file
### mv <filepath1> <filepath2>
mv /home/richmonp/test.txt /home/richmonp/ABetterName.txt
# Copy File (cp)
## Basic
### cp <filepath1> <filepath2>
cp /global/scratch/EOT_Tutorials/IntroToLinux/Files/genes.gtf /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/
## Copy and rename
### cp <filepath1> <filepath2>
cp /global/scratch/EOT_Tutorials/IntroToLinux/Files/genes.gtf /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes_hg38.gtf
## Copy a Directory
### cp -r <filepath1> <filepath2>
cp -r /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/ /global/scratch/EOT_Tutorials/IntroToLinux/Problemset/
# List (ls)
## Basic
### ls <filepath>
ls /global/scratch/EOT_Tutorials/IntroToLinux/
## Add options for -h (human readable), -l (long listing), -t (sort by time), -r (reverse order)
ls -lhtr /global/scratch/EOT_Tutorials/IntroToLinux/genes.gtf
# Change permissions (chmod)
## Basic
### chmod ugo=rwx <filepath>
chmod ugo=rwx /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes.gtf
## On everything in a directory
### chmod ugo=rwx -R <filepath>
chmod ugo=rwx -R /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/
## Only give yourself access, let the world read it though
### chmod u=rwx,go=r <filepath>
chmod u=rwx,go=r /global/scratch/EOT_Tutorials/IntroToLinux/
## Only give yourself access, let them have nothing
### chmod u=rwx,go=- <filepath>
chmod u=rwx,go=- /global/scratch/EOT_Tutorials/IntroToLinux/
# Exploring File Contents (more)
# more <filepath>
more /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes.gtf
# Exploring File Contents (less)
### less <filepath>
less /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes.gtf
# Print top of file to stdout (head)
## Basic
### head <filepath>
head /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes.gtf
## Specify number of lines
### head -n 100 <filepath>
head -n 100 /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes.gtf
# Print bottom of file to stdout (tail)
### tail <filepath>
$ tail /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes.gtf
# Print whole file to stdout (cat)
### cat <filepath>
$ cat /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes.gtf
# Capture Standard Out
## Basic (head example)
### <command> > <filepath>
head /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes.gtf > /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/SomeLines.gtf
# Remove/Delete a file
## Basic
### rm <file>
rm /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/SomeLines.gtf
## Everything in a directory (CAREFUL)
### rm -r <filepath>
rm -r /global/scratch/EOT_Tutorials/IntroToLinux/BeCarefulWithThisCommand/
# Grab regular expression (grep)
## Basic
### grep <pattern> <filepath>
grep "PAX6" /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes.gtf
## Basic with capture
### grep <pattern> <filepath> > <filepath>
grep "PAX6" /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes.gtf > /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/PAX6.gtf
## Matching just the word
grep -w "PAX6" /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes.gtf
## Inverted matching, return all non-matches
grep -v "PAX6" /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/genes.gtf
# Word Count (wc)
## Basic
### wc <filepath>
wc /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/PAX6.gtf
## Just lines
### wc -l <filepath>
wc -l /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/PAX6.gtf
# Manual (man)
## Basic
### man <command>
man wc
# Web Get (wget)
## Basic
### wget <URL>
wget ftp://ftp.ncbi.nlm.nih.gov/pub/clinvar/tab_delimited/variant_summary.txt.gz
# G-unzip (gunzip)
## Basic
### gunzip <filepath>
gunzip ftp://ftp.ncbi.nlm.nih.gov/pub/clinvar/tab_delimited/variant_summary.txt.gz
## Keep compressed file
### gunzip -c <filepath> > <outfilepath>
gunzip -c /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/variant_summary.txt.gz > /global/scratch/EOT_Tutorials/IntroToLinux/RICHMOND/variant_summary.txt
# Cut/Extract columns from a delimited file
## Basic
### cut -f#,# <filename>
cut -f 1,4,5 GRN.gtf > GRN.bed
# Echo (echo)
echo "Just a test file, made with the echo command" > /home/richmonp/test.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment