关于shell的几个不为人知却十分有用的命令分享
最近一直在使用Linux操作系统,也熟知一些简单的命令,那么下面我将介绍几个不为人知却十分有用的命令:
1.mtr命令,查看mtr运行的主机和某个网站的直接网络连接,如下
mtrgoogle.com
显示一下内容
Mytraceroute [v0.75] localhost.localdomain(0.0.0.0) SunMay1819:32:362014 Keys: Help Displaymode Restartstatistics Orderoffields quit Packets Pings Host Loss% Snt Last Avg Best WrstStDev 1.103.31.240.129 0.0% 42 0.5 0.5 0.5 0.6 0.0 2.118.126.0.9 0.0% 42 0.3 0.3 0.2 0.4 0.0 3.210.245.144.37 0.0% 42 2.9 3.6 2.9 22.1 3.0 4.113.10.231.125 0.0% 42 3.1 3.8 2.7 40.2 5.8 5.irb9.10g-tc2.wpc.nwtgigalink.com 0.0% 42 2.9 3.1 2.9 5.1 0.4 6.ae2.10g-pp2.wpc.nwtgigalink.com 0.0% 42 3.2 3.0 2.9 3.2 0.1 7.google3-10G.hkix.net 0.0% 42 4.6 4.5 4.3 4.6 0.1 8.209.85.248.62 0.0% 42 5.0 5.3 4.8 13.7 1.6 9.209.85.241.171 0.0% 42 5.3 5.2 5.1 5.7 0.1 10.hkg03s16-in-f8.1e100.net 0.0% 41 4.8 4.9 4.7 5.0 0.1
2.nl命令,给所查看的文本加上行号,如下
cata.log
aa
nla.log
1aa
3.shuf命令,随机从一个文件或者一个文件夹中选取行或者文件
[root@localhostmwq]#ls|shuf-n1 a.log [root@localhostmwq]#ls|shuf-n1 a.log [root@localhostmwq]#ls|shuf-n1 a.log [root@localhostmwq]#ls|shuf-n1 20140512.sql [root@localhostmwq]#ls|shuf-n1 20140512.sql [root@localhostmwq]#ls|shuf-n1 a.log [root@localhostmwq]#vima.log [root@localhostmwq]#cata.log|shuf-n1 aa [root@localhostmwq]#cata.log|shuf-n1 dd [root@localhostmwq]#cata.log|shuf-n1 aa [root@localhostmwq]#cata.log|shuf-n1 ff
当然你也可以改变参数如cata.log|shuf-n2获取两行内容。
4.last命令,查看上次登录或者登出的用户
root pts/4 xxxxxxxxxxx SunMay1819:12 stillloggedin root pts/4 xxxxxxxxxxx FriMay1609:39-15:17 (05:38) root pts/4 xxxxxxxxxxx WedMay1417:13-18:01 (00:48) root pts/4 xxxxxxxxxxx MonMay1210:50-13:38 (02:47) root pts/4 xxxxxxxxxxx MonMay1210:48-10:50 (00:02) root pts/1 xxxxxxxxxxx FriMay 911:58 stillloggedin
5.pstree以树的结构显示当前的进程节点
init─┬─abrt-dump-oops
├─abrtd
├─acpid
├─atd
├─auditd───{auditd}
├─avahi-daemon───avahi-daemon
├─console-kit-dae───63*[{console-kit-da}]
├─crond
├─dbus-daemon───{dbus-daemon}
├─hald───hald-runner─┬─hald-addon-acpi
│ └─hald-addon-inpu
├─irqbalance
├─java───330*[{java}]
├─master───qmgr
├─6*[mingetty]
├─mysqld_safe───mysqld───11*[{mysqld}]
├─rhsmcertd───rhsmcertd
├─rsyslogd───3*[{rsyslogd}]
├─sshd─┬─4*[sshd───bash]
│ └─sshd───bash───pstree
├─stap-serverd
├─udevd───2*[udevd]
└─vsftpd
好了,今天就先介绍这么多,稍后会继续。。。。