Miscellaneous - Gig77/wiki GitHub Wiki

Kill all processes of certain user and name

ps -u <USER_ID> -o "%p,%c" | grep <PROCESS_NAME> | cut -f 1 -d "," | sudo xargs kill

Default space delimiter cannot be used because ps produces right-aligned output with varying number of spaces in front of process ID.

NFS setup

NFS server:

sudo apt-get install nfs-kernel-server nfs-common

Add directory to be shared to /etc/exports. The asterisk * will make this share accessible to all machines in the network:

/home/cf    *(rw,sync,no_subtree_check)

Restart NFS server:

sudo /etc/init.d/nfs-kernel-server restart

On the client, only install nfs-commons:

sudo apt-get install nfs-common

Then mount the share:

sudo mount biohazard:/ /mnt/biohazard

NFS user mapping

One easy (but insecure) way to get specific users mapped between NFS client and server is to set these users as nobody-user in /etc/idmapd.conf.

/etc/idmapd.conf (biowaste, server)

[Mapping]

Nobody-User = STANNANET\christian.frech
Nobody-Group = STANNANET\domänen-benutzer 

/etc/idmapd.conf (biohazard, client)

[Mapping]

Nobody-User = cf
Nobody-Group = cf

After changing idmapd.conf, restart the idmap daemon on both client and server:

sudo /etc/init.d/nfs-common restart

SSH

Include the following line in /etc/ssh/sshd_config to speed up slow ssh logins

UseDNS no

Download data from the European Genome-phenome Archive (EGA) using download streaming agent

https://www.ebi.ac.uk/ega/about/your_EGA_account/download_streaming_client

Download software

wget https://www.ebi.ac.uk/ega/sites/ebi.ac.uk.ega/files/documents/EGA_download_client_0.9.9.zip
unzip EGA_download_client_0.9.9.zip

See datasets we are allowed to download

java -jar EgaDemoClient.jar -p <email> <pwd> -ld

List files in dataset

java -jar EgaDemoClient.jar -p <email> <pwd> -lfd <EGADxxxxxxxx>

Request download of dataset

java -jar EgaDemoClient.jar -p <email> <pwd> -rfd <EGADxxxxxxxx> -re test -label <label>

Download dataset

java -jar EgaDemoClient.jar -p <email> <pwd> -path <target_directory> -dr <label>

Decrypt files

java -jar EgaDemoClient.jar -p <email> <pwd> --decrypt <file> -dck test

SSH login without password

According to http://www.linuxproblem.org/art_9.html

First log in on A as user a and generate a pair of authentication keys. Do not enter a passphrase:

a@A:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa): 
Created directory '/home/a/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A

Append new public key to b@B:.ssh/authorized_keys:

a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
b@B's password: 

From now on you can log into B as b from A as a without password:

a@A:~> ssh b@B

R: Get colored pathway from WikiPathways via SOAP

install.packages("SSOAP", repos = "http://www.omegahat.org/R", dependencies = TRUE, type = "source")
install.packages("RCurl")

library(SSOAP)
library(RCurl)
library(XML)

srv = SOAPServer("http://www.wikipathways.org/wpi/webservice/webservice.php");
reply = .SOAP(srv, "getColoredPathway", pwId="WP1842", revision="76861", graphId=c("f1419"), color=c("FF0000"), fileType="svg", action=I("getColoredPathway"), handlers=NULL)
svg <- base64Decode(xmlValue(getReturnNode(reply)))
writeLines(svg, "/home/christian/pathway.svg")

biomaRt: Gene symbol orthology mapping between human and mouse

library(biomaRt)
human = useMart(biomart="ENSEMBL_MART_ENSEMBL", host="feb2014.archive.ensembl.org", dataset="hsapiens_gene_ensembl") # GRCh37, v75
mouse = useMart(biomart="ENSEMBL_MART_ENSEMBL", host="feb2014.archive.ensembl.org", dataset="mmusculus_gene_ensembl") # GRCm38, v75
orthologs <- getLDS(attributes = c("mgi_symbol"), mart = mouse, attributesL = c("hgnc_symbol", "entrezgene"), martL = human)
⚠️ **GitHub.com Fallback** ⚠️