网站搜索

供 Linux 专家使用的 20 个高级命令


感谢您在本文前两部分中给予我们的所有点赞、美言和支持。在第一篇文章中,我们讨论了针对那些刚刚切换到 Linux 并需要必要的知识的用户的命令。

  1. 对 Linux 新手有用的 20 个命令

在第二篇文章中,我们讨论了中级用户管理自己的系统所需的命令。

  1. 适合中级 Linux 用户的 20 个高级命令

接下来做什么?在本文中,我将解释管理 Linux 服务器 所需的命令。

41.命令:ifconfig

ifconfig 用于配置驻留在内核的网络接口。它在启动时用于根据需要设置接口。之后,通常只有在调试或需要系统调整时才需要它。

检查活动网络接口
[avishek@tecmint ~]$ ifconfig 

eth0      Link encap:Ethernet  HWaddr 40:2C:F4:EA:CF:0E  
          inet addr:192.168.1.3  Bcast:192.168.1.255  Mask:255.255.255.0 
          inet6 addr: fe80::422c:f4ff:feea:cf0e/64 Scope:Link 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1 
          RX packets:163843 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:124990 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:154389832 (147.2 MiB)  TX bytes:65085817 (62.0 MiB) 
          Interrupt:20 Memory:f7100000-f7120000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0 
          inet6 addr: ::1/128 Scope:Host 
          UP LOOPBACK RUNNING  MTU:16436  Metric:1 
          RX packets:78 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:78 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:0 
          RX bytes:4186 (4.0 KiB)  TX bytes:4186 (4.0 KiB)
检查所有网络接口

使用“-a”参数显示所有接口的详细信息,包括禁用的接口。

[avishek@tecmint ~]$ ifconfig -a

eth0      Link encap:Ethernet  HWaddr 40:2C:F4:EA:CF:0E  
          inet addr:192.168.1.3  Bcast:192.168.1.255  Mask:255.255.255.0 
          inet6 addr: fe80::422c:f4ff:feea:cf0e/64 Scope:Link 
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1 
          RX packets:163843 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:124990 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:1000 
          RX bytes:154389832 (147.2 MiB)  TX bytes:65085817 (62.0 MiB) 
          Interrupt:20 Memory:f7100000-f7120000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0 
          inet6 addr: ::1/128 Scope:Host 
          UP LOOPBACK RUNNING  MTU:16436  Metric:1 
          RX packets:78 errors:0 dropped:0 overruns:0 frame:0 
          TX packets:78 errors:0 dropped:0 overruns:0 carrier:0 
          collisions:0 txqueuelen:0 
          RX bytes:4186 (4.0 KiB)  TX bytes:4186 (4.0 KiB) 

virbr0    Link encap:Ethernet  HWaddr 0e:30:a3:3a:bf:03  
          inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
禁用接口
[avishek@tecmint ~]$ ifconfig eth0 down
启用接口
[avishek@tecmint ~]$ ifconfig eth0 up
为接口分配 IP 地址

将“192.168.1.12”指定为接口 eth0 的 IP 地址。

[avishek@tecmint ~]$ ifconfig eth0 192.168.1.12
更改接口 eth0 的子网掩码
[avishek@tecmint ~]$ ifconfig eth0 netmask 255.255.255.
更改接口eth0的广播地址
[avishek@tecmint ~]$ ifconfig eth0 broadcast 192.168.1.255
为接口 eth0 分配 IP 地址、网络掩码和广播
[avishek@tecmint ~]$ ifconfig eth0 192.168.1.12 netmask 255.255.255.0 broadcast 192.168.1.255

注意:如果使用无线网络,您需要使用命令“iwconfig”。有关更多“ifconfig”命令示例和用法,请阅读 15 个有用的“ifconfig”命令。

42.命令:netstat

netstat 命令显示各种网络相关信息,例如网络连接、路由表、接口统计信息、伪装连接、多播成员资格等。

