自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

10個你從未用過的Linux命令

系統 Linux
也許需要幾年甚至是幾十年,才能真正掌握Linux shell 命令。這里有10個你從來沒有聽說或使用過的命令。他們在沒有特定的順序。我最喜歡的是mkfifo。

 這也許需要幾年甚至是幾十年,才能真正掌握Linux shell 命令。這里有10個你從來沒有聽說或使用過的命令。他們在沒有特定的順序。我最喜歡的是mkfifo。

1、pgrep, 替代:

# ps -ef | egrep '^root ' | awk '{print $2}'
1
2
3
4
5
20
21
38

39

...

你還可以這樣:

# pgrep -u root
1
2
3
4
5
20
21
38
39
...

2、pstree,在tree 格式中列出進程,當有webSphere或重任務應用時非常有用。

# pstree
init-+-acpid
|-atd
|-crond
|-cups-config-dae
|-cupsd
|-dbus-daemon-1
|-dhclient
|-events/0-+-aio/0
| |-kacpid
| |-kauditd
| |-kblockd/0
| |-khelper
| |-kmirrord
| `-2*[pdflush]
|-gpm
|-hald
|-khubd
|-2*[kjournald]
|-klogd
|-kseriod
|-ksoftirqd/0
|-kswapd0
|-login---bash
|-5*[mingetty]
|-portmap
|-rpc.idmapd
|-rpc.statd
|-2*[sendmail]
|-smartd
|-sshd---sshd---bash---pstree
|-syslogd
|-udevd
|-vsftpd
|-xfs
`-xinetd

3、bc 是個任意精度計算器語言,它可以Shell腳本執(zhí)行平方根操作,expr 不支持平方根。

# ./sqrt
Usage: sqrt number
# ./sqrt 64
8
# ./sqrt 132112
363
# ./sqrt 1321121321
36347
Here is the script:
# cat sqrt
#!/bin/bash
if [ $# -ne 1 ]
then
echo 'Usage: sqrt number'
exit 1
else
echo -e "sqrt($1)\nquit\n" | bc -q -i
fi

4、split, 你需要將大的文件分解稱若干小部分?

split是你的命令,下面是將250MB文件分解為2M的塊兒,所有開始于LF_前綴。

 

# ls -lh largefile
-rw-r--r-- 1 root root 251M Feb 19 10:27 largefile
# split -b 2m largefile LF_
# ls -lh LF_* | head -n 5
-rw-r--r-- 1 root root 2.0M Feb 19 10:29 LF_aa
-rw-r--r-- 1 root root 2.0M Feb 19 10:29 LF_ab
-rw-r--r-- 1 root root 2.0M Feb 19 10:29 LF_ac
-rw-r--r-- 1 root root 2.0M Feb 19 10:29 LF_ad
-rw-r--r-- 1 root root 2.0M Feb 19 10:29 LF_ae
# ls -lh LF_* | wc -l
126

 

5、nl 數字線,在沒發(fā)現nl之前,一直用腳本來實現。

# head wireless.h
/*
* This file define a set of standard wireless extensions
*
* Version : 20 17.2.06
*
* Authors : Jean Tourrilhes - HPL
* Copyright (c) 1997-2006 Jean Tourrilhes, All Rights Reserved.
*/#ifndef _LINUX_WIRELESS_H
# nl wireless.h | head
1 /*
2 * This file define a set of standard wireless extensions
3 *
4 * Version : 20 17.2.06
5 *
6 * Authors : Jean Tourrilhes - HPL
7 * Copyright (c) 1997-2006 Jean Tourrilhes, All Rights Reserved.
8 */9 #ifndef _LINUX_WIRELESS_H

#p#

6、mkfifo 是最酷的一個,你一定知道如何創(chuàng)建管道 輸送grep的結果到LESS,可能甚至perl。

但是你知道如何使2個命令通過1個命名管道溝通?看下圖,創(chuàng)建管道,開始寫到它。

mkfifo pipe; tail file > pipe

然后讀取它:

cat pipe

 

7、ldd, 想知道java鏈接到哪個Linux線程庫?

# ldd /usr/java/jre1.5.0_11/bin/java
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x00bd4000)
libdl.so.2 => /lib/libdl.so.2 (0x00b87000)
libc.so.6 => /lib/tls/libc.so.6 (0x00a5a000)
/lib/ld-linux.so.2 (0x00a3c000)

8、col, 想保存幫助頁面為純文本?

# PAGER=cat
# man less | col -b > less.txt

9、xmlwf, 需要知道一個XML文檔或許是配置文件是否合理?

# curl -s 'http://bashcurescancer.com' > bcc.html
# xmlwf bcc.html
# perl -i -pe 's@<br/>@<br/>@g' bcc.html
# xmlwf bcc.html
bcc.html:104:2: mismatched tag

10、lsof 列出打開文件,你可以用它做很多很cool的事情,比如查找哪個接口是開放的?

# lsof | grep TCP
portmap 2587 rpc 4u IPv4 5544 TCP *:sunrpc (LISTEN)
rpc.statd 2606 root 6u IPv4 5585 TCP *:668 (LISTEN)
sshd 2788 root 3u IPv6 5991 TCP *:ssh (LISTEN)
sendmail 2843 root 4u IPv4 6160 TCP badhd:smtp (LISTEN)
vsftpd 9337 root 3u IPv4 34949 TCP *:ftp (LISTEN)
cupsd 16459 root 0u IPv4 41061 TCP badhd:ipp (LISTEN)
sshd 16892 root 3u IPv6 61003 TCP badhd.mshome.net:ssh->kontiki.mshome.net:4661 (ESTABLISHED)
Note: OpenBSD 101 pointed out that “lsof -i TCP” a better way to obtain this same information. Thanks!Or find the number of open files a user has. Very important for running big applications like Oracle, DB2, or WebSphere:
# lsof | grep ' root ' | awk '{print $NF}' | sort | uniq | wc -l
179

提示,匿名評論者指出應該用“sort -u”代替sort | uniq,本人忘記了-u flag,謝謝!

原文:http://www.oschina.net/news/19435/10-linux-commands-youve-never-used

英文原文:http://bashcurescancer.com/10-linux-commands-youve-never-used.html

【編輯推薦】

  1. 五個不容錯過的Linux命令行技巧
  2. 六個鮮為人知的超酷Unix/Linux命令
  3. Linux命令行閉關修煉札記
責任編輯:黃丹 來源: oschina.net
相關推薦

2009-06-02 10:49:32

思科路由器交換機

2015-12-25 10:58:20

WiFi政府

2023-11-24 13:00:32

2022-10-17 15:47:19

JavaScript開發(fā)Web

2020-03-19 19:00:01

Linux命令

2009-05-13 10:28:28

Linux命令

2025-04-23 08:20:00

Linux性能監(jiān)測命令

2020-08-16 10:58:20

Pandaspython開發(fā)

2020-09-22 14:45:11

谷歌TensorFlow開發(fā)

2020-05-03 14:14:48

Linux 命令 代碼

2020-08-23 09:18:30

Pandas函數數據分析

2010-11-26 09:45:56

2020-10-13 14:54:11

機器學習技術工具

2013-10-11 15:26:32

linux網絡監(jiān)控

2021-07-12 14:50:25

Linux命令文件

2023-04-21 08:11:24

2020-12-15 09:43:20

Python可視化工具網絡應用

2017-03-20 14:37:43

Linux命令

2018-09-13 10:00:02

Linux命令危險命令

2014-03-14 09:13:35

Linux終端進程管理終端命令
點贊
收藏

51CTO技術棧公眾號