命令目录

文本处理类
cut-split-paste-cat-tee-grep-info-top-pidof-setterm

网络工具类
ss-netstat-ping-dig-traceroute-nc-ip-tcpdump
进程类
lsof-fuser-ps-top
文件系统类
fsck-dumpe2fs-tune2fs-resize2fs-lsattr-chattr
硬盘检测类
hdparm-badblocks-smartctl
性能分析类
iostat(i/o)-vmstat(内存)-free-uptime-sar-mpstat(cpu)
性能调优类
sysctl-ulimit
流量监视类
iptraf-nload-iftop

网络安全类
ntop-nmap-nc
http://blog.csdn.net/aspirationflow/article/details/7694274

以下内容是通过阅读info文档而来的,收获是阅读英文文档,可以清楚明白很多细节。
[root@250-shiyan frag]# info coreutils "cut"
cut 
-b|-c     可以认为是一样的
-f    字段
-d    分隔符
Bytes, characters, and fields are numbered starting at 1.
[root@250-shiyan frag]# cat eth.sh
#!/bin/bash
while [ 1 -gt 0 ]
 do
 eth=`ifconfig eth0|grep "TX bytes"|gawk '{print $6}'|cut -d ":" -f2`
 echo $eth >> /root/sh/jj
 sleep 2
 done
[root@250-shiyan frag]# cut -c5-8 eth.sh
in/b
e [

=`if
o $e
ep 2
e
[root@250-shiyan frag]# cut -c5,8 eth.sh
ib
e

=f
oe
e2
e
[root@250-shiyan frag]# cut -c5,8 eth.sh --output-delimiter=" "
i b
e

= f
o e
e 2
e
[root@250-shiyan frag]# cut -c-8 eth.sh
#!/bin/b
while [
 do
 eth=`if
 echo $e
 sleep 2
 done
[root@250-shiyan frag]# cut -c8- eth.sh
bash
 1 -gt 0 ]

fconfig eth0|grep "TX bytes"|gawk '{print $6}'|cut -d ":" -f2`
eth >> /root/sh/jj
2

默认以tab为分隔符,如果没有默认也没有指定分隔符,则打印整行。如果需要其它,则用-d指定。
Fields are separated by a TAB character by default.  Also print any line that contains no delimiter character, unless the `--only-delimited' (`-s') option is specified
[root@250-shiyan frag]# cat >aa
wo      iej     iiii
 jo eif oef     wowp
kdfjdf fsjksjd sdkf
[root@250-shiyan frag]# cut -f2 aa
iej
oef
kdfjdf fsjksjd sdkf
不打印没有分隔符的行。
[root@250-shiyan frag]# cut -f2 aa -s
iej
oef
[root@250-shiyan frag]# info coreutils "paste"
paste把由每一个给定文件对应行顺序组成的新行写到标准输出上,默认用tab分隔
[root@250-shiyan frag]# cat > a
11
12
13
14
15
[root@250-shiyan frag]# cat > b
1
2
3
4
5
[root@250-shiyan frag]# paste a b
11      1
12      2
13      3
14      4
15      5
[root@250-shiyan frag]# paste a b -s
11      12      13      14      15
1       2       3       4       5
[root@250-shiyan frag]# paste a b a -d '%_'
11%1_11
12%2_12
13%3_13
14%4_14
15%5_15
split切分一个文件为多个小文件,可以按字节与行数来切分

先转换格式
dos2unix datasource.properties
再将原文件进行一下归整,让a这个文件是一些重复的块
grep -A 14 ^# datasource.properties >a
再以16行为一个块切分
split -l16 a

[root@my pie]# cat a
#common database config
base.driverClassName=com.mysql.jdbc.Driver

base.url=jdbc:mysql://192.168.1.248:3306/basedata?useUnicode=true&characterEncoding=utf-8

base.username=root
base.password=xxxxxxx
base.initialSize=3
base.maxActive=5
base.sleepTime=100
base.lifeTime=10
base.deadLockMaxWait=50
base.deadLockRetryWait=3
base.validationQuery=select * from tb_sequence limit 0,1
base.checkLevelObject=1
--
#common database config
common.driverClassName=com.mysql.jdbc.Driver

common.url=jdbc:mysql://192.168.1.248:3306/spcommon?useUnicode=true&characterEncoding=utf-8

common.username=root
common.password=xxxxxxxxxxx
common.initialSize=3
common.maxActive=5
common.sleepTime=100
common.lifeTime=10
common.deadLockMaxWait=50
common.deadLockRetryWait=3
common.validationQuery=select * from tb_sequence limit 0,1
common.checkLevelObject=1
--


