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


谢谢你你给了我们在这篇文章前两个部分的喜欢,美言和支持。在第一部分文章中我们讨论了那些都只是切换到 Linux 和linux新手所需的必要知识的用户的命令。

对 Linux 新手非常有用的 20 个命令

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

对中级 Linux 用户非常有用的 20 个命令

接下来呢?在这篇文章中我将解释管理 Linux 服务器所需的一些命令。

1. 命令: ifconfig

ifconfig用来配置常驻内核的网络接口信息。在系统启动必要时用来设置网络适配器的信息。之后,它通常是只需要在调试时或当系统需要调整时使用。

检查活动网络适配器

  1. [avishek@tecmint ~]$ ifconfig 
  2. eth0      Link encap:Ethernet  HWaddr 40:2C:F4:EA:CF:0E 
  3. inet addr:192.168.1.3  Bcast:192.168.1.255  Mask:255.255.255.0 
  4. inet6 addr: fe80::422c:f4ff:feea:cf0e/64 Scope:Link 
  5. UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1 
  6. RX packets:163843 errors:0 dropped:0 overruns:0 frame:0 
  7. TX packets:124990 errors:0 dropped:0 overruns:0 carrier:0 
  8. collisions:0 txqueuelen:1000 
  9. RX bytes:154389832 (147.2 MiB)  TX bytes:65085817 (62.0 MiB) 
  10. Interrupt:20 Memory:f7100000-f7120000 
  11. lo        Link encap:Local Loopback 
  12. inet addr:127.0.0.1  Mask:255.0.0.0 
  13. inet6 addr: ::1/128 Scope:Host 
  14. UP LOOPBACK RUNNING  MTU:16436  Metric:1 
  15. RX packets:78 errors:0 dropped:0 overruns:0 frame:0 
  16. TX packets:78 errors:0 dropped:0 overruns:0 carrier:0 
  17. collisions:0 txqueuelen:0 
  18. RX bytes:4186 (4.0 KiB)  TX bytes:4186 (4.0 KiB) 

检查所有的网络适配器

“-a”参数用来显示所有网络适配器(网卡)的详细信息,包括那些停用的适配器。

  1. [avishek@tecmint ~]$ ifconfig -a 
  2. eth0      Link encap:Ethernet  HWaddr 40:2C:F4:EA:CF:0E 
  3. inet addr:192.168.1.3  Bcast:192.168.1.255  Mask:255.255.255.0 
  4. inet6 addr: fe80::422c:f4ff:feea:cf0e/64 Scope:Link 
  5. UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1 
  6. RX packets:163843 errors:0 dropped:0 overruns:0 frame:0 
  7. TX packets:124990 errors:0 dropped:0 overruns:0 carrier:0 
  8. collisions:0 txqueuelen:1000 
  9. RX bytes:154389832 (147.2 MiB)  TX bytes:65085817 (62.0 MiB) 
  10. Interrupt:20 Memory:f7100000-f7120000 
  11. lo        Link encap:Local Loopback 
  12. inet addr:127.0.0.1  Mask:255.0.0.0 
  13. inet6 addr: ::1/128 Scope:Host 
  14. UP LOOPBACK RUNNING  MTU:16436  Metric:1 
  15. RX packets:78 errors:0 dropped:0 overruns:0 frame:0 
  16. TX packets:78 errors:0 dropped:0 overruns:0 carrier:0 
  17. collisions:0 txqueuelen:0 
  18. RX bytes:4186 (4.0 KiB)  TX bytes:4186 (4.0 KiB) 
  19. virbr0    Link encap:Ethernet  HWaddr 0e:30:a3:3a:bf:03 
  20. inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0 
  21. UP BROADCAST MULTICAST  MTU:1500  Metric:1 
  22. RX packets:0 errors:0 dropped:0 overruns:0 frame:0 
  23. TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 
  24. collisions:0 txqueuelen:0 
  25. RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B) 

停用网络适配器

  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 命令”。


相关内容