列出所有网络端口
[avishek@tecmint ~]$ netstat -a

Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ACC ]     STREAM     LISTENING     741379   /run/user/user1/keyring-I5cn1c/gpg
unix  2      [ ACC ]     STREAM     LISTENING     8965     /var/run/acpid.socket
unix  2      [ ACC ]     STREAM     LISTENING     18584    /tmp/.X11-unix/X0
unix  2      [ ACC ]     STREAM     LISTENING     741385   /run/user/user1/keyring-I5cn1c/ssh
unix  2      [ ACC ]     STREAM     LISTENING     741387   /run/user/user1/keyring-I5cn1c/pkcs11
unix  2      [ ACC ]     STREAM     LISTENING     20242    @/tmp/dbus-ghtTjuPN46
unix  2      [ ACC ]     STREAM     LISTENING     13332    /var/run/samba/winbindd_privileged/pipe
unix  2      [ ACC ]     STREAM     LISTENING     13331    /tmp/.winbindd/pipe
unix  2      [ ACC ]     STREAM     LISTENING     11030    /var/run/mysqld/mysqld.sock
unix  2      [ ACC ]     STREAM     LISTENING     19308    /tmp/ssh-qnZadSgJAbqd/agent.3221
unix  2      [ ACC ]     STREAM     LISTENING     436781   /tmp/HotShots
unix  2      [ ACC ]     STREAM     LISTENING     46110    /run/user/ravisaive/pulse/native
unix  2      [ ACC ]     STREAM     LISTENING     19310    /tmp/gpg-zfE9YT/S.gpg-agent
....
列出所有 TCP 端口
[avishek@tecmint ~]$ netstat -at

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 localhost:mysql         *:*                     LISTEN     
tcp        0      0 *:5901                  *:*                     LISTEN     
tcp        0      0 *:5902                  *:*                     LISTEN     
tcp        0      0 *:x11-1                 *:*                     LISTEN     
tcp        0      0 *:x11-2                 *:*                     LISTEN     
tcp        0      0 *:5938                  *:*                     LISTEN     
tcp        0      0 localhost:5940          *:*                     LISTEN     
tcp        0      0 ravisaive-OptiPl:domain *:*                     LISTEN     
tcp        0      0 ravisaive-OptiPl:domain *:*                     LISTEN     
tcp        0      0 localhost:ipp           *:*                     LISTEN     
tcp        0      0 ravisaive-OptiPle:48270 ec2-23-21-236-70.c:http ESTABLISHED
tcp        0      0 ravisaive-OptiPle:48272 ec2-23-21-236-70.c:http TIME_WAIT  
tcp        0      0 ravisaive-OptiPle:48421 bom03s01-in-f22.1:https ESTABLISHED
tcp        0      0 ravisaive-OptiPle:48269 ec2-23-21-236-70.c:http ESTABLISHED
tcp        0      0 ravisaive-OptiPle:39084 channel-ecmp-06-f:https ESTABLISHED
...
显示所有端口的统计信息
[avishek@tecmint ~]$ netstat -s

Ip:
    4994239 total packets received
    0 forwarded
    0 incoming packets discarded
    4165741 incoming packets delivered
    3248924 requests sent out
    8 outgoing packets dropped
Icmp:
    29460 ICMP messages received
    566 input ICMP message failed.
    ICMP input histogram:
        destination unreachable: 98
        redirects: 29362
    2918 ICMP messages sent
    0 ICMP messages failed
    ICMP output histogram:
        destination unreachable: 2918
IcmpMsg:
        InType3: 98
        InType5: 29362
        OutType3: 2918
Tcp:
    94533 active connections openings
    23 passive connection openings
    5870 failed connection attempts
    7194 connection resets received
....

好的!由于某种原因,如果您不想将主机、端口和用户名解析为 netstat 的输出。

[avishek@tecmint ~]$ netstat -an