[root@my pie]# ll
total 36
-rw-r--r--. 1 root root 3036 Apr  7 05:02 a
-rw-r--r--. 1 root root 3182 Apr  7 04:37 datasource.properties
-rw-r--r--. 1 root root  411 Apr  7 05:08 xaa
-rw-r--r--. 1 root root  435 Apr  7 05:08 xab
-rw-r--r--. 1 root root  448 Apr  7 05:08 xac
-rw-r--r--. 1 root root  440 Apr  7 05:08 xad
-rw-r--r--. 1 root root  437 Apr  7 05:08 xae
-rw-r--r--. 1 root root  409 Apr  7 05:08 xaf
-rw-r--r--. 1 root root  456 Apr  7 05:08 xag


[root@my pie]# cat xag
#common database config
supplier.driverClassName=com.mysql.jdbc.Driver

supplier.url=jdbc:mysql://192.168.1.248:3306/supplier?useUnicode=true&characterEncoding=utf-8

supplier.username=root
supplier.password=xxxxxxxx
supplier.initialSize=3
supplier.maxActive=5
supplier.sleepTime=100
supplier.lifeTime=10
supplier.deadLockMaxWait=50
supplier.deadLockRetryWait=3
supplier.validationQuery=select * from tb_sequence limit 0,1
supplier.checkLevelObject=1
[root@my pie]#
cat    Concatenate(连接) and write files
cat拷贝每个文件或标准输入到标准输出
####-b 不标号空行
[root@250-shiyan cmd]# cat -b log.sample
     1  # rsyslog v5 configuration file

     2  # For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html
     3  # If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html

     4  #### MODULES ####
####-s 将多个连续空行压缩为一个
[root@250-shiyan cmd]# cat -n log.sample
     1  # rsyslog v5 configuration file
     2
     3
     4
     5  # For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html
     6  # If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html
     7
     8
     9  #### MODULES ####
[root@250-shiyan cmd]# cat -ns log.sample
     1  # rsyslog v5 configuration file
     2
     3  # For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html
     4  # If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html
     5
     6  #### MODULES ####
[root@250-shiyan cmd]# cat -A aa.sample
wo^Iiej^Iiiii$
 jo eif^Ioef^Iwowp$
kdfjdf fsjksjd sdkf$
[root@web ~]# echo 12345 | tee
12345
[root@web ~]# echo 12345 | tee -
12345
12345
[root@web ~]# echo 12345 | tee - -
12345
12345
12345
[root@web ~]# echo -n 12345 | tee
12345[root@web ~]# echo -n 12345 | tee -
1234512345[root@web ~]# echo -n 12345 | tee - -
123451234512345[root@web ~]# echo -n 12345 | tee - - -
12345123451234512345[root@web ~]# echo -n 12345 | tee - - - -
1234512345123451234512345[root@web ~]# 

####标准输出一次
tee
tee file
####屏幕一次,文件一次
tee -a file
####标准输出二次
tee -
####标准输出二次,同时保存到文件中
tee file1 file2 -

示例一 tee命令与重定向的对比
[root@web ~]# seq 5 >1.txt
[root@web ~]# cat 1.txt
1
2
3
4
5
[root@web ~]# cat 1.txt >2.txt
[root@web ~]# cat 1.txt | tee 3.txt 

示例三 使用tee命令把标准错误输出也保存到文件
[root@web ~]# ls "*"
ls: *: 没有那个文件或目录
[root@web ~]# ls "*" | tee -
ls: *: 没有那个文件或目录
[root@web ~]# ls "*" | tee ls.txt
ls: *: 没有那个文件或目录
[root@web ~]# cat ls.txt
[root@web ~]# ls "*" 2>&1 | tee ls.txt
ls: *: 没有那个文件或目录
[root@web ~]# cat ls.txt
ls: *: 没有那个文件或目录
[root@web ~]#
BRE
^ 行首
$ 行尾
. 任意单个字符
转义
* 前面的字符重复0到多次
[] 匹配其中之一
[0-9a-z] 匹配范围
[^a] 匹配非a
< 单词开头
> 单词结尾
{2,3} 前面的字符重复2,3次

ERE
+
?
|
()

