歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux命令 >> 10個你從未用過的Linux命令

10個你從未用過的Linux命令

日期:2017/2/28 10:01:51   编辑:Linux命令
Linux命令

這也許需要幾年甚至是幾十年,才能真正掌握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腳本執行平方根操作,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 數字線,在沒發現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

Copyright © Linux教程網 All Rights Reserved