老李分享:《Linux Shell脚本攻略》 要点(七)下
2015-12-16 16:21
411 查看
4、磁盘可用情况 df = disk free
[root@localhost program_test]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 18G 2.5G 15G 16% /
tmpfs 504M 80K 504M 1% /dev/shm
/dev/sda1 291M 33M 244M 12% /boot
5、获取当前用户的相关信息 who、w
[root@localhost pts]# who
yxy tty1 2015-01-02 22:36 (:0)
yxy pts/1 2015-01-02 22:37 (:0.0)
yxy pts/2 2015-01-02 22:37 (192.168.119.1)
yxy pts/3 2015-01-02 22:37 (192.168.119.1)
[root@localhost pts]# w
23:19:38 up 46 min, 4 users, load average: 0.00, 0.02, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
6、提供系统登陆日志 last
[root@localhost pts]# last
ycy pts/0 192.168.119.1 Fri Jan 2 23:21 still logged in
7、获取登陆失败的回话信息 lastb //必须以超级管理员运行
[root@localhost pts]# lastb
centos ssh:notty 192.168.119.128 Fri Jan 2 22:59 - 22:59 (00:00)
centos ssh:notty 192.168.119.128 Fri Jan 2 22:59 - 22:59 (00:00)
centos ssh:notty 192.168.119.128 Fri Jan 2 22:59 - 22:59 (00:00)
8、统计最常用的10个命令
[root@localhost program_test]# cat top10_cmds.sh
#!/bin/bashprintf "COMMAND\t COUNT\n"cat ~/.bash_history | awk '{ list[$1]++ } \
END{
for(i in list)
{
printf("%s\t %d\n",i, list[i]); }
}' | sort -nrk 2 | head//执行结果如下:
[root@localhost program_test]# ./top10_cmds.sh
COMMAND COUNT
vi 88
find 82
[root@localhost 75
echo 72
cat 72
ls 65
ll 28
sh 25
seq 22
./word_freq.sh 21
[root@localhost program_test]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 18G 2.5G 15G 16% /
tmpfs 504M 80K 504M 1% /dev/shm
/dev/sda1 291M 33M 244M 12% /boot
5、获取当前用户的相关信息 who、w
[root@localhost pts]# who
yxy tty1 2015-01-02 22:36 (:0)
yxy pts/1 2015-01-02 22:37 (:0.0)
yxy pts/2 2015-01-02 22:37 (192.168.119.1)
yxy pts/3 2015-01-02 22:37 (192.168.119.1)
[root@localhost pts]# w
23:19:38 up 46 min, 4 users, load average: 0.00, 0.02, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
6、提供系统登陆日志 last
[root@localhost pts]# last
ycy pts/0 192.168.119.1 Fri Jan 2 23:21 still logged in
7、获取登陆失败的回话信息 lastb //必须以超级管理员运行
[root@localhost pts]# lastb
centos ssh:notty 192.168.119.128 Fri Jan 2 22:59 - 22:59 (00:00)
centos ssh:notty 192.168.119.128 Fri Jan 2 22:59 - 22:59 (00:00)
centos ssh:notty 192.168.119.128 Fri Jan 2 22:59 - 22:59 (00:00)
8、统计最常用的10个命令
[root@localhost program_test]# cat top10_cmds.sh
#!/bin/bashprintf "COMMAND\t COUNT\n"cat ~/.bash_history | awk '{ list[$1]++ } \
END{
for(i in list)
{
printf("%s\t %d\n",i, list[i]); }
}' | sort -nrk 2 | head//执行结果如下:
[root@localhost program_test]# ./top10_cmds.sh
COMMAND COUNT
vi 88
find 82
[root@localhost 75
echo 72
cat 72
ls 65
ll 28
sh 25
seq 22
./word_freq.sh 21
相关文章推荐
- 老李性能测试分享
- 你想不到:咖啡馆里上工具课
- 移动端自动化测试开课了
- 老李分享:什么是好战略
- 性能调优案例分享:Mysql的cpu过高
- 性能测试分享:性能测试工具开发的案例分享(上)
- 性能测试分享:性能测试工具开发的案例分享(下)
- 性能测试培训:批量执行Jmeter脚本之ant调用 2
- 性能测试培训:分布式测试之jmeter1
- 老李案例分享:MAT分析应用程序服务出现内存溢出过程1
- 老李案例分享:MAT分析应用程序服务出现内存溢出过程2
- 老李案例分享:定位JAVA内存溢出 1
- 老李案例分享:定位JAVA内存溢出 2
- 性能测试培训: 建立压力模型
- 老李分享:你知道有哪些持续集成工具
- 老李分享知识:性能测试之TPS和吞吐率
- 老李分享知识:性能测试之吞吐量
- 性能测试培训:分析内训泄露的案例
- 自动化测试培训:qtp脚本获取获取汇率数据
- 性能测试培训:sql server性能测试分析局部变量的性能影响1