北京大学生物信息平台论坛

 找回密码
 立即注册
搜索
热搜: 通知 活动

Linux常用命令

[复制链接]
hec 发表于 2016-1-16 10:05:09 | 显示全部楼层 |阅读模式
将常用的命令做了个表,方便查询。
有一段时间将一些命令作为桌面
-----------------------------------------------------------------------------------


文件
ls -1ShtR
wc
grep  -v "\|\&" [grep -v *显示所有文件所有行,与非门;grep v 显示文件名]    zgrep
sed -r s/^/chr/ file::add string chr before the 1st column every raw
\
perl -ne
perl -lane '$F[1] = "cc$F[1]"; print join("\t",@F)' file:只能大写:add cc in front of the 2nd column every raw

let "I=$I-1"
declare -i I \n I=$I-1

sed -r 's/a/b/g'
sed -n '5,10p' filename
1.eval sed ’s/$a/$b/’ filename
2.sed "s/$a/$b/" filename
3.sed ’s/’$a’/’$b’/’ filename
4.sed s/$a/$b/ filename
sed -I 虽然不显示,但是会生成中间文件,需要考虑硬盘占用
rm -i `find ./ -size 0`
rmdir
cat <input file> > out,不在sh中用,否则会一起cat耗mem
split
touch
find -size +0c -name
du | df -Th
nohup cat `find -name "*.txt"|xargs ls ` >3.txt &
mv `find -name "*2*"`
for i in `ls`; do mv -f $i `echo $i | sed 's/.1././'`; done
find -size 0c -name
sort -t $'\t' -k 1n,1 -k 2n,2 -k4rn,4 <my-file>
diff文本文件,cmp二进制
sed 'n;d' file: delete even lines
find -name ""|xargs ls 当没有对应对象时,会ls整个目录
awk -F';' 'NR==FNR{a[$2]++;next}{c[$2]=($2 in a)?a[$2]:0;print $0";"c[$2]}' b a
rename 22 27 *

查询
man/ --help    man bash

软件
yum intall/list/update…
ls lsof fuser

语言
etc/profile    LANG=…

更新
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get purge
升级java:将网址添加到库中再在网上搜索
download the rpm and  rpm -ivh .rpm

