Linux的常用命令

网络通信命令

网络通信命令 ifconfig

  • 命令名称:ifconfig
  • 命令所在路径:/usr/sbin/ifconfig
  • 执行权限:所有用户
  • 功能描述:查看网络设置信息
  • 语法:
ifconfig 选项[-a] [网卡设备标识]
// -a  显示所有网卡信息
  • 范例:
ifconfig  -a
  • 示例图:
    Linux(15)_命令语法_网络通信命令 & 防火墙 & 系统命令

网络通信命令 ping

  • 命令名称:ping
  • 命令所在路径:/usr/sbin/ping
  • 执行权限:root
  • 功能描述:测试网络连通性
  • 语法:
ping 选项IP地址
  • 范例:
ping 192.168.43.35
ping www.baidu.com
  • 示例图:
    Linux(15)_命令语法_网络通信命令 & 防火墙 & 系统命令

关于防火墙

  • 查看防火墙状态:
service iptables status

示例图:
Linux(15)_命令语法_网络通信命令 & 防火墙 & 系统命令

  • 开启防火墙,即时生效,虚拟机重启后失效:
service iptables start  
// 开启 

service iptables stop
// 关闭

示例图:
Linux(15)_命令语法_网络通信命令 & 防火墙 & 系统命令

  • 开启防火墙,重启后永久性生效:
chkconfig iptables on
// 开启   

chkconfig iptables off   
// 关闭

注意当上述命令执行的时候出现如下错误:

Linux(15)_命令语法_网络通信命令 & 防火墙 & 系统命令
解决办法

  • ① 使用 systemctl
systemctl [start|stop|restart|save|status] iptables.service
  • ② 安装 iptables-services
切换到root用户下,执行:

yum install iptables-services
systemctl enable iptables.service //设置开机启动

之后就可以使用以下指令了:
service iptables [start|stop|restart|save|status]

管理防火墙也可以使用图形界面

  • 由于在 SecureCRT 当中操作不便,不建议直接在 SecureCRT 当值执行 setup 命令;建议直接到虚拟机当中打开终端执行。
    Linux(15)_命令语法_网络通信命令 & 防火墙 & 系统命令
    Linux(15)_命令语法_网络通信命令 & 防火墙 & 系统命令
    Linux(15)_命令语法_网络通信命令 & 防火墙 & 系统命令
    Linux(15)_命令语法_网络通信命令 & 防火墙 & 系统命令
  • 此种方式是也是永久生效的,但不建议使用这种方法,因为我们很少使用图形化界面。

系统命令

系统命令 shutdown

  • 命令名称:shutdown
  • 命令所在路径:/usr/sbin/shutdown
  • 执行权限:root
  • 功能描述:关机
  • 语法:
shutdown
  • 范例:
shutdown -h now
// 立马关机

系统命令 reboot

  • 命令名称:reboot
  • 命令所在路径:/usr/sbin/reboot
  • 执行权限:root
  • 功能描述:重启系统
  • 语法:
reboot
  • 范例:
reboot
  • 示例图:
    Linux(15)_命令语法_网络通信命令 & 防火墙 & 系统命令

系统命令 su

  • 切换用户
  • 示例图:
    Linux(15)_命令语法_网络通信命令 & 防火墙 & 系统命令
    Linux(15)_命令语法_网络通信命令 & 防火墙 & 系统命令

如有错误,欢迎指正!

相关文章:

  • 2021-10-27
  • 2022-12-23
  • 2022-02-08
  • 2021-10-04
  • 2021-12-31
  • 2021-11-29
  • 2021-09-30
  • 2021-06-11
猜你喜欢
  • 2021-12-10
  • 2021-12-10
  • 2022-03-02
  • 2021-08-05
  • 2021-07-03
  • 2021-12-02
  • 2021-12-24
相关资源
相似解决方案