谢谢你你给了我们在这篇文章前两个部分的喜欢,美言和支持。在第一部分文章中我们讨论了那些都只是切换到 Linux 和linux新手所需的必要知识的用户的命令。 第二篇文章中我们讨论了中级用户管理自己的系统所需要的命令。 接下来呢?在这篇文章中我将解释管理 Linux 服务器所需的一些命令。 |
MtrS
|
41. 命令: ifconfigifconfig用来配置常驻内核的网络接口信息。在系统启动必要时用来设置网络适配器的信息。之后,它通常是只需要在调试时或当系统需要调整时使用。 检查活动网络适配器
检查所有的网络适配器“-a”参数用来显示所有网络适配器(网卡)的详细信息,包括那些停用的适配器。
停用网络适配器
|
1 | [avishek@tecmint ~]$ ifconfig eth0 down |
启用网络适配器
1 | [avishek@tecmint ~]$ ifconfig eth0 up |
指定IP地址到网络适配器
为网络适配器eth0设定IP地址“192.168.1.12”.
1 | [avishek@tecmint ~]$ ifconfig eth0 192.168.1.12 |
更改网络适配器eth0的子网掩码
1 | [avishek@tecmint ~]$ ifconfig eth0 netmask 255.255.255. |
更改网络适配器eth0的广播地址
1 | [avishek@tecmint ~]$ ifconfig eth0 broadcast 192.168.1.255 |
为网络适配器eth0指定IP地址,子网掩码,广播地址
1 | [avishek@tecmint ~]$ ifconfig eth0 192.168.1.12 netmask 255.255.255.0 broadcast 192.168.1.255 |
注Note: 如果你设置一块无线网卡的信息,你可以使用的命令是“iwconfig”.欲知更多ifconfig命令的例子和使用方法,读“15个有用的ifconfig 命令”.
MtrS
翻译于 6天前
3人顶
顶 翻译的不错哦!
42. 命令: netstatnetstat命令显示各种网络相关的信息,如网络连接,路由表,接口统计,伪装连接,组播成员身份等.... 列出所有的网络端口
显示所有tcp相关端口
|
01 | [avishek@tecmint ~]$ netstat -at |
02 |
03 | Active Internet connections (servers and established) |
04 | Proto Recv-Q Send-Q Local Address Foreign Address State |
05 | tcp 0 0 localhost:mysql *:* LISTEN |
06 | tcp 0 0 *:5901 *:* LISTEN |
07 | tcp 0 0 *:5902 *:* LISTEN |
08 | tcp 0 0 *:x11-1 *:* LISTEN |
09 | tcp 0 0 *:x11-2 *:* LISTEN |
10 | tcp 0 0 *:5938 *:* LISTEN |
11 | tcp 0 0 localhost:5940 *:* LISTEN |
12 | tcp 0 0 ravisaive-OptiPl:domain *:* LISTEN |
13 | tcp 0 0 ravisaive-OptiPl:domain *:* LISTEN |
14 | tcp 0 0 localhost:ipp *:* LISTEN |
15 | tcp 0 0 ravisaive-OptiPle:48270 ec2-23-21-236-70.c:http ESTABLISHED |
16 | tcp 0 0 ravisaive-OptiPle:48272 ec2-23-21-236-70.c:http TIME_WAIT |
17 | tcp 0 0 ravisaive-OptiPle:48421 bom03s01- in -f22.1:https ESTABLISHED |
18 | tcp 0 0 ravisaive-OptiPle:48269 ec2-23-21-236-70.c:http ESTABLISHED |
19 | tcp 0 0 ravisaive-OptiPle:39084 channel-ecmp-06-f:https ESTABLISHED |
20 | ... |
显示所有连接的统计信息
01 | [avishek@tecmint ~]$ netstat -s |
02 |
03 | Ip: |
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 |
10 | Icmp: |
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 |
20 | IcmpMsg: |
21 | InType3: 98 |
22 | InType5: 29362 |
23 | OutType3: 2918 |
24 | Tcp: |
25 | 94533 active connections openings |
26 | 23 passive connection openings |
27 | 5870 failed connection attempts |
28 | 7194 connection resets received |
29 | .... |
好的!由于某些原因如果你不想解析netstat 输出的主机、端口和用户名称的话 。
1 | [avishek@tecmint ~]$ netstat -an |
好,你可能需要获取的 netstat 持续输出的动态信息,通过传递中断输出指令 (ctrl + c)来停止。
1 | [avishek@tecmint ~]$ netstat -c |
更多关于“netstat”的例子和使用方法,浏览文章“20个netstat 的使用案例”。
MtrS
翻译于 6天前
1人顶
顶 翻译的不错哦!
43. 命令: nslookup网络实用程序,用于获得互联网服务器的信息。顾名思义,该实用程序将发现通过查询 DNS 域的名称服务器信息。
查询
邮件
交换器
记录
查询域名服务器
查询DNS记录
|
01 | [avishek@tecmint ~]$ nslookup - type =any tecmint.com |
02 |
03 | Server: 192.168.1.1 |
04 | Address: 192.168.1.1 #53 |
05 |
06 | Non-authoritative answer: |
07 | tecmint.com mail exchanger = 10 mailstore1.secureserver.net. |
08 | tecmint.com mail exchanger = 0 smtp.secureserver.net. |
09 | tecmint.com nameserver = ns06.domaincontrol.com. |
10 | tecmint.com nameserver = ns3404.com. |
11 | tecmint.com nameserver = ns3403.com. |
12 | tecmint.com nameserver = ns05.domaincontrol.com. |
13 |
14 | Authoritative answers can be found from: |
查询
起始
授权机构
01 | [avishek@tecmint ~]$ nslookup - type =soa tecmint.com |
02 |
03 | Server: 192.168.1.1 |
04 | Address: 192.168.1.1 #53 |
05 |
06 | Non-authoritative answer: |
07 | tecmint.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 |
16 | Authoritative answers can be found from: |
查询端口号
更改使用你想要连接的端口号
1 | [avishek@tecmint ~]$ nslookup -port 56 tecmint.com |
2 |
3 | Server: tecmint.com |
4 | Address: 50.16.76.239 #53 |
5 |
6 | Name: 56 |
7 | Address: 14.13.253.12 |
更多阅读 8个Nslookup 命令
MtrS
翻译于 6天前
2人顶
顶 翻译的不错哦!
44. 命令: digdig是查询DNS 域名服务器的工具,可以查询的主机地址、 邮件交流、 域名服务器相关的信息。在任何 Linux (Unix) 或 Macintosh OS X 操作系统上,都可以使用该工具。dig的最典型的用法是单个主机的查询。
关闭注释行
关闭认证块
关闭
其他
块
关闭 统计块
|
1 | [avishek@tecmint ~]$ dig tecmint.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< |
关闭回复块
1 | [avishek@tecmint ~]$ dig tecmint.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< |
关闭所有块
1 | [avishek@tecmint ~]$ dig tecmint.com +noall |
2 |
3 | ; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.17.rc1.el6 <<>> tecmint.com +noall |
4 | ;; global options: +cmd |
MtrS
翻译于 6天前
0人顶
顶 翻译的不错哦!
45.命令: uptime你连接到你的 Linux 服务器时发现一些不寻常或恶意的东西,你会做什么?猜测......不,绝不!你可以运行uptime来验证当服务器无人值守式到底发生了什么事情。
46. 命令: wall对系统管理员来说一个最重要的命令.wall发送一条消息到大家登录端将其 mesg 权限设置为"yes"。这条信息可以被wall作为参数,或者可以将它作为wall的标准输入。
|
MtrS
| ||||||||||||||||
其它翻译版本(1) |
47. 命令: mesg其他人们可以使用"wtrite"命令,将在在向您发送文本到屏幕上。你可以控制是否显示。
48. 命令: write如果 'mesg' 是 'y',让你的文本直接发送到另一台 Linux 机器的屏幕。.
49. 命令: talk增强的write命令,talk命令可让你与其他登录的用户交谈。
注释: 如果 talk 命令没安装的话,可以通过apt 或yum 安装所需的包.
|
MtrS
|
50. 命令:w是否觉得命令'w'很滑稽?但是事实上不是的。它是一个命令,尽管只有一个字符长!命令"w"是uptime和who命令,以前后的顺序组合在一起。
51. 命令: rename见名知意,这个命令重命名文件。rename将会通过从文件名的首字符开始替换,重命名为指定的文件名。
仅仅写这些命令:[@Lesus 注: 在Ubuntu上不支持这种格式, rename与mv不同的是,rename可以批量修改,如同带了while的mv操作。]
|
Lesus
|
52. 命令: top显示CPU进程信息。这个命令自动刷新,默认是持续显示CPU进程信息,除非使用了中断指令。
另查看 12 TOP命令例子 ·[@Lesus 注:htop比top命令更好用,不过需要自己安装 53. 命令: mkfs.ext4这个命令在指定的设备上创建一个新的ext4文件系统,如果这个命令后面跟的是个错误的设备,那么整个设备就会被擦除和格式化,所以建议不要运行这个命令,除非你清楚自己正在干什么。
更多查看: Ext4是什么及怎么创建和转换 |
Lesus
|
54. vi/emac/nano 命令vi (visual), emac, nano 是 linux 中最常用的一些编辑器。它们经常用于编辑文本,配置,… 等文件. A quick guide to work around vi and nano is, emac is a. vi 编辑器:
[按下‘i’键进入插入模式, 否则你不能输入任何内容]
nano 编辑器:
ctrl +x (关闭编辑器).它会显示如下的提示输出信息:
点击‘y’ 选择 yes 并输入文件名,就完成编辑了. |
赵亮-碧海情天
| ||||||||||||||||
其它翻译版本(1) |
55. 命令: rsyncRsync复制文件,参数-P开启进度条。如果你已经安装了rsync,你可以使用一个简单的别名。
现在尝试在终端复制一个大文件,这样将会看到显示剩余部分的输出,与进度条类似。 而且,保持和维护备份是系统管理员不得不做的最重要、最无聊的工作之一。Rsync是一个用于新建和维护备份的非常好用的终端工具(也存在许多其它工具)。
注意: -z表示压缩, -v表示详细信息,-r表示递归。 |
袁不语
|
56. 命令: free跟踪内存的使用和资源一样重要,就像管理员执行的任何其它任务,可以使用 'free' 命令来在这里救援. 当前内存使用状态Current Usage Status of Memory
设置输出单位为KB,MB或GB
以可读的格式显示,检查当前内存使用
设定
时间间隔
后
,持续检查
使用状态
阅读更多10个Free命令使用实例 |
MtrS
|
57. mysqldump 命令好了,现在你从名字上就能明白这个命令所代表的作用。mysqldump 命令会转储(备份)数据库的全部或特定一部分数据到一个给定的文件中。例如:
注意: mysqldump 需要 mysql 在运行中并且有正确的授权密码。我们在 用mysqldump命令备份数据库中讨论了一些有用的 “mysqldump” 命令用法。 |
赵亮-碧海情天
|
58. mkpasswd 命令根据指定的长度,产生一个难猜的随机密码。
注意: -l 10 产生一个10个字符的随机密码,而-l 20 产生 20个字符的密码,它可以设置为任意长度来取得所希望的结果。这个命令很有用,经常在脚本语言里使用来产生随机的密码。你可能需要 yum 或 apt ‘expect’ 包来使用这个命令。
|
赵亮-碧海情天
|
59. Command: paste合并两个或多个文本文件,按行来进行合并。示例。如果 file1 的内容是:
60.Command: lsoflsof 是"list open files("列表中打开的文件") 的缩写,显示您的系统当前已打开的所有文件。这是非常有用的对于想找出哪些进程使用某一特定文件,或显示为单个进程打开所有文件。一些有用的 10 个lsof 命令示例,你可能会感兴趣阅读。
这里并没有结束,系统管理员会很多东西,为你提供漂亮的界面,服务于你的工作。系统管理实际上是学习和实现的一门优雅的艺术。我们会尽力给你介绍 linux 专业人员必须了解的知识以及一些其他必要东西,linux本身是基础的,简单的。深入理解是不断学习的过程。你的美言好词总是在不断鼓励我们写出更多的优秀,丰富的文章。"喜之以分享,助我来传播"。 |