日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > linux >内容正文

linux

(转)对 Linux 专家非常有用的 20 个命令

發(fā)布時(shí)間:2024/3/24 linux 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 (转)对 Linux 专家非常有用的 20 个命令 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

謝謝你你給了我們?cè)谶@篇文章前兩個(gè)部分的喜歡,美言和支持。在第一部分文章中我們討論了那些都只是切換到 Linux 和linux新手所需的必要知識(shí)的用戶的命令。

  • 對(duì) Linux 新手非常有用的 20 個(gè)命令
  • 第二篇文章中我們討論了中級(jí)用戶管理自己的系統(tǒng)所需要的命令。

  • 對(duì)中級(jí) Linux 用戶非常有用的 20 個(gè)命令
  • 接下來呢?在這篇文章中我將解釋管理?Linux 服務(wù)器所需的一些命令。

    41. 命令: ifconfig

    ifconfig用來配置常駐內(nèi)核的網(wǎng)絡(luò)接口信息。在系統(tǒng)啟動(dòng)必要時(shí)用來設(shè)置網(wǎng)絡(luò)適配器的信息。之后,它通常是只需要在調(diào)試時(shí)或當(dāng)系統(tǒng)需要調(diào)整時(shí)使用。

    檢查活動(dòng)網(wǎng)絡(luò)適配器
    01[avishek@tecmint ~]$?ifconfig
    02?
    03eth0????? Link encap:Ethernet? HWaddr 40:2C:F4:EA:CF:0E?
    04??????????inet addr:192.168.1.3? Bcast:192.168.1.255? Mask:255.255.255.0
    05??????????inet6 addr: fe80::422c:f4ff:feea:cf0e/64 Scope:Link
    06??????????UP BROADCAST RUNNING MULTICAST? MTU:1500? Metric:1
    07??????????RX packets:163843 errors:0 dropped:0 overruns:0 frame:0
    08??????????TX packets:124990 errors:0 dropped:0 overruns:0 carrier:0
    09??????????collisions:0 txqueuelen:1000
    10??????????RX bytes:154389832 (147.2 MiB)? TX bytes:65085817 (62.0 MiB)
    11??????????Interrupt:20 Memory:f7100000-f7120000
    12?
    13lo??????? Link encap:Local Loopback?
    14??????????inet addr:127.0.0.1? Mask:255.0.0.0
    15??????????inet6 addr: ::1/128 Scope:Host
    16??????????UP LOOPBACK RUNNING? MTU:16436? Metric:1
    17??????????RX packets:78 errors:0 dropped:0 overruns:0 frame:0
    18??????????TX packets:78 errors:0 dropped:0 overruns:0 carrier:0
    19??????????collisions:0 txqueuelen:0
    20??????????RX bytes:4186 (4.0 KiB)? TX bytes:4186 (4.0 KiB)
    檢查所有的網(wǎng)絡(luò)適配器

    “-a”參數(shù)用來顯示所有網(wǎng)絡(luò)適配器(網(wǎng)卡)的詳細(xì)信息,包括那些停用的適配器。

    01[avishek@tecmint ~]$?ifconfig?-a
    02?
    03eth0????? Link encap:Ethernet? HWaddr 40:2C:F4:EA:CF:0E?
    04??????????inet addr:192.168.1.3? Bcast:192.168.1.255? Mask:255.255.255.0
    05??????????inet6 addr: fe80::422c:f4ff:feea:cf0e/64 Scope:Link
    06??????????UP BROADCAST RUNNING MULTICAST? MTU:1500? Metric:1
    07??????????RX packets:163843 errors:0 dropped:0 overruns:0 frame:0
    08??????????TX packets:124990 errors:0 dropped:0 overruns:0 carrier:0
    09??????????collisions:0 txqueuelen:1000
    10??????????RX bytes:154389832 (147.2 MiB)? TX bytes:65085817 (62.0 MiB)
    11??????????Interrupt:20 Memory:f7100000-f7120000
    12?
    13lo??????? Link encap:Local Loopback?
    14??????????inet addr:127.0.0.1? Mask:255.0.0.0
    15??????????inet6 addr: ::1/128 Scope:Host
    16??????????UP LOOPBACK RUNNING? MTU:16436? Metric:1
    17??????????RX packets:78 errors:0 dropped:0 overruns:0 frame:0
    18??????????TX packets:78 errors:0 dropped:0 overruns:0 carrier:0
    19??????????collisions:0 txqueuelen:0
    20??????????RX bytes:4186 (4.0 KiB)? TX bytes:4186 (4.0 KiB)
    21?
    22virbr0??? Link encap:Ethernet? HWaddr 0e:30:a3:3a:bf:03?
    23??????????inet addr:192.168.122.1? Bcast:192.168.122.255? Mask:255.255.255.0
    24??????????UP BROADCAST MULTICAST? MTU:1500? Metric:1
    25??????????RX packets:0 errors:0 dropped:0 overruns:0 frame:0
    26??????????TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
    27??????????collisions:0 txqueuelen:0
    28??????????RX bytes:0 (0.0 B)? TX bytes:0 (0.0 B)
    停用網(wǎng)絡(luò)適配器
    1[avishek@tecmint ~]$?ifconfig?eth0 down
    啟用網(wǎng)絡(luò)適配器
    1[avishek@tecmint ~]$?ifconfig?eth0 up
    指定IP地址到網(wǎng)絡(luò)適配器

    為網(wǎng)絡(luò)適配器eth0設(shè)定IP地址“192.168.1.12”.

    1[avishek@tecmint ~]$?ifconfig?eth0 192.168.1.12
    更改網(wǎng)絡(luò)適配器eth0的子網(wǎng)掩碼
    1[avishek@tecmint ~]$?ifconfig?eth0 netmask 255.255.255.
    更改網(wǎng)絡(luò)適配器eth0的廣播地址
    1[avishek@tecmint ~]$?ifconfig?eth0 broadcast 192.168.1.255
    為網(wǎng)絡(luò)適配器eth0指定IP地址,子網(wǎng)掩碼,廣播地址
    1[avishek@tecmint ~]$?ifconfig?eth0 192.168.1.12 netmask 255.255.255.0 broadcast 192.168.1.255

    注Note:?如果你設(shè)置一塊無線網(wǎng)卡的信息,你可以使用的命令是“iwconfig”.欲知更多ifconfig命令的例子和使用方法,讀“15個(gè)有用的ifconfig 命令”.

    42. 命令: netstat

    netstat命令顯示各種網(wǎng)絡(luò)相關(guān)的信息,如網(wǎng)絡(luò)連接,路由表,接口統(tǒng)計(jì),偽裝連接,組播成員身份等....

    列出所有的網(wǎng)絡(luò)端口
    01[avishek@tecmint ~]$?netstat?-a
    02?
    03Active UNIX domain sockets (servers and established)
    04Proto RefCnt Flags?????? Type?????? State???????? I-Node?? Path
    05unix? 2????? [ ACC ]???? STREAM???? LISTENING???? 741379?? /run/user/user1/keyring-I5cn1c/gpg
    06unix? 2????? [ ACC ]???? STREAM???? LISTENING???? 8965???? /var/run/acpid.socket
    07unix? 2????? [ ACC ]???? STREAM???? LISTENING???? 18584??? /tmp/.X11-unix/X0
    08unix? 2????? [ ACC ]???? STREAM???? LISTENING???? 741385?? /run/user/user1/keyring-I5cn1c/ssh
    09unix? 2????? [ ACC ]???? STREAM???? LISTENING???? 741387?? /run/user/user1/keyring-I5cn1c/pkcs11
    10unix? 2????? [ ACC ]???? STREAM???? LISTENING???? 20242??? @/tmp/dbus-ghtTjuPN46
    11unix? 2????? [ ACC ]???? STREAM???? LISTENING???? 13332??? /var/run/samba/winbindd_privileged/pipe
    12unix? 2????? [ ACC ]???? STREAM???? LISTENING???? 13331??? /tmp/.winbindd/pipe
    13unix? 2????? [ ACC ]???? STREAM???? LISTENING???? 11030??? /var/run/mysqld/mysqld.sock
    14unix? 2????? [ ACC ]???? STREAM???? LISTENING???? 19308??? /tmp/ssh-qnZadSgJAbqd/agent.3221
    15unix? 2????? [ ACC ]???? STREAM???? LISTENING???? 436781?? /tmp/HotShots
    16unix? 2????? [ ACC ]???? STREAM???? LISTENING???? 46110??? /run/user/ravisaive/pulse/native
    17unix? 2????? [ ACC ]???? STREAM???? LISTENING???? 19310??? /tmp/gpg-zfE9YT/S.gpg-agent
    18....
    顯示所有tcp相關(guān)端口
    01[avishek@tecmint ~]$?netstat?-at
    02?
    03Active Internet connections (servers and established)
    04Proto Recv-Q Send-Q Local Address?????????? Foreign Address???????? State?????
    05tcp??????? 0????? 0 localhost:mysql???????? *:*???????????????????? LISTEN????
    06tcp??????? 0????? 0 *:5901????????????????? *:*???????????????????? LISTEN????
    07tcp??????? 0????? 0 *:5902????????????????? *:*???????????????????? LISTEN????
    08tcp??????? 0????? 0 *:x11-1???????????????? *:*???????????????????? LISTEN????
    09tcp??????? 0????? 0 *:x11-2???????????????? *:*???????????????????? LISTEN????
    10tcp??????? 0????? 0 *:5938????????????????? *:*???????????????????? LISTEN????
    11tcp??????? 0????? 0 localhost:5940????????? *:*???????????????????? LISTEN????
    12tcp??????? 0????? 0 ravisaive-OptiPl:domain *:*???????????????????? LISTEN????
    13tcp??????? 0????? 0 ravisaive-OptiPl:domain *:*???????????????????? LISTEN????
    14tcp??????? 0????? 0 localhost:ipp?????????? *:*???????????????????? LISTEN????
    15tcp??????? 0????? 0 ravisaive-OptiPle:48270 ec2-23-21-236-70.c:http ESTABLISHED
    16tcp??????? 0????? 0 ravisaive-OptiPle:48272 ec2-23-21-236-70.c:http TIME_WAIT?
    17tcp??????? 0????? 0 ravisaive-OptiPle:48421 bom03s01-in-f22.1:https ESTABLISHED
    18tcp??????? 0????? 0 ravisaive-OptiPle:48269 ec2-23-21-236-70.c:http ESTABLISHED
    19tcp??????? 0????? 0 ravisaive-OptiPle:39084 channel-ecmp-06-f:https ESTABLISHED
    20...
    顯示所有連接的統(tǒng)計(jì)信息
    01[avishek@tecmint ~]$?netstat?-s
    02?
    03Ip:
    04????4994239 total packets received
    05????0 forwarded
    06????0 incoming packets discarded
    07????4165741 incoming packets delivered
    08????3248924 requests sent out
    09????8 outgoing packets dropped
    10Icmp:
    11????29460 ICMP messages received
    12????566 input ICMP message failed.
    13????ICMP input histogram:
    14????????destination unreachable: 98
    15????????redirects: 29362
    16????2918 ICMP messages sent
    17????0 ICMP messages failed
    18????ICMP output histogram:
    19????????destination unreachable: 2918
    20IcmpMsg:
    21????????InType3: 98
    22????????InType5: 29362
    23????????OutType3: 2918
    24Tcp:
    25????94533 active connections openings
    26????23 passive connection openings
    27????5870 failed connection attempts
    28????7194 connection resets received
    29....


    好的!由于某些原因如果你不想解析netstat 輸出的主機(jī)、端口和用戶名稱的話 。

    1[avishek@tecmint ~]$?netstat?-an


    好,你可能需要獲取的 netstat 持續(xù)輸出的動(dòng)態(tài)信息,通過傳遞中斷輸出指令 (ctrl + c)來停止。

    1[avishek@tecmint ~]$?netstat?-c

    更多關(guān)于“netstat”的例子和使用方法,瀏覽文章“20個(gè)netstat 的使用案例”。

    43. 命令: nslookup

    網(wǎng)絡(luò)實(shí)用程序,用于獲得互聯(lián)網(wǎng)服務(wù)器的信息。顧名思義,該實(shí)用程序?qū)l(fā)現(xiàn)通過查詢 DNS 域的名稱服務(wù)器信息。

    1[avishek@tecmint ~]$?nslookuptecmint.com
    2?
    3Server:???? 192.168.1.1
    4Address:??? 192.168.1.1#53
    5?
    6Non-authoritative answer:
    7Name:?? tecmint.com
    8Address: 50.16.67.239
    查詢?郵件?交換器?記錄
    01[avishek@tecmint ~]$?nslookup-query=mx tecmint.com
    02?
    03Server:???? 192.168.1.1
    04Address:??? 192.168.1.1#53
    05?
    06Non-authoritative answer:
    07tecmint.com mail exchanger = 0 smtp.secureserver.net.
    08tecmint.com mail exchanger = 10 mailstore1.secureserver.net.
    09?
    10Authoritative answers can be found from:
    查詢域名服務(wù)器
    01[avishek@tecmint ~]$?nslookup-type=ns tecmint.com
    02?
    03Server:???? 192.168.1.1
    04Address:??? 192.168.1.1#53
    05?
    06Non-authoritative answer:
    07tecmint.com nameserver = ns3404.com.
    08tecmint.com nameserver = ns3403.com.
    09?
    10Authoritative answers can be found from:
    查詢DNS記錄
    01[avishek@tecmint ~]$?nslookup-type=any tecmint.com
    02?
    03Server:???? 192.168.1.1
    04Address:??? 192.168.1.1#53
    05?
    06Non-authoritative answer:
    07tecmint.com mail exchanger = 10 mailstore1.secureserver.net.
    08tecmint.com mail exchanger = 0 smtp.secureserver.net.
    09tecmint.com nameserver = ns06.domaincontrol.com.
    10tecmint.com nameserver = ns3404.com.
    11tecmint.com nameserver = ns3403.com.
    12tecmint.com nameserver = ns05.domaincontrol.com.
    13?
    14Authoritative answers can be found from:
    查詢?起始?授權(quán)機(jī)構(gòu)
    01[avishek@tecmint ~]$?nslookup-type=soa tecmint.com
    02?
    03Server:???? 192.168.1.1
    04Address:??? 192.168.1.1#53
    05?
    06Non-authoritative answer:
    07tecmint.com
    08????origin = ns3403.hostgator.com
    09????mail addr = dnsadmin.gator1702.hostgator.com
    10????serial = 2012081102
    11????refresh = 86400
    12????retry = 7200
    13????expire = 3600000
    14????minimum = 86400
    15?
    16Authoritative answers can be found from:
    查詢端口號(hào)

    更改使用你想要連接的端口號(hào)

    1[avishek@tecmint ~]$?nslookup?-port 56 tecmint.com
    2?
    3Server:???? tecmint.com
    4Address:??? 50.16.76.239#53
    5?
    6Name:?? 56
    7Address: 14.13.253.12

    更多閱讀?8個(gè)Nslookup 命令

    44. 命令: dig

    dig是查詢DNS 域名服務(wù)器的工具,可以查詢的主機(jī)地址、 郵件交流、 域名服務(wù)器相關(guān)的信息。在任何 Linux (Unix) 或 Macintosh OS X 操作系統(tǒng)上,都可以使用該工具。dig的最典型的用法是單個(gè)主機(jī)的查詢。

    1[avishek@tecmint ~]$?dig?tecmint.com
    2?
    3; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6 <<>> tecmint.com
    4;; global options: +cmd
    5;; Got answer:
    6;; ->>HEADER<
    關(guān)閉注釋行
    01[avishek@tecmint ~]$?digtecmint.com +nocomments
    02?
    03; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6 <<>> tecmint.com +nocomments
    04;; global options: +cmd
    05;tecmint.com.?????????? IN? A
    06tecmint.com.??????? 14400?? IN? A?? 40.216.66.239
    07;; Query?time: 418 msec
    08;; SERVER: 192.168.1.1#53(192.168.1.1)
    09;; WHEN: Sat Jun 29 13:53:22 2013
    10;; MSG SIZE? rcvd: 45
    關(guān)閉認(rèn)證塊
    1[avishek@tecmint ~]$?digtecmint.com +noauthority
    2?
    3; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6 <<>> tecmint.com +noauthority
    4;; global options: +cmd
    5;; Got answer:
    6;; ->>HEADER<
    關(guān)閉?其他?塊
    1[avishek@tecmint ~]$?dig?tecmint.com +noadditional
    2?
    3; <<>> DiG 9.9.2-P1 <<>> tecmint.com +noadditional
    4;; global options: +cmd
    5;; Got answer:
    6;; ->>HEADER<
    關(guān)閉 統(tǒng)計(jì)塊
    1[avishek@tecmint ~]$?digtecmint.com +nostats
    2?
    3; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6 <<>> tecmint.com +nostats
    4;; global options: +cmd
    5;; Got answer:
    6;; ->>HEADER<
    關(guān)閉回復(fù)塊
    1[avishek@tecmint ~]$?digtecmint.com +noanswer
    2?
    3; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6 <<>> tecmint.com +noanswer
    4;; global options: +cmd
    5;; Got answer:
    6;; ->>HEADER<
    關(guān)閉所有塊
    1[avishek@tecmint ~]$?digtecmint.com +noall
    2?
    3; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6 <<>> tecmint.com +noall
    4;; global options: +cmd

    10 個(gè)Linux?Dig 命令實(shí)例

    45.命令: uptime

    你連接到你的?Linux 服務(wù)器時(shí)發(fā)現(xiàn)一些不尋?;驉阂獾臇|西,你會(huì)做什么?猜測(cè)......不,絕不!你可以運(yùn)行uptime來驗(yàn)證當(dāng)服務(wù)器無人值守式到底發(fā)生了什么事情。

    1[avishek@tecmint ~]$ uptime
    2?
    314:37:10 up? 4:21,? 2?users,? load average: 0.00, 0.00, 0.04

    46. 命令: wall

    對(duì)系統(tǒng)管理員來說一個(gè)最重要的命令.wall發(fā)送一條消息到大家登錄端將其?mesg?權(quán)限設(shè)置為"yes"。這條信息可以被wall作為參數(shù),或者可以將它作為wall的標(biāo)準(zhǔn)輸入。

    1[avishek@tecmint ~]$ wall?"we will be going down for maintenance for one hour sharply at 03:30 pm"
    2?
    3Broadcast message from root@localhost.localdomain (pts/0) (Sat Jun 29 14:44:02 2013):
    4?
    5we will be going down?for?maintenance?for?one hour sharply at 03:30 pm

    47. 命令: mesg

    其他人們可以使用"wtrite"命令,將在在向您發(fā)送文本到屏幕上。你可以控制是否顯示。

    1mesg [<strong>n</strong>|<strong>y</strong>] <strong>n</strong> - prevents the message from others popping up on the?screen. <strong>y</strong> – Allows messages to appear on your?screen.

    48. 命令: write

    如果 'mesg' 是 'y',讓你的文本直接發(fā)送到另一臺(tái) Linux 機(jī)器的屏幕。.

    1[avishek@tecmint ~]$ write ravisaive

    49. 命令: talk

    增強(qiáng)的write命令,talk命令可讓你與其他登錄的用戶交談。

    1[avishek@tecmint ~]$ talk ravisaive

    注釋: 如果?talk?命令沒安裝的話,可以通過apt?或yum 安裝所需的包.

    1[avishek@tecmint ~]$ yum?install?talk
    2OR
    3[avishek@tecmint ~]$ apt-get?install?talk

    50. 命令:w

    是否覺得命令'w'很滑稽?但是事實(shí)上不是的。它是一個(gè)命令,盡管只有一個(gè)字符長(zhǎng)!命令"w"是uptimewho命令,以前后的順序組合在一起。

    1[avishek@tecmint ~]$ w
    2?
    315:05:42 up? 4:49,? 3?users,? load average: 0.02, 0.01, 0.00
    4USER???? TTY????? FROM????????????? LOGIN@?? IDLE?? JCPU?? PCPU WHAT
    5server?? tty7???? :0?????????????? 14:06??? 4:43m? 1:42?? 0.08s pam: gdm-passwo
    6server?? pts/0??? :0.0???????????? 14:18??? 0.00s? 0.23s? 1.65s gnome-terminal
    7server?? pts/1??? :0.0???????????? 14:47??? 4:43?? 0.01s? 0.01s?bash

    51. 命令: rename

    見名知意,這個(gè)命令重命名文件。rename將會(huì)通過從文件名的首字符開始替換,重命名為指定的文件名。

    1Give the?file?names a1, a2, a3, a4.....1213

    僅僅寫這些命令:[@Lesus 注: 在Ubuntu上不支持這種格式, rename與mv不同的是,rename可以批量修改,如同帶了while的mv操作。]

    1rename a1 a0 a?
    2rename a1 a0 a??

    52. 命令: top

    顯示CPU進(jìn)程信息。這個(gè)命令自動(dòng)刷新,默認(rèn)是持續(xù)顯示CPU進(jìn)程信息,除非使用了中斷指令。

    01[avishek@tecmint ~]$?top
    02?
    03top?- 14:06:45 up 10 days, 20:57,? 2?users,? load average: 0.10, 0.16, 0.21
    04Tasks: 240 total,?? 1 running, 235 sleeping,?? 0 stopped,?? 4 zombie
    05%Cpu(s):? 2.0 us,? 0.5 sy,? 0.0 ni, 97.5?id,? 0.0 wa,? 0.0 hi,? 0.0 si,? 0.0 st
    06KiB Mem:?? 2028240 total,? 1777848 used,?? 250392?free,??? 81804 buffers
    07KiB Swap:? 3905532 total,?? 156748 used,? 3748784?free,?? 381456 cached
    08?
    09??PID USER????? PR? NI? VIRT? RES? SHR S? %CPU %MEM??? TIME+ COMMAND???????????????????????????????????????????????????????????????????????????????????????????????????????????
    1023768 ravisaiv? 20?? 0 1428m 571m? 41m S?? 2.3 28.9? 14:27.52 firefox???????????????????????????????????????????????????????????????????????????????????????????????????????????
    1124182 ravisaiv? 20?? 0? 511m 132m? 25m S?? 1.7? 6.7?? 2:45.94 plugin-containe???????????????????????????????????????????????????????????????????????????????????????????????????
    1226929 ravisaiv? 20?? 0? 5344 1432? 972 R?? 0.7? 0.1?? 0:00.07?top???????????????????????????????????????????????????????????????????????????????????????????????????????????????
    1324875 ravisaiv? 20?? 0? 263m? 14m? 10m S?? 0.3? 0.7?? 0:02.76 lxterminal????????????????????????????????????????????????????????????????????????????????????????????????????????
    14????1 root????? 20?? 0? 3896 1928 1228 S?? 0.0? 0.1?? 0:01.62 init??????????????????????????????????????????????????????????????????????????????????????????????????????????????
    15????2 root????? 20?? 0???? 0??? 0??? 0 S?? 0.0? 0.0?? 0:00.06 kthreadd??????????????????????????????????????????????????????????????????????????????????????????????????????????
    16????3 root????? 20?? 0???? 0??? 0??? 0 S?? 0.0? 0.0?? 0:17.28 ksoftirqd/0???????????????????????????????????????????????????????????????????????????????????????????????????????
    17????5 root?????? 0 -20???? 0??? 0??? 0 S?? 0.0? 0.0?? 0:00.00 kworker/0:0H??????????????????????????????????????????????????????????????????????????????????????????????????????
    18????7 root?????? 0 -20???? 0??? 0??? 0 S?? 0.0? 0.0?? 0:00.00 kworker/u:0H??????????????????????????????????????????????????????????????????????????????????????????????????????
    19????8 root????? rt?? 0???? 0??? 0??? 0 S?? 0.0? 0.0?? 0:00.12 migration/0???????????????????????????????????????????????????????????????????????????????????????????????????????
    20????9 root????? 20?? 0???? 0??? 0??? 0 S?? 0.0? 0.0?? 0:00.00 rcu_bh????????????????????????????????????????????????????????????????????????????????????????????????????????????
    21???10 root????? 20?? 0???? 0??? 0??? 0 S?? 0.0? 0.0?? 0:26.94 rcu_sched?????????????????????????????????????????????????????????????????????????????????????????????????????????
    22???11 root????? rt?? 0???? 0??? 0??? 0 S?? 0.0? 0.0?? 0:01.95 watchdog/0????????????????????????????????????????????????????????????????????????????????????????????????????????
    23???12 root????? rt?? 0???? 0??? 0??? 0 S?? 0.0? 0.0?? 0:02.00 watchdog/1????????????????????????????????????????????????????????????????????????????????????????????????????????
    24???13 root????? 20?? 0???? 0??? 0??? 0 S?? 0.0? 0.0?? 0:17.80 ksoftirqd/1???????????????????????????????????????????????????????????????????????????????????????????????????????
    25???14 root????? rt?? 0???? 0??? 0??? 0 S?? 0.0? 0.0?? 0:00.12 migration/1???????????????????????????????????????????????????????????????????????????????????????????????????????
    26???16 root?????? 0 -20???? 0??? 0??? 0 S?? 0.0? 0.0?? 0:00.00 kworker/1:0H??????????????????????????????????????????????????????????????????????????????????????????????????????
    27???17 root?????? 0 -20???? 0??? 0??? 0 S?? 0.0? 0.0?? 0:00.00 cpuset????????????????????????????????????????????????????????????????????????????????????????????????????????????
    28???18 root?????? 0 -20???? 0??? 0??? 0 S?? 0.0? 0.0?? 0:00.00 khelper???????????????????????????????????????????????????????????????????????????????????????????????????????????
    29???19 root????? 20?? 0???? 0??? 0??? 0 S?? 0.0? 0.0?? 0:00.00 kdevtmpfs?????????????????????????????????????????????????????????????????????????????????????????????????????????
    30???20 root?????? 0 -20???? 0??? 0??? 0 S?? 0.0? 0.0?? 0:00.00 netns?????????????????????????????????????????????????????????????????????????????????????????????????????????????
    31???21 root????? 20?? 0???? 0??? 0??? 0 S?? 0.0? 0.0?? 0:00.04 bdi-default???????????????????????????????????????????????????????????????????????????????????????????????????????
    32???22 root?????? 0 -20???? 0??? 0??? 0 S?? 0.0? 0.0?? 0:00.00 kintegrityd???????????????????????????????????????????????????????????????????????????????????????????????????????
    33???23 root?????? 0 -20???? 0??? 0??? 0 S?? 0.0? 0.0?? 0:00.00 kblockd???????????????????????????????????????????????????????????????????????????????????????????????????????????
    34???24 root?????? 0 -20???? 0??? 0??? 0 S?? 0.0? 0.0?? 0:00.00 ata_sff

    另查看?12 TOP命令例子?·[@Lesus 注:htop比top命令更好用,不過需要自己安裝
    ]

    53. 命令: mkfs.ext4

    這個(gè)命令在指定的設(shè)備上創(chuàng)建一個(gè)新的ext4文件系統(tǒng),如果這個(gè)命令后面跟的是個(gè)錯(cuò)誤的設(shè)備,那么整個(gè)設(shè)備就會(huì)被擦除和格式化,所以建議不要運(yùn)行這個(gè)命令,除非你清楚自己正在干什么。

    1Mkfs.ext4 /dev/sda1 (sda1 block will be formatted)
    2mkfs.ext4 /dev/sdb1 (sdb1 block will be formatted)

    更多查看:?Ext4是什么及怎么創(chuàng)建和轉(zhuǎn)換

    54. vi/emac/nano 命令

    vi?(visual),?emac,?nano?是 linux 中最常用的一些編輯器。它們經(jīng)常用于編輯文本,配置,… 等文件. A quick guide to work around vi and nano is, emac is a.

    vi 編輯器:
    1[avishek@tecmint ~]$?toucha.txt (創(chuàng)建一個(gè)名為a.txt的文本文件)
    2[avishek@tecmint ~]$?vi?a.txt (用vi打開a.txt)

    [按下‘i’鍵進(jìn)入插入模式, 否則你不能輸入任何內(nèi)容]

    1echo?"Hello"??(這里的文本會(huì)存到文件中)
  • alt+x?(退出插入模式, 記得在最后的字符間留有一些空格.
  • ctrl+x?命令或你上一個(gè)單詞將被刪除).
  • :wq!?(以當(dāng)前的文本保存文件, 記住‘!’ 是覆蓋的意思).
  • nano 編輯器:
    1[avishek@tecmint ~]$ nano a.txt (用nano打開 a.txt)
    1edit, with the content, required

    ctrl +x (關(guān)閉編輯器).它會(huì)顯示如下的提示輸出信息:

    1Save modified buffer (ANSWERING?"No"WILL DESTROY CHANGES) ????????????????????
    2?Y Yes
    3?N No?????????? ^C Cancel

    點(diǎn)擊‘y’ 選擇 yes 并輸入文件名,就完成編輯了.

    55. 命令: rsync

    Rsync復(fù)制文件,參數(shù)-P開啟進(jìn)度條。如果你已經(jīng)安裝了rsync,你可以使用一個(gè)簡(jiǎn)單的別名。

    1alias?cp='rsync -aP'

    現(xiàn)在嘗試在終端復(fù)制一個(gè)大文件,這樣將會(huì)看到顯示剩余部分的輸出,與進(jìn)度條類似。

    而且,保持和維護(hù)備份是系統(tǒng)管理員不得不做的最重要、最無聊的工作之一。Rsync是一個(gè)用于新建和維護(hù)備份的非常好用的終端工具(也存在許多其它工具)。

    1[avishek@tecmint ~]$?rsync-zvr IMG_5267\ copy\=33\ copy\=ok.jpg ~/Desktop/
    2?
    3sending incremental?filelist
    4IMG_5267 copy=33 copy=ok.jpg
    5?
    6sent 2883830 bytes? received 31 bytes? 5767722.00 bytes/sec
    7total size is 2882771? speedup is 1.00

    注意:?-z表示壓縮, -v表示詳細(xì)信息,-r表示遞歸。

    56. 命令: free

    跟蹤內(nèi)存的使用和資源一樣重要,就像管理員執(zhí)行的任何其它任務(wù),可以使用 'free' 命令來在這里救援.

    當(dāng)前內(nèi)存使用狀態(tài)Current Usage Status of Memory
    1[avishek@tecmint ~]$?free
    2?
    3?????????????total?????? used???????free?????shared??? buffers???? cached
    4Mem:?????? 2028240??? 1788272???? 239968????????? 0????? 69468???? 363716
    5-/+ buffers/cache:??? 1355088???? 673152
    6Swap:????? 3905532???? 157076??? 3748456
    設(shè)置輸出單位為KB,MB或GB
    1[avishek@tecmint ~]$?free?-b
    2?
    3?????????????total?????? used???????free?????shared??? buffers???? cached
    4Mem:??? 2076917760 1838272512? 238645248????????? 0?? 71348224? 372670464
    5-/+ buffers/cache: 1394253824? 682663936
    6Swap:?? 3999264768? 160845824 3838418944
    1[avishek@tecmint ~]$?free?-k
    2?
    3?????????????total?????? used???????free?????shared??? buffers???? cached
    4Mem:?????? 2028240??? 1801484???? 226756????????? 0????? 69948???? 363704
    5-/+ buffers/cache:??? 1367832???? 660408
    6Swap:????? 3905532???? 157076??? 3748456
    1[avishek@tecmint ~]$?free?-m
    2?
    3?????????????total?????? used???????free?????shared??? buffers???? cached
    4Mem:????????? 1980?????? 1762??????? 218????????? 0???????? 68??????? 355
    5-/+ buffers/cache:?????? 1338??????? 641
    6Swap:???????? 3813??????? 153?????? 3660
    1[avishek@tecmint ~]$?free?-g
    2?
    3?????????????total?????? used???????free?????shared??? buffers???? cached
    4Mem:???????????? 1????????? 1????????? 0????????? 0????????? 0????????? 0
    5-/+ buffers/cache:????????? 1????????? 0
    6Swap:??????????? 3????????? 0????????? 3
    以可讀的格式顯示,檢查當(dāng)前內(nèi)存使用
    1[avishek@tecmint ~]$?free?-h
    2?
    3?????????????total?????? used???????free?????shared??? buffers???? cached
    4Mem:????????? 1.9G?????? 1.7G?????? 208M???????? 0B??????? 68M?????? 355M
    5-/+ buffers/cache:?????? 1.3G?????? 632M
    6Swap:???????? 3.7G?????? 153M?????? 3.6G
    設(shè)定?時(shí)間間隔?后?,持續(xù)檢查?使用狀態(tài)
    01[avishek@tecmint ~]$?free?-s 3
    02?
    03?????????????total?????? used???????free?????shared??? buffers???? cached
    04Mem:?????? 2028240??? 1824096???? 204144????????? 0????? 70708???? 364180
    05-/+ buffers/cache:??? 1389208???? 639032
    06Swap:????? 3905532???? 157076??? 3748456
    07?
    08?????????????total?????? used???????free?????shared??? buffers???? cached
    09Mem:?????? 2028240??? 1824192???? 204048????????? 0????? 70716???? 364212
    10-/+ buffers/cache:??? 1389264???? 638976
    11Swap:????? 3905532???? 157076??? 3748456

    10個(gè)Free命令使用實(shí)例

    57. mysqldump 命令

    好了,現(xiàn)在你從名字上就能明白這個(gè)命令所代表的作用。mysqldump?命令會(huì)轉(zhuǎn)儲(chǔ)(備份)數(shù)據(jù)庫(kù)的全部或特定一部分?jǐn)?shù)據(jù)到一個(gè)給定的文件中。例如:

    1[avishek@tecmint ~]$ mysqldump -u root -p --all-databases > /home/server/Desktop/backupfile.sql

    注意:?mysqldump?需要 mysql 在運(yùn)行中并且有正確的授權(quán)密碼。我們?cè)?用mysqldump命令備份數(shù)據(jù)庫(kù)中討論了一些有用的 “mysqldump” 命令用法。

    58. mkpasswd 命令

    根據(jù)指定的長(zhǎng)度,產(chǎn)生一個(gè)難猜的隨機(jī)密碼。

    1[avishek@tecmint ~]$ mkpasswd -l 10
    2?
    3zI4+Ybqfx9
    1[avishek@tecmint ~]$ mkpasswd -l 20
    2?
    3w0Pr7aqKk&hmbmqdrlmk

    注意:?-l 10?產(chǎn)生一個(gè)10個(gè)字符的隨機(jī)密碼,而-l 20?產(chǎn)生?20個(gè)字符的密碼,它可以設(shè)置為任意長(zhǎng)度來取得所希望的結(jié)果。這個(gè)命令很有用,經(jīng)常在腳本語(yǔ)言里使用來產(chǎn)生隨機(jī)的密碼。你可能需要?yum?或?apt?‘expect’ 包來使用這個(gè)命令。

    1[avishek@tecmint ~]$ yum?installexpect
    2
    3[avishek@tecmint ~]$ apt-get?install?expect

    59. Command: paste

    合并兩個(gè)或多個(gè)文本文件,按行來進(jìn)行合并。示例。如果 file1 的內(nèi)容是:

    011
    022
    033
    04?
    05file2 是這樣的:
    06?
    07a
    08b
    09c
    10d
    11<pre class="brush:shell">[avishek@tecmint ~]$?paste?file1 file2 > file3</pre>
    12<br>
    13結(jié)果file3將是:
    141??? a
    152??? b
    163??? c
    17?????d

    60.Command: lsof

    lsof 是"list open files("列表中打開的文件") 的縮寫,顯示您的系統(tǒng)當(dāng)前已打開的所有文件。這是非常有用的對(duì)于想找出哪些進(jìn)程使用某一特定文件,或顯示為單個(gè)進(jìn)程打開所有文件。一些有用的?10 個(gè)lsof 命令示例,你可能會(huì)感興趣閱讀。

    01[avishek@tecmint ~]$?lsof
    02?
    03COMMAND???? PID?? TID??????????? USER?? FD????? TYPE???? DEVICE SIZE/OFF?????? NODE NAME
    04init????????? 1????????????????? root? cwd?????? DIR??????? 8,1???? 4096????????? 2 /
    05init????????? 1????????????????? root? rtd?????? DIR??????? 8,1???? 4096????????? 2 /
    06init????????? 1????????????????? root? txt?????? REG??????? 8,1?? 227432???? 395571 /sbin/init
    07init????????? 1????????????????? root? mem?????? REG??????? 8,1??? 47080???? 263023 /lib/i386-linux-gnu/libnss_files-2.17.so
    08init????????? 1????????????????? root? mem?????? REG??????? 8,1??? 42672???? 270178 /lib/i386-linux-gnu/libnss_nis-2.17.so
    09init????????? 1????????????????? root? mem?????? REG??????? 8,1??? 87940???? 270187 /lib/i386-linux-gnu/libnsl-2.17.so
    10init????????? 1????????????????? root? mem?????? REG??????? 8,1??? 30560???? 263021 /lib/i386-linux-gnu/libnss_compat-2.17.so
    11init????????? 1????????????????? root? mem?????? REG??????? 8,1?? 124637???? 270176 /lib/i386-linux-gnu/libpthread-2.17.so
    12init????????? 1????????????????? root? mem?????? REG??????? 8,1? 1770984???? 266166 /lib/i386-linux-gnu/libc-2.17.so
    13init????????? 1????????????????? root? mem?????? REG??????? 8,1??? 30696???? 262824 /lib/i386-linux-gnu/librt-2.17.so
    14init????????? 1????????????????? root? mem?????? REG??????? 8,1??? 34392???? 262867 /lib/i386-linux-gnu/libjson.so.0.1.0
    15init????????? 1????????????????? root? mem?????? REG??????? 8,1?? 296792???? 262889 /lib/i386-linux-gnu/libdbus-1.so.3.7.2
    16init????????? 1????????????????? root? mem?????? REG??????? 8,1??? 34168???? 262840 /lib/i386-linux-gnu/libnih-dbus.so.1.0.0
    17init????????? 1????????????????? root? mem?????? REG??????? 8,1??? 95616???? 262848 /lib/i386-linux-gnu/libnih.so.1.0.0
    18init????????? 1????????????????? root? mem?????? REG??????? 8,1?? 134376???? 270186 /lib/i386-linux-gnu/ld-2.17.so
    19init????????? 1????????????????? root??? 0u????? CHR??????? 1,3????? 0t0?????? 1035 /dev/null
    20init????????? 1????????????????? root??? 1u????? CHR??????? 1,3????? 0t0?????? 1035 /dev/null
    21init????????? 1????????????????? root??? 2u????? CHR??????? 1,3????? 0t0?????? 1035 /dev/null
    22init????????? 1????????????????? root??? 3r???? FIFO??????? 0,8????? 0t0?????? 1714 pipe
    23init????????? 1????????????????? root??? 4w???? FIFO??????? 0,8????? 0t0?????? 1714 pipe
    24init????????? 1????????????????? root??? 5r???? 0000??????? 0,9??????? 0?????? 6245 anon_inode
    25init????????? 1????????????????? root??? 6r???? 0000??????? 0,9??????? 0?????? 6245 anon_inode
    26init????????? 1????????????????? root??? 7u???? unix 0xf5e91f80????? 0t0?????? 8192 @/com/ubuntu/upstart
    27init????????? 1????????????????? root??? 8w????? REG??????? 8,1???? 3916??????? 394 /var/log/upstart/teamviewerd.log.1 (deleted)

    這里并沒有結(jié)束,系統(tǒng)管理員會(huì)很多東西,為你提供漂亮的界面,服務(wù)于你的工作。系統(tǒng)管理實(shí)際上是學(xué)習(xí)和實(shí)現(xiàn)的一門優(yōu)雅的藝術(shù)。我們會(huì)盡力給你介紹 linux 專業(yè)人員必須了解的知識(shí)以及一些其他必要東西,linux本身是基礎(chǔ)的,簡(jiǎn)單的。深入理解是不斷學(xué)習(xí)的過程。你的美言好詞總是在不斷鼓勵(lì)我們寫出更多的優(yōu)秀,豐富的文章。"喜之以分享,助我來傳播"。

    本文地址:http://www.oschina.net/translate/20-advanced-commands-for-linux-experts

    原文地址:http://www.tecmint.com/20-advanced-commands-for-linux-experts/

    轉(zhuǎn)載于:https://www.cnblogs.com/finlay/p/3253255.html

    總結(jié)

    以上是生活随笔為你收集整理的(转)对 Linux 专家非常有用的 20 个命令的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。