Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the unknown but useful commands in shell

Shulou Source: shulou.com Published: 2022-06-03 13:04:28 11月14日 Update

This article mainly introduces the unknown but very useful commands in shell. It is very detailed and has a certain reference value. Friends who are interested must finish reading it!

I've been using the Linux operating system recently, and I'm familiar with some simple commands, so here are a few little-known but useful commands:

1.mtr command to view the direct network connection between the host running mtr and a website, as follows

Mtr google.com

Show the content.

My traceroute [v0.75]

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

Keys: Help Display mode Restart statistics Order of fields quit

Packets Pings

Host Loss% Snt Last Avg Best Wrst StDev

1. 103.31.240.129 0.0% 42 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 command to add a line number to the viewed text, as follows

Cat a.log

Aa

Nl a.log

1 aa

3.shuf command to randomly select a line or file from a file or a folder

[root@localhost mwq] # ls | shuf-N1

A.log

[root@localhost mwq] # ls | shuf-N1

A.log

[root@localhost mwq] # ls | shuf-N1

A.log

[root@localhost mwq] # ls | shuf-N1

20140512.sql

[root@localhost mwq] # ls | shuf-N1

20140512.sql

[root@localhost mwq] # ls | shuf-N1

A.log

[root@localhost mwq] # vim a.log

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

Aa

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

Dd

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

Aa

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

Ff

Of course, you can also change the parameters such as cat a.log | shuf-N2 to get two lines.

4.last command to view the last logged-in or logged-out user

Root pts/4 xxxxxxxxxxx Sun May 18 19:12 still logged in

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

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

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

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

Root pts/1 xxxxxxxxxxx Fri May 9 11:58 still logged in

5.pstree displays the current process node in a tree structure

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

The above is all the contents of the article "what are the unknown but useful commands in shell". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Commands content unknown useful files articles operating systems hosts values interests parameters guys partners folders text more users knowledge systems structures Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Tech Info Shulou Technology OPPO Reno Docker