Advanced shell


1. Remote/cloud computing

1.1 ssh & keys

# examples
ssh -i ~/.ssh/replikation.pem ubuntu@ec2-11-218-160-32.us-east-2.compute.amazonaws.com
ssh -i ~/.ssh/azure_rsa student@13.45.57.169

1.2 file transfer

# examples
rsync -avp -e "ssh -i ~/.ssh/cloudgoogle" * replik@35.231.111.99:~/fast5_files
rsync -avpr -e "ssh -i ~/.ssh/cloudgoogle" <USER>@<IP>:~/auto_assembly/ .
# example for synology with different rsync path
# Username@IP is stored in $IP
rsync --rsync-path=/bin/rsync -vr -e "ssh -i ~/.ssh/id_rsa" --remove-source-files --include "*.fast5" --include "*/" --exclude "*" /cygdrive/c/data/reads/ $IP:/volume1/sequencing_data/
while true;
do
   rsync -vr --ignore-existing --bwlimit=3M --include "*.fast5" --include "*/" --exclude "*" /mnt/e/data/reads/20181205_1008_02WW /mnt/g/02.Schweden_WW
  sleep 5 ;
done

1.3 Transfer through a proxy

# A is the host so "."
# B(proxy) is e.g.:
PROXY="username@IP"
# C(server) is e.g.:
Server="username@IP"
#download fast5 files from server to host via proxy:
scp -r -oProxyJump=$PROXY $SERVER:/var/home/FAST5_files .
# it will now ask for both passwords (proxy and server)

2. Screen

virtual shell session in the cloud

screen -R <name> #name of the virtual machine
# works with tab completion after you started a virtual screen
screen -R <tab completion>

3. Advanced Scripting for deploying Software

4. mounting devices

# mount <name of disk> to <target>
sudo mount /dev/nvme1n1p1 /mnt/

5. Big file splitting

# tar a folder (-v for terminal status)
tar -cf archive.tar sequencing_read_folder/
  # alternatively with compression
  tar -czf archive.tar.gz sequencing_read_folder/

# split it into 10 GB chunks, alternatively -b 500M (500MB)
split -b 10G archive.tar "archive.tar.part"

# joining them together
cat archive.tar.part* > archive.tar

# extract it
tar -xf archive.tar sequencing_read_folder/
# pack split
tar -cvzf targetdir/ | split --bytes=10GB - archivname.tar.gz.
# combine unpack
cat archivname.tar.gz.* > archivname.tar.gz; tar -xvzf archivname.tar.gz -C /mnt/d/dir

5.1 other

tar -zc ./path | ssh remoteMachine "cat > ~/file.tar.gz"