grep 一般情况下支持基本正则表达式,可以通过参数-E支持扩展正则表达式,另外grep单独提供了一个扩展命令叫做egrep用来支持扩展正则表达式,这条命 令和grep -E等价。虽然一般情况下,基本正则表达式就够用了。特殊情况下,复杂的扩展表达式,可以简化字符串的匹配。
扩展正则表达式就是在基本正则表达式的基础上,增加了一些元数据。
`grep' searches the input files for lines containing a match to a given pattern list.
grep 在输入文件里搜索给定模式在行里的匹配
 When it finds a match in a line, it copies the line to standard output (by default), or produces whatever other sort of output you have requested with options.

GREP 是 Global Regular Expression Print 的缩写
1.grep是一个搜索程序,它只能搜索匹配一个正则表达式的一行的存在性. 2.grep可以对一行采取唯一的动作是把它发送到标准输出. 如果该行不匹配正则表达式,则其不被打印. 3.行的选择只基于正则表达式. 行编号或其他准则不能用于选择行. 4.grep是一个过滤器. 它可用在管道的左边或右边. 5.grep不能用于增加,删除或修改行,只用于打印。 6.grep不能用于只打印行的一部分. 7.grep不能只读取文件的一部分. 8.grep不能基于前面的内容或下一行来选择一行.只有一个缓冲区,它只保存当前行. 匹配特殊字符,查询有特殊含义的字符,诸如$ .‘ ” * [] ^ | + ? ,必须在特定字符前加。 [root@250-shiyan grep]# cp /usr/include/fstab.h ./ [root@250-shiyan grep]# ls a.grep fstab.h [root@250-shiyan grep]# pwd /root/sh/grep [root@250-shiyan grep]# cat a.grep ####有时模式匹配的双引号可以不加,但一般加上,选项可前可后 ####单个文件里 grep "fstab" fstab.h -c echo "---------------------------------------------------" grep "fstab" fstab.h --color echo "---------------------------------------------------" grep "fstab" fstab.h --color -i echo "---------------------------------------------------" grep "fstab" fstab.h --color -on echo "-----------------------------------------" grep -f pattern.txt -bn --color fstab.h echo "-------------------------------------" grep "fstab" fstab.h -nx --color echo "-------------------------------------" ####多个文件及递归 grep -bn --color "for" aa ab grep -bn --color "for" * grep -rn --color "for" * ####列出匹配的文件名,查询多文件时只输出包含匹配字符的文件名。 grep -l --color for * ####列出不匹配的文件名 grep -L --color for * ####与上面的正好相反,不打印文件名,查询多文件时不显示文件名。 grep -hn --color for * ####列出单词for,而不是包含for的所有行 grep -w --color for * grep -A 1 FAILED  匹配及其后一行 grep -B 1 FAILED  匹配及其前一行 grep -C 1 FAILED  匹配及其前后各一行 grep "<80>"    精确匹配80,而不是8005或808都匹配,

匹配四组Failed字符串
grep -m 4 Failed catalina.out >a
只匹配一组后10行
grep -m 1 -A 10 Failed catalina.out >a
只匹配Failed字符串
grep -o Failed catalina.out >a
记录行号
grep -n -o Failed catalina.out >a
后面10行,分隔符为--
grep -A 10 Failed catalina.out >a
默认组分隔符是--
grep --group-separator=?????????????? -A 10 Failed catalina.out >a
info命令
x Close this help window. q Quit Info altogether. H Invoke the Info tutorial. TAB Skip to the next hypertext link. 上一次看到的屏,跳跃
b       (beginning-of-node)             Move to the start of this node
e       (end-of-node)                   Move to the end of this node l Go back to the
last node seen in this window. 前一个节点,顺序 [ Go to the previous node in the document. 后一个节点,顺序 ] Go to the next node in the document. 前一个子目录 p Go to the previous node on this level. 后一个子目录 n Go to the next node on this level. 一层一层往上返 u Go up one level. 到本文档的根 t Go to the top node of this document. 到根 d Go to the main `directory' node.
数字对应菜单项 1...9 Pick the first...ninth item in this node's menu.

top命令
字段解释:
  PID:进程的ID
  USER:进程所有者
  PR:进程的优先级别,越小越优先被执行
  NInice:值
  VIRT:进程占用的虚拟内存
  RES:进程占用的物理内存
  SHR:进程使用的共享内存
  S:进程的状态。S表示休眠,R表示正在运行,Z表示僵死状态,N表示该进程优先值为负数
  %CPU:进程占用CPU的使用率
  %MEM:进程使用的物理内存和总内存的百分比
  TIME+:该进程启动后占用的总的CPU时间,即占用CPU使用时间的累加值。
  COMMAND:进程启动命令名称
  
子命令:
  P:按%CPU使用率排行
  T:按TIME+排行
  M:按%MEM排行
字段:
f 选择字段  选择显示列:执行top命令后,按 f 键,再按某一列的代表字母,即可选中或取消显示;
o 排序字段  列显示位置调整:执行top命令后,按 o 键,选择要调整位置的列(如K:CUP Usageage),按动一下大写K则显示位置往上调整,按动一下小写K则显示位置往下调整。
F或者O 列排序   执行top命令后,按 shift + f(小写)或o(小写),二者等同。进入选择排序列页面,再按要排序的列的代表字母即可;
排序,默认是按cpu排序,>左移一列排序,shift+r反向,<右移一列排序。

只显示asterisk及其线程的top显示。
top -H -p `pidof asterisk`
#basename /usr/bin/awk
awk
#dirname /usr/bin/basename
/usr/bin
yum install elinks
text www browser

elinks快捷键

上,当前页前一链接
下,当前页后一链接
左,前一页
右,进入当前链接
insert,delete,当前页前后滚动
{,},当前页左右滚动
home,end,当前页的开头与最后
\,在html与plain间切换
g,G指定地址
q,退出elinks
=,当前页信息
|,http header信息
/,?,n,N,当前页进行模式搜索
d,下载当前链接
t,新建一个标签,c关闭标签,>下一个标签,<上一个标签
原文地址:https://www.cnblogs.com/createyuan/p/4260124.html