好吧,您可能需要连续获取 netstat 的输出,直到中断指令通过(ctrl+c)。

[avishek@tecmint ~]$ netstat -c

有关更多“netstat”命令示例和用法,请参阅文章 20 Netstat 命令示例。

43.命令:nslookup

用于获取有关 Internet 服务器信息的网络实用程序。顾名思义,该实用程序通过查询 DNS 查找域的名称服务器信息。

[avishek@tecmint ~]$ nslookup linux-console.net 

Server:		192.168.1.1 
Address:	192.168.1.1#53 

Non-authoritative answer: 
Name:	linux-console.net 
Address: 50.16.67.239
查询邮件交换器记录
[avishek@tecmint ~]$ nslookup -query=mx linux-console.net 

Server:		192.168.1.1 
Address:	192.168.1.1#53 

Non-authoritative answer: 
linux-console.net	mail exchanger = 0 smtp.secureserver.net. 
linux-console.net	mail exchanger = 10 mailstore1.secureserver.net. 

Authoritative answers can be found from:
查询名称服务器
[avishek@tecmint ~]$ nslookup -type=ns linux-console.net 

Server:		192.168.1.1 
Address:	192.168.1.1#53 

Non-authoritative answer: 
linux-console.net	nameserver = ns3404.com. 
linux-console.net	nameserver = ns3403.com. 

Authoritative answers can be found from:
查询DNS记录
[avishek@tecmint ~]$ nslookup -type=any linux-console.net 

Server:		192.168.1.1 
Address:	192.168.1.1#53 

Non-authoritative answer: 
linux-console.net	mail exchanger = 10 mailstore1.secureserver.net. 
linux-console.net	mail exchanger = 0 smtp.secureserver.net. 
linux-console.net	nameserver = ns06.domaincontrol.com. 
linux-console.net	nameserver = ns3404.com. 
linux-console.net	nameserver = ns3403.com. 
linux-console.net	nameserver = ns05.domaincontrol.com. 

Authoritative answers can be found from:
查询权限起始
[avishek@tecmint ~]$ nslookup -type=soa linux-console.net 

Server:		192.168.1.1 
Address:	192.168.1.1#53 

Non-authoritative answer: 
linux-console.net 
	origin = ns3403.hostgator.com 
	mail addr = dnsadmin.gator1702.hostgator.com 
	serial = 2012081102 
	refresh = 86400 
	retry = 7200 
	expire = 3600000 
	minimum = 86400 

Authoritative answers can be found from:
查询端口号

更改您要连接的端口号

[avishek@tecmint ~]$ nslookup -port 56 linux-console.net

Server:		linux-console.net
Address:	50.16.76.239#53

Name:	56
Address: 14.13.253.12

另请阅读:8 个 Nslookup 命令

44. 命令:挖掘

dig 是一个用于查询 DNS 域名服务器以获取有关主机地址、邮件交换、域名服务器和相关信息的工具。该工具可以在任何 Linux (Unix) 或 Macintosh OS X 操作系统中使用。 dig 最典型的用途是简单地查询单个主机。

[avishek@tecmint ~]$ dig linux-console.net

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6 <<>> linux-console.net 
;; global options: +cmd 
;; Got answer: 
;; ->>HEADER<
关闭注释行
[avishek@tecmint ~]$ dig linux-console.net +nocomments 

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6 <<>> linux-console.net +nocomments 
;; global options: +cmd 
;linux-console.net.			IN	A 
linux-console.net.		14400	IN	A	40.216.66.239 
;; Query time: 418 msec 
;; SERVER: 192.168.1.1#53(192.168.1.1) 
;; WHEN: Sat Jun 29 13:53:22 2013 
;; MSG SIZE  rcvd: 45
关闭权限部分
[avishek@tecmint ~]$ dig linux-console.net +noauthority 

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6 <<>> linux-console.net +noauthority 
;; global options: +cmd 
;; Got answer: 
;; ->>HEADER<
关闭附加部分
[avishek@tecmint ~]$ dig  linux-console.net +noadditional 

