关于shell的几个不为人知却十分有用的命令

最近一直在使用Linux操作系统,也熟知一些简单的命令,那么下面我将介绍几个不为人知却十分有用的命令:

1.mtr命令,查看mtr运行的主机和某个网站的直接网络连接,如下

mtr google.com

 显示一下内容

 
  1. My traceroute [v0.75]

  2. localhost.localdomain (0.0.0.0) Sun May 18 19:32:36 2014

  3. Keys: Help Display mode Restart statistics Order of fields quit

  4. Packets Pings

  5. Host Loss% Snt Last Avg Best Wrst StDev

  6. 1. 103.31.240.129 0.0% 42 0.5 0.5 0.5 0.6 0.0

  7. 2. 118.126.0.9 0.0% 42 0.3 0.3 0.2 0.4 0.0

  8. 3. 210.245.144.37 0.0% 42 2.9 3.6 2.9 22.1 3.0

  9. 4. 113.10.231.125 0.0% 42 3.1 3.8 2.7 40.2 5.8

  10. 5. irb9.10g-tc2.wpc.nwtgigalink.com 0.0% 42 2.9 3.1 2.9 5.1 0.4

  11. 6. ae2.10g-pp2.wpc.nwtgigalink.com 0.0% 42 3.2 3.0 2.9 3.2 0.1

  12. 7. google3-10G.hkix.net 0.0% 42 4.6 4.5 4.3 4.6 0.1

  13. 8. 209.85.248.62 0.0% 42 5.0 5.3 4.8 13.7 1.6

  14. 9. 209.85.241.171 0.0% 42 5.3 5.2 5.1 5.7 0.1

  15. 10. hkg03s16-in-f8.1e100.net 0.0% 41 4.8 4.9 4.7 5.0 0.1

 2.nl命令,给所查看的文本加上行号,如下

 
  1. cat a.log

  2. aa

  3.  
  4. nl a.log

  5. 1 aa

 3.shuf命令,随机从一个文件或者一个文件夹中选取行或者文件

 
  1. [root@localhost mwq]# ls | shuf -n1

  2. a.log

  3. [root@localhost mwq]# ls | shuf -n1

  4. a.log

  5. [root@localhost mwq]# ls | shuf -n1

  6. a.log

  7. [root@localhost mwq]# ls | shuf -n1

  8. 20140512.sql

  9. [root@localhost mwq]# ls | shuf -n1

  10. 20140512.sql

  11. [root@localhost mwq]# ls | shuf -n1

  12. a.log

  13. [root@localhost mwq]# vim a.log

  14. [root@localhost mwq]# cat a.log | shuf -n1

  15. aa

  16. [root@localhost mwq]# cat a.log | shuf -n1

  17. dd

  18. [root@localhost mwq]# cat a.log | shuf -n1

  19. aa

  20. [root@localhost mwq]# cat a.log | shuf -n1

  21. ff

 当然你也可以改变参数如cat a.log | shuf -n2获取两行内容。

4.last命令,查看上次登录或者登出的用户

 
  1. root pts/4 xxxxxxxxxxx Sun May 18 19:12 still logged in

  2. root pts/4 xxxxxxxxxxx Fri May 16 09:39 - 15:17 (05:38)

  3. root pts/4 xxxxxxxxxxx Wed May 14 17:13 - 18:01 (00:48)

  4. root pts/4 xxxxxxxxxxx Mon May 12 10:50 - 13:38 (02:47)

  5. root pts/4 xxxxxxxxxxx Mon May 12 10:48 - 10:50 (00:02)

  6. root pts/1 xxxxxxxxxxx Fri May 9 11:58 still logged in

 5.pstree以树的结构显示当前的进程节点

 
  1. init─┬─abrt-dump-oops

  2. ├─abrtd

  3. ├─acpid

  4. ├─atd

  5. ├─auditd───{auditd}

  6. ├─avahi-daemon───avahi-daemon

  7. ├─console-kit-dae───63*[{console-kit-da}]

  8. ├─crond

  9. ├─dbus-daemon───{dbus-daemon}

  10. ├─hald───hald-runner─┬─hald-addon-acpi

  11. │ └─hald-addon-inpu

  12. ├─irqbalance

  13. ├─java───330*[{java}]

  14. ├─master───qmgr

  15. ├─6*[mingetty]

  16. ├─mysqld_safe───mysqld───11*[{mysqld}]

  17. ├─rhsmcertd───rhsmcertd

  18. ├─rsyslogd───3*[{rsyslogd}]

  19. ├─sshd─┬─4*[sshd───bash]

  20. │ └─sshd───bash───pstree

  21. ├─stap-serverd

  22. ├─udevd───2*[udevd]

  23. └─vsftpd

 

好了,今天就先介绍这么多,稍后会继续。。。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值