用户
adduser/groupadd
passwd
STR="Hello World" echo ${#STR}
userdel -r test1
useradd -g test -d /home/test1 -s /etc/bash -m test1
chong   ALL=(ALL)       ALL======/etc/sudoers

网络
network(数据怎么走,IP门牌、网关路标、DNS域名、端口服务)
图形界面先turn on 任务栏处的网络开关
ping 127.0.0.1(这边有两根网线,一根用于远程控制,一根用于服务器,tcp协议栈)
ping  本机IP地址(ifconfig查看),网卡
ping 本机网关(route查看,default那行),路由器
检查DNS 服务器地址(cat /etc/resolv.conf)(单位通用DNS)
防火墙:service iptables stop
路由、直连|换网孔
traceroute
重启、重装网卡
alias serr='ssh serr@XXX.XXX.XXX.XX'
用笔记本连接网线得到IP/DNS
换网线、重置IP/DNS
可以ping通网关(DNS与网关一样会packet filtered)
339无线及有线动态获得新IP后ssh可以连接到新ip,不能连接到XXX.com域名
服务器不能Ping无线获得的Ip,但可以ping通有线获得的IP,且能wget 外网资源
将ip重新设置为200后,又能连接(路由那里将ip.200[不参与自动分配中]与XXX.com:22绑定),可能断后自动分配,过段时间又重新硬连接(1天后)
dhclient -r;dhclient
ifdown eth0;ifup eth0 是用静态IP地址
用静态IP后,DNS出错,不能连外网,用wget
连接路由
网页登录192.168.1.1
网页自动获取IP(静态IP不行)
查看不同机器本地IP
设置端口转发规则
外部31 内部均为22
ssh hec@XXX.XX.XXX.XX -p XX
Write failed: Broken pipe;/etc/ssh/sshd_config;ClientAliveInterval 60
ftp
wget -c -r
wget -c -r -nd -np -k -L -p -A c,h http目录/
sftp -P XX XX@XXX.XXX.XXX.XX
sftp> get -r folder
wget --timestamping  'ftp://xxx/*'

压缩/解压
zip/unzip .zip
tar -cx|z|f|v .tar.gz|tgz target
gzip/gunzip gz
tar jxv|f tar.bz2  
gunzip `find -name "*.gz"`
ar -x .deb
xz -d *.tar.xz
zcat/bzcat
md5sum file > md5.txt
md5sum -c md5.txt
bzip2 [-c/d]

屏幕
screen
tmux
ctrl+B " X
mkdir ~/.tmux
cd ~/.tmux
git clone https://github.com/tmux-plugins/tmux-continuum.git
echo run-shell ~/.tmux/tmux-continuum/continuum.tmux>~/.tmux.conf
set -g @continuum-save-interval '60'>>~/.tmux.conf
tmux source-file ~/.tmux.conf
ctrl+B d 后台;tmux attach恢复后台;alias:tmuxa
ctrl+B [----->pgup pgdn
vi /etc/sysconfig/network-scripts
service network restart
/etc/init.d/network start
ctrl+B s
ctrl+B t
ctrl+B alt+方向键
ln -s user/share/ s

重装
cp /etc 备份
yum install ssh
service sshd start
查看ip
fdisk -l
mkdir /dat
mkfs.xfs /dev/sdb
mount /dev/sdb /dat
cat /etc/fstab

系统
yum groupinstall "X Window System" -y
yum groupinstall "Desktop" -y
startx=======xinit: connection to X server lost
uname -a
lsb_release -a
sudo mount /dev/sdd media/Share
cat /proc/mounts
对所有用户/etc/profile||/etc/bashrc
visudo
chmod 700|u+/-w
umask 077
yum install openssl-devel
chown x:groung file
dmidecode |grep -A16 "System Information$"
dmidecode |grep -A16 "Memory Device$"
fdisk -l   smartctl -a /dev/sda
mii-tool
yum groupinstall "X Window System" -y
yum groupinstall "Desktop" -y
startx=======xinit: connection to X server lost
1、直接关电源
2、init   0
3、telinit   0
4、shutdown   -h   now
5、halt
6、poweroff
/var/log/messages
curl https://WWW.XXX.COM >Y
updatedb=======locate
cat /etc/issue
uname -a
cat /proc/cpuinfo
cat /proc/version
dmesg/lsmod

进程
ctrl+Z / nohup(终端) command &(当前后台)
jobs -l
fg l
top
| xargs
ps -ef
history
kill -15 1 2 3
strace -p
cpulimit -p 43777 -l 1000
iostat -d 2
pmap
nice,renince,ionice   ionice -c 3 -p `ps -ef|grep xx|grep -v "root"|awk '{print $2}'`
getrlimit, setrlimit, ulimit
/proc/sys/fs/file-max /etc/sysctl.conf /proc/sys/fs/file-nr /etc/security/limits.conf /ect/init.d/squid /etc/pam.d/logi
sync,echo 3 > /proc/sys/vm/drop_caches
pwd pwdx ls -l /proc/13456/cwd
i
><=字符串比较,整数比较 -lt -le -eq -ge -gt -ne
free -g -s 3
ps -eo pid,%mem,cmd --sort %mem
iotop
awk -F '\t' '{print NF-1}'
rm `llht|grep Dec|awk '{print $NF}'`
command1 & command2 & command3   run at the same time
command1; command2; command3 run the latter regardless of the return status of the former
command1 && command2 run the latter only when the former exit with success

变量
X=($A):A is spaced string, X is an array
X=$(command)
${#X} len of array X
${#X} len of string X
X=${X%A} cut A from tail of X
${X} (i-1)-th element  of array X  
LIST1=(`find -name "*.fq.gz"`)
"$*" is equivalent to "$1c$2c...",c: IFS variable.
$@ is equivalent to "$1" "$2" ...  
$[1+2]
n=`awk -v x=2.53 -v y=3.64 'BEGIN {printf "%.2f\n",x/y}'`
cat file| awk '{print NF}'
awk '{for(i=1;i<=5;i++)$i="";print}' file
list1=$(find -name "*.2.clean.fq.gz"|grep -v "A"|grep -v "E3")




桌面

桌面
回复

使用道具 举报

北京大学生物信息平台论坛

GMT+8, 2017-9-23 04:43 , Processed in 0.090214 second(s), 26 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表