; <<>> DiG 9.9.2-P1 <<>> linux-console.net +noadditional
;; global options: +cmd
;; Got answer:
;; ->>HEADER<
关闭统计部分
[avishek@tecmint ~]$ dig linux-console.net +nostats 

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6 <<>> linux-console.net +nostats 
;; global options: +cmd 
;; Got answer: 
;; ->>HEADER<
关闭应答部分
[avishek@tecmint ~]$ dig linux-console.net +noanswer 

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6 <<>> linux-console.net +noanswer 
;; global options: +cmd 
;; Got answer: 
;; ->>HEADER<
一次禁用所有部分
[avishek@tecmint ~]$ dig linux-console.net +noall 

; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6 <<>> linux-console.net +noall 
;; global options: +cmd

另请阅读:10 个 Linux Dig 命令示例

45. 命令:正常运行时间

您刚刚连接到您的 Linux 服务器计算机,并发现了异常或恶意的情况,您会做什么?猜测……不,绝对不能运行uptime来验证服务器无人值守时实际发生的情况。

[avishek@tecmint ~]$ uptime

14:37:10 up  4:21,  2 users,  load average: 0.00, 0.00, 0.04

46. 命令:墙

对于管理员来说,wall 是最重要的命令之一,它向所有登录且 mesg 权限设置为“yes”的用户发送一条消息。该消息可以作为 wall 的参数给出,也可以发送到 wall 的标准输入。

[avishek@tecmint ~]$ wall "we will be going down for maintenance for one hour sharply at 03:30 pm"

