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/bash
printf "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
转载于:https://blog.51cto.com/10988776/1725257