1.vimdiff
[root@oldboylinux ~]# vimdiff a.txt  b.txt 
2 files to edit
- this is a text             |- this is a text
  ~                          |  ~                         
  ~                          |  ~                         
a.txt          1,1        All b.txt         1,1        All
"b.txt" 1L, 15C
- this is a text             |- this is a text
2.stat
[root@oldboylinux ~]# stat a.txt 
  File: `a.txt‘
  Size: 15              Blocks: 8          IO Block: 4096   regular file
Device: 803h/2051d      Inode: 26170       Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2015-10-08 08:25:31.738650958 +0800
Modify: 2015-10-08 08:25:15.865650899 +0800
Change: 2015-10-08 08:25:15.865650899 +0800
3.date
[root@oldboylinux ~]# date +%F
2015-10-08
[root@oldboylinux ~]# date --date=‘3 day ago‘(3天以前)
Mon Oct  5 11:27:26 CST 2015
[root@oldboylinux ~]# date -d ‘3 day ago‘(极简写法)
Mon Oct  5 11:27:52 CST 2015
[root@oldboylinux ~]# date +%F -d ‘-3 day‘    
2015-10-05
[root@oldboylinux ~]# date +%F -d ‘3 day‘ 
2015-10-11
[root@oldboylinux ~]# date +%F -d ‘+3 day‘
2015-10-11
4.linux快捷键使用
tab		命令补全工具
ctrl + a   切换到命令行开头
ctrl + e   切换到命令行末尾
ctrl + c    终止当前命令或脚本
ctrl + d	 退出当前shell,相当于exit。logout
ctrl + l	 清除屏幕内容,相当于clear。
ctrl + u    清除光标之前的内容(还有剪切板的功能)
ctrl + k	  清除光标之后的内容。
ctrl + y     复制剪切板的内容(如执行了ctrl + u后)
ctrl + h      类似于退格键(删除键)
ctrl + r       在命令中查找(非常好用,输入关键字就调出以前的命令了)
快捷键:ctrl + W
作用:清除左边的字段
快捷键:ctrl + Y
作用:将会贴上被ctrl + u或者ctrl + k或者ctrl + w清除的部分
快捷键:ctrl + L
作用:清除屏幕,相当于clean
快捷键:ctrl + c 或者ctrl +\
作用:杀死或者结束当前任务
快捷键:ctrl + D
作用:EOF即文件末尾(end-of-file)
快捷键:ctrl + z
作用:结束进程
快捷键:ctrl + A
作用:把光标移动到命令行最开始的地方
快捷键:ctrl + E
作用:把光标移动到命令行末尾。
快捷键:ctrl + U
作用:清除命令行中所处位置之前的所以字符。
快捷键:ctrl + s
作用:锁定屏幕
快捷键:ctrl + q
作用:解锁屏幕
5.time命令
查看一个命令执行时间
6.pgrep
pgrep 是通过程序的名字来查询进程的工具,一般是用来判断程序是否正在运行。在服务器的配置和管理中,这个工具常被应用,简单明了;
用法:
#pgrep 参数选项   程序名
常用参数
-l  列出程序名和进程ID;
 -o  进程起始的ID;
 -n  进程终止的ID;
举例:
[root@localhost ~]# pgrep -lo httpd
 4557 httpd
 [root@localhost ~]# pgrep -ln httpd
 4566 httpd
 [root@localhost ~]# pgrep -l httpd
 4557 httpd
 4560 httpd
 4561 httpd
 4562 httpd
 4563 httpd
 4564 httpd
 4565 httpd
 4566 httpd
 [root@localhost ~]# pgrep httpd
 4557
 4560
 4561
 4562
 4563
 4564
 4565
 4566
或者pidof
[root@localhost ~]#pidof  httpd
7.e2label 查看分区的卷标
例:使用fdisk -l 等到分区/dev/sda1
[root@localhost ~]# e2label /dev/sda1
/boot
8.tee高级用法:
tee本身命令就是将命令结果输出到屏幕,可用于检验某段输入的结果正确与否。
例:查看管道前执行结果,并用tee导入到文件。只需查看文件导入的结果即可。
[root@shellboy ~]# ps axo  %cpu,%mem,pid,comm | tee /root/a.txt | sort -rn | tee /root/b.txt | head 
10.0  0.9  65411 yumBackend.py
 7.9 10.7  12039 gnome-shell
 0.8  2.0  11482 Xorg
 0.6  0.2  65383 packagekitd
 0.1  0.4  12177 vmtoolsd
 0.1  0.2  65055 vncviewer
 0.1  0.1    795 vmtoolsd
 0.1  0.0  65388 nm-dispatcher.a
 0.1  0.0  65203 sshd
 0.1  0.0    138 rcuos/0
9、每5S运行一次
#!/bin/bash
while trun
do
ls -l /etc
sleep 5s
done
本文出自 “用心创造价值,晚点咖啡” 博客,请务必保留此出处http://wandiankafei.blog.51cto.com/10878910/1717966
原文地址:http://wandiankafei.blog.51cto.com/10878910/1717966