Broadcast message from [email  (pts/0) (Sat Jun 29 14:44:02 2013): 

we will be going down for maintenance for one hour sharply at 03:30 pm

47. 命令:mesg

让您控制人们是否可以使用“写入”命令通过屏幕向您发送文本。

mesg [n|y]
n - prevents the message from others popping up on the screen.
y – Allows messages to appear on your screen.

48. 命令:写

如果“mesg”为“y”,您可以将文本直接发送到另一台 Linux 计算机的屏幕。

[avishek@tecmint ~]$ write ravisaive

49. 命令:说话

write 命令的增强功能,talk 命令可让您与登录的用户交谈。

[avishek@tecmint ~]$ talk ravisaive

注意:如果没有安装talk命令,您可以随时aptyum所需的软件包。

[avishek@tecmint ~]$ yum install talk
OR
[avishek@tecmint ~]$ apt-get install talk

50. 命令:w

什么命令“w”让你觉得很有趣?但实际上并非如此。这是一个命令,即使它只有一个字母长!命令“w”是 uptimewho 命令的组合,按顺序依次给出。

[avishek@tecmint ~]$ w

15:05:42 up  4:49,  3 users,  load average: 0.02, 0.01, 0.00 
USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU WHAT 
server   tty7     :0               14:06    4:43m  1:42   0.08s pam: gdm-passwo 
server   pts/0    :0.0             14:18    0.00s  0.23s  1.65s gnome-terminal 
server   pts/1    :0.0             14:47    4:43   0.01s  0.01s bash

51.命令:重命名

顾名思义,该命令重命名文件。重命名将通过替换文件名中的第一个匹配项来重命名指定的文件。

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

只需键入命令即可。

 rename a1 a0 a?
 rename a1 a0 a??

52. 命令:顶部

显示CPU的进程。默认情况下,此命令会自动刷新,并继续显示 CPU 进程,除非给出中断指令。

[avishek@tecmint ~]$ top

top - 14:06:45 up 10 days, 20:57,  2 users,  load average: 0.10, 0.16, 0.21
Tasks: 240 total,   1 running, 235 sleeping,   0 stopped,   4 zombie
%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
KiB Mem:   2028240 total,  1777848 used,   250392 free,    81804 buffers
KiB Swap:  3905532 total,   156748 used,  3748784 free,   381456 cached

  PID USER      PR  NI  VIRT  RES  SHR S  %CPU %MEM    TIME+ COMMAND                                                                                                            
23768 ravisaiv  20   0 1428m 571m  41m S   2.3 28.9  14:27.52 firefox                                                                                                            
24182 ravisaiv  20   0  511m 132m  25m S   1.7  6.7   2:45.94 plugin-containe                                                                                                    
26929 ravisaiv  20   0  5344 1432  972 R   0.7  0.1   0:00.07 top                                                                                                                
24875 ravisaiv  20   0  263m  14m  10m S   0.3  0.7   0:02.76 lxterminal                                                                                                         
    1 root      20   0  3896 1928 1228 S   0.0  0.1   0:01.62 init                                                                                                               
    2 root      20   0     0    0    0 S   0.0  0.0   0:00.06 kthreadd                                                                                                           
    3 root      20   0     0    0    0 S   0.0  0.0   0:17.28 ksoftirqd/0                                                                                                        
    5 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 kworker/0:0H                                                                                                       
    7 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 kworker/u:0H                                                                                                       
    8 root      rt   0     0    0    0 S   0.0  0.0   0:00.12 migration/0                                                                                                        
    9 root      20   0     0    0    0 S   0.0  0.0   0:00.00 rcu_bh                                                                                                             
   10 root      20   0     0    0    0 S   0.0  0.0   0:26.94 rcu_sched                                                                                                          
   11 root      rt   0     0    0    0 S   0.0  0.0   0:01.95 watchdog/0                                                                                                         
   12 root      rt   0     0    0    0 S   0.0  0.0   0:02.00 watchdog/1                                                                                                         
   13 root      20   0     0    0    0 S   0.0  0.0   0:17.80 ksoftirqd/1                                                                                                        
   14 root      rt   0     0    0    0 S   0.0  0.0   0:00.12 migration/1                                                                                                        
   16 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 kworker/1:0H                                                                                                       
   17 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 cpuset                                                                                                             
   18 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 khelper                                                                                                            
   19 root      20   0     0    0    0 S   0.0  0.0   0:00.00 kdevtmpfs                                                                                                          
   20 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 netns                                                                                                              
   21 root      20   0     0    0    0 S   0.0  0.0   0:00.04 bdi-default                                                                                                        
   22 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 kintegrityd                                                                                                        
   23 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 kblockd                                                                                                            
   24 root       0 -20     0    0    0 S   0.0  0.0   0:00.00 ata_sff

另请阅读:12 个 TOP 命令示例

53.命令:mkfs.ext4

该命令在指定设备上创建一个新的ext4文件系统,如果该命令后跟随了错误的设备,则整个块将被擦除并格式化,因此建议不要运行该命令,除非且直到你明白你在做什么。

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

阅读更多内容:什么是 Ext4 以及如何创建和转换

54.命令:vi /emacs/nano

vi(视觉)、emacsnano 是 Linux 中最常用的编辑器。它们经常用于编辑文本、配置……文件。解决 vi 和 nano 的快速指南是 emacs。

vi编辑器
[avishek@tecmint ~]$ touch a.txt (creates a text file a.txt) 
[avishek@tecmint ~]$ vi a.txt (open a.txt with vi editor)
echo "Hello"  (your text here for the file)
  1. alt+x(退出插入模式,记得在最后一个字母之间保留一些空格。
  2. ctrl+x 命令,否则您的最后一个单词将被删除)。
  3. :wq! (保存文件,使用当前文本,记住‘!’是覆盖)。
纳米编辑器
[avishek@tecmint ~]$ nano a.txt (open a.txt file to be edited with nano)
edit, with the content, required

ctrl +x(关闭编辑器)。它将显示输出为:

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

单击“y”选择“是”并输入文件名,即可完成。

55.命令:rsync

Rsync 复制文件并具有用于进度条的 -P 开关。因此,如果您安装了 rsync,则可以使用简单的别名。

alias cp='rsync -aP'

现在尝试在终端中复制一个大文件并查看带有剩余项目的输出,类似于进度条。

此外,保存和维护备份是系统管理员需要执行的最重要和最无聊的工作之一。 Rsync 是一个非常好的工具(存在,还有其他几个),用于在终端中创建和维护备份。

[avishek@tecmint ~]$ rsync -zvr IMG_5267\ copy\=33\ copy\=ok.jpg ~/Desktop/ 

sending incremental file list 
IMG_5267 copy=33 copy=ok.jpg 

sent 2883830 bytes  received 31 bytes  5767722.00 bytes/sec 
total size is 2882771  speedup is 1.00

注意-z表示压缩,-v表示详细,-r表示递归。

56. 命令:自由

跟踪内存和资源与管理员执行的任何其他任务一样重要,“free”命令可以解决这个问题。

当前内存使用情况
[avishek@tecmint ~]$ free

             total       used       free     shared    buffers     cached
Mem:       2028240    1788272     239968          0      69468     363716
-/+ buffers/cache:    1355088     673152
Swap:      3905532     157076    3748456
调整后的输出(以 KB、MB 或 GB 为单位)
[avishek@tecmint ~]$ free -b

             total       used       free     shared    buffers     cached
Mem:    2076917760 1838272512  238645248          0   71348224  372670464
-/+ buffers/cache: 1394253824  682663936
Swap:   3999264768  160845824 3838418944
[avishek@tecmint ~]$ free -k

             total       used       free     shared    buffers     cached
Mem:       2028240    1801484     226756          0      69948     363704
-/+ buffers/cache:    1367832     660408
Swap:      3905532     157076    3748456
[avishek@tecmint ~]$ free -m

             total       used       free     shared    buffers     cached
Mem:          1980       1762        218          0         68        355
-/+ buffers/cache:       1338        641
Swap:         3813        153       3660
[avishek@tecmint ~]$ free -g

             total       used       free     shared    buffers     cached
Mem:             1          1          0          0          0          0
-/+ buffers/cache:          1          0
Swap:            3          0          3
以人类可读的格式检查当前使用情况
[avishek@tecmint ~]$ free -h

             total       used       free     shared    buffers     cached
Mem:          1.9G       1.7G       208M         0B        68M       355M
-/+ buffers/cache:       1.3G       632M
Swap:         3.7G       153M       3.6G
定期间隔后连续检查状态
[avishek@tecmint ~]$ free -s 3

             total       used       free     shared    buffers     cached
Mem:       2028240    1824096     204144          0      70708     364180
-/+ buffers/cache:    1389208     639032
Swap:      3905532     157076    3748456

             total       used       free     shared    buffers     cached
Mem:       2028240    1824192     204048          0      70716     364212
-/+ buffers/cache:    1389264     638976
Swap:      3905532     157076    3748456

另请阅读:10 个自由命令示例

57.命令:mysqldump

好的,到目前为止,您应该已经从命令的名称中了解了该命令的实际含义。mysqldump 命令将所有或特定数据库数据转储(备份)到给定的文件中。例如,

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

注意mysqldump需要mysql正在运行并且需要正确的密码才能授权。我们在使用 mysqldump 命令进行数据库备份时介绍了一些有用的“mysqldump”命令

58.命令:mkpasswd

创建一个难以猜测的、指定长度的随机密码。

[avishek@tecmint ~]$ mkpasswd -l 10

zI4+Ybqfx9
[avishek@tecmint ~]$ mkpasswd -l 20 

w0Pr7aqKk&hmbmqdrlmk

注意-l 10生成10个字符的随机密码,而-l 20生成-l 20字符的密码strong>20,它可以设置为任何值以获得所需的结果。该命令非常有用,通常用脚本语言实现来生成随机密码。您可能需要yumapt“expect”包才能使用此命令。

[root@tecmint ~]# yum install expect 
OR
[root@tecmint ~]# apt-get install expect

59.命令:粘贴

使用以下命令合并两个或多个文本文件。例子。如果 file1 的内容是:

1 
2 
3 

and file2 was: 

a 
b 
c 
d 
the resulting file3 would be: 

1    a 
2    b 
3    c 
     d

60.命令:lsof

lsof 代表“列出打开的文件”,显示系统当前打开的所有文件。找出哪些进程使用某个文件或显示单个进程的所有文件非常有用。一些有用的 10 个 lsof 命令示例,您可能有兴趣阅读。

[avishek@tecmint ~]$ lsof 

COMMAND     PID   TID            USER   FD      TYPE     DEVICE SIZE/OFF       NODE NAME
init          1                  root  cwd       DIR        8,1     4096          2 /
init          1                  root  rtd       DIR        8,1     4096          2 /
init          1                  root  txt       REG        8,1   227432     395571 /sbin/init
init          1                  root  mem       REG        8,1    47080     263023 /lib/i386-linux-gnu/libnss_files-2.17.so
init          1                  root  mem       REG        8,1    42672     270178 /lib/i386-linux-gnu/libnss_nis-2.17.so
init          1                  root  mem       REG        8,1    87940     270187 /lib/i386-linux-gnu/libnsl-2.17.so
init          1                  root  mem       REG        8,1    30560     263021 /lib/i386-linux-gnu/libnss_compat-2.17.so
init          1                  root  mem       REG        8,1   124637     270176 /lib/i386-linux-gnu/libpthread-2.17.so
init          1                  root  mem       REG        8,1  1770984     266166 /lib/i386-linux-gnu/libc-2.17.so
init          1                  root  mem       REG        8,1    30696     262824 /lib/i386-linux-gnu/librt-2.17.so
init          1                  root  mem       REG        8,1    34392     262867 /lib/i386-linux-gnu/libjson.so.0.1.0
init          1                  root  mem       REG        8,1   296792     262889 /lib/i386-linux-gnu/libdbus-1.so.3.7.2
init          1                  root  mem       REG        8,1    34168     262840 /lib/i386-linux-gnu/libnih-dbus.so.1.0.0
init          1                  root  mem       REG        8,1    95616     262848 /lib/i386-linux-gnu/libnih.so.1.0.0
init          1                  root  mem       REG        8,1   134376     270186 /lib/i386-linux-gnu/ld-2.17.so
init          1                  root    0u      CHR        1,3      0t0       1035 /dev/null
init          1                  root    1u      CHR        1,3      0t0       1035 /dev/null
init          1                  root    2u      CHR        1,3      0t0       1035 /dev/null
init          1                  root    3r     FIFO        0,8      0t0       1714 pipe
init          1                  root    4w     FIFO        0,8      0t0       1714 pipe
init          1                  root    5r     0000        0,9        0       6245 anon_inode
init          1                  root    6r     0000        0,9        0       6245 anon_inode
init          1                  root    7u     unix 0xf5e91f80      0t0       8192 @/com/ubuntu/upstart
init          1                  root    8w      REG        8,1     3916        394 /var/log/upstart/teamviewerd.log.1 (deleted)

这还没有结束,系统管理员做了很多事情,为您提供一个如此漂亮的界面,供您工作。系统管理实际上是一门以非常完美的方式学习和实施的艺术。我们将尽力为您提供 Linux 专业人士必须学习的所有其他必要的东西,Linux 的基础实际上本身就是一个学习和学习的过程。我们总是寻求您的好话,这鼓励我们付出更多努力为您提供一篇知识渊博的文章。 “喜欢并分享我们,帮助我们传播”。