-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLinuxCommand
More file actions
160 lines (133 loc) · 6.96 KB
/
LinuxCommand
File metadata and controls
160 lines (133 loc) · 6.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# Using Web Portal for visualization of single cell data
https://github.com/DoruMP/Fast-data-portals-for-scRNAseq-data
1. 通过百度配置好httpd apache
2. 服务器上/etc/httpd/conf/httpd.conf 通过listen 3838开放3838 端口(80端口被shiny占用了。。)
3. copy web_portal to /var/www/html
# using Apache/httpd + aria2c + aria2WebUI on cloud server for downloading
# using seafile on cloud server for file share
# checkSize.sh for Novogene
today=`date +"%Y%m%d"`
find -type f | xargs -n 1 -I {} bash -c 'size=`ls -l {} | cut -f 5 -d " "`; echo -e "$size\t{}"' > checkSize.${today}.xls
cat checkSize.xls >> checkSize.${today}.xls
cat checkSize.${today}.xls | sort | uniq -c
# Linux 中利用xargs -P 控制并发数下执行多任务
nohup ls *.mapped.sorted.bam | xargs -n 1 -I {} -P 7 bash -c 'file={};samAddTag.py -i $file -o ${file%.*}.tagged.bam' > nohup.log 2>&1 &
samtools sort -t CB -O BAM -o cellsorted_possorted_genome_bam.bam possorted_genome_bam.bam
nohup cat sample_data1.list | xargs -n 1 -I {} -P 1 bash -c 'velocyto run -b /home/Public/BioSoft/myutils/smartliu/96-8bp-barcode -o ./ -m /data1/Database/genome/fromTangLab/mm10/mm10_rmsk.gtf -u chr -@9 --samtools-memory 3000 /data1/users/lizc07/mouseEC_smarliu_part2/out_smartliu/mapping_to_refgene/{}.mapped.sorted.tagged.bam mm10_ERCC_RGC.refGene.velocyto.gtf' > velocyto_data1.log 2>&1 &
gtf issue: https://github.com/velocyto-team/velocyto.py/issues/117
use rtracklayer to solve it.
# UCSC RepeatMasker to GTF
# http://genome.ucsc.edu/cgi-bin/hgTables
# SEE describe table schema: Displays schema information for the tables associated with the selected track.
wget http://hgdownload.cse.ucsc.edu/goldenPath/hg38/database/rmsk.txt.gz
zcat rmsk.txt.gz | awk 'OFS="\t" {print $6,"rmsk",$12,$7+1,$8,".",$10,".","repName \""$11"\"; repFamily \""$13"\";"}' > rmsk.gtf
Jupyper
#在服务器上运行,搞清楚jupyter notebook的服务器的IP是多少
ifconfig | grep “inet addr"
#配置jupyter notebook
jupyter notebook --generate-config
echo "c.ConnectionFileMixin.ip = '0.0.0.0'" >> ~/.jupyter/jupyter_notebook_config.py #全0表示接受任何IP地址的访问(基于信任局域网使用人的前提)
echo "c.NotebookApp.ip = '0.0.0.0'" >> ~/.jupyter/jupyter_notebook_config.py
jupyter notebook
#执行上述命令,会在terminal看到http://0.0.0:8888/?token=xxxxxxx的提示
#打开浏览器上粘贴这个地址后,把0.0.0.0替换成服务器的IP地址即可。
# Rstudio Server port forward
nohup autossh -M 2005 -NR localhost:47283:localhost:47283 achen@123.57.43.237 > /home/achen/autossh.log
# 后台运行
sh run.sh && disown -a && exit
nohup sh run.sh &
# 特定r版本的conda环境创建
conda create -n r3.3.2 r=3.3.2
To activate this environment, use:
> source activate r3.3.2
To deactivate an active environment, use:
> source deactivate
#删除多个同级文件夹
cat sample | while read LINE; do for i in `seq 1 96`;do rm out_smartseq/$LINE/${LINE}_sc$i/tophat_out_refgene/ -r ;done; done
or
cat sample | while read LINE;
do
for i in `seq 1 96`;
do
rm out_smartseq/$LINE/${LINE}_sc$i/tophat_out_refgene/ -r ;
done;
done
#新增用户
useradd test
passwd test
#修改用户主目录,所在用户组
usermod -g Liulab Hazard
usermod -d /home/Hazard Hazard
#linux防火墙 iptables http://www.linuxidc.com/Linux/2012-03/56066.htm
vi /etc/sysconfig/iptables
开通端口3838和80的访问
-A INPUT -s 192.168.1.0/24 -p tcp -m tcp --dport 3838 -j ACCEPT
-A INPUT -s 192.168.1.0/24 -p tcp -m tcp --dport 80 -j ACCEPT
保存文件
先service iptables restart,然后调用/etc/rc.d/init.d/iptables save
下面介绍一些指令用法(主要还是man iptables看下相关资料才行)
-A:指定链名
-p:指定协议类型
-d:指定目标地址
--dport:指定目标端口(destination port 目的端口)
--sport:指定源端口(source port 源端口)
-j:指定动作类型
# linux CentOS 7.6+ 防火墙 firewalld
systemctl start firewalld.service
systemctl status firewalld.service
systemctl stop firewalld.service
firewall-cmd --state
firewall-cmd --zone=public --list-ports # 所有开放的端口
firewall-cmd --zone=public --add-port=xxxx/tcp --permanent #开放xxx端口
firewall-cmd --zone=public --remove-port=xxxx/tcp --permanent #移除xxx端口
firewall-cmd --reload # 配置立即生效
netstat -ntlp # 查看监听的端口
# 通过反向隧道访问局域网服务器(局域网服务器必须能联网)
内网主机A,公网主机B,以CentOS 7 为例
1. 公网主机配置/etc/ssh/sshd_config
`GatewayPorts yes` # 把监听端口绑定到任意IP,否则只能本机127.0.0.1可以访问
`AllowTcpForwading yes` # 允许sshd 转发tcp数据包
`sudo service sshd restart` 重启sshd服务
2. 内网主机安装 autossh
`yum install autossh`
3. 设置棉衣登陆,便于实现自动重连
`ssh-keygen` #执行,然后按回车(依次按下三次),生成免密的公钥和私钥
`ssh-copy-id user@ip_of_B` # 将密钥复制到公网主机B
# 或使用以下步骤实现
在局域网服务器A上执行ssh-keygen生成~/.ssh/id_rsa.pub文件(ssh-keygen -t rsa)
将生成的文件拷贝至外网服务器B上,然后cat id_rsa.pub >> ~/.ssh/authorized_keys
确认authorized_keys 文件的权限为-rw-------,否则执行chmod 600 ~/.ssh/authorized_keys (重要!!!)
4. 在局域网服务器A上执行以下命令
nohup autossh -M portA1 -NR portB1:localhost:portA2 userB@ipB -p portB2 > autossh.log 2>&1 &
portA1 可以为任意可用端口(1-65535)
portA2 是内外服务端口
portB1 是外网服务端口
portB2 是外网ssh端口
user@ipB 是外网主机
-M portA1 代表内网主机A的portA1端口监视SSH连接,出问题回自动重连
-N 代表不执行远程命令
-R 将远程主机的某个端口转发到本地主机的指定端口
portB1:localhost:portA2 是内外主机A的portA2端口转发至公网主机B的portB1端口上
-p portB2 是公网主机B的SSH端口,若是默认的22,则可省略
5. 访问ipB:portB1 即可访问内外ipA:portA2 下的服务内容。
6. 注意外网B的防火墙设置,将相关端口打开。以腾讯云服务器为例,可在控制台开放端口,无需在Linux系统配置。
例如:
nohup autossh -M 2018 -NR 8888:192.168.31.100:8888 userB@ipB > ./autossh.jupyter.txt &
??? 5. 在外网服务器B上执行 ssh -p portB1 userA@localhost 即可访问局域网服务器A
#kill 筛选出的多个线程
ps aux|grep 510|grep -v grep|awk '{print $2}'|xargs kill -9
###############
# git command #
###############
git init #不常用
git clone $url #克隆一个仓库
git status #查看本次历史操作
git commit -a -m "some message" #本地仓库的修改提交
git config --global user.email "youremail@email.com"
git config --global user.name "yourusername"
git remote
git push #提交至远端仓库,请确认无误后提交!!!
# 如果想完全回退到以前某一版本,连续使用以下命令
git reflog #查看历史git命令,找到目标版本的ID号,如"704639c"
git reset --hard 704639c
git push origin -f