linux命令修改网络 linux更改网络( 三 )


systemctl disable crond.service //禁止开机启动
systemctl status crond.service//查看服务状态
systemctl start crond.service //启动服务
systemctl stop crond.service//停止服务
systemctl restart crond.service//重启服务
systemctl is-enabled crond.service//查看某个服务是否开机启动
unit /usr/lib/systemd/system 此目录下列出了很多文件,这些文件都是unit 。类别如下:
service 系统服务target 多个unit组成的组device 硬件设备mount 文件系统挂载点automount 自动挂载点path 文件或路径scope 不是由systemd启动的外部进程slice 进程组snapshot systemd快照socket 进程间通信的套接字swap swap文件timer 定时器
target target类似于centos6的启动级别,target内又包含多个unit的组合,当然target内也可以包含target 。启动target就是启动多个unit,用target来管理这些unit 。
[root@cent01 ~]# systemctl list-units --all --type=target//查看当前所有的target
UNITLOADACTIVESUBDESCRIPTION
basic.targetloadedactiveactive Basic System
bluetooth.targetloadedactiveactive Bluetooth
[root@localhost ~]# systemctl list-dependencies multi-user.target
multi-user.target
● ├─abrt-ccpp.service
● ├─abrt-oops.service
● ├─abrt-vmcore.service
● ├─abrt-xorg.service
[root@localhost ~]# systemctl get-default//查看系统默认的target
multi-user.target
systemctl set-default multi-user.target//设置默认的target
multi-user.target等同于centos6的运行级别3 。他们的对应关系如下:
SysV运行级别systemd target备注
0poweroff.target关闭系统
1rescure.target单用户模式
2multiuser.target用户自定义级别,通常识别为3
3multiuser.target多用户命令行模式
4multiuser.target用户自定义级别,通常识别为3
5graphical.target多用户图形界面,比级别3只多一个GUI
6reboot.target重启
所以总结起来,一个service属于一种unit , 多个unit组成一个target , 当然target里面也可以包含target 。
1.4、ifconfig命令配置IP网络参数
格式:
[root@localhost /]#ifconfig [网络设备] [ip地址] [MAC地址] [netmask掩码地址] [broadcast广播地址(NDC)] [up/down]
[root@localhost /]#ifconfig eth0 192.168.74.130 netmask 255.255.255.0 up
用ifconfig命令配置eth0别名设备 , 为eth0绑定多个IP地址 。
[root@localhost /]#ifconfig eth0:1 192.168.74.130
[root@localhost /]#ifconfig eth0:2 192.168.73.130
1.5、使用routedel命令添加路由
格式:
[root@localhost /]#routedel [-net|host] [网域或主机] netmask [mask] [gw]
[root@localhost /]#route #查看路由信息
功能:添加路由
-net : 表示后面接的路由为一个网络 。
-host : 表示后面接的为连接到单部主机的路由 。
netmask : 与网络有关,可以设定netmask决定网路的大小 。
gw : gateway (网关)的简写 , 后面接的是ip地址 。
1.6、使用hostname命令修改主机名称
[root@localhost /]#hostname service.jw.com
hostnamectl set-hostname nod1
Linux——网络配置命令一、ifconfig
自ubuntu17起linux命令修改网络,已经不提供这个命令了linux命令修改网络,要自动安装
sudo apt installnet-tools
ifconfig -a :查看当前系统所有linux命令修改网络的网络接口
ifconfiginterface(PS:这里是网络接口的名称) downlinux命令修改网络:禁用当前网络接口
ifconfiginterface up :启用网络接口
二、ip命令
1、管理网络接口
1)、ip link list显示网络设备的运行状态
2)、ip -s link list 显示更详细的网络设备运行状态
4)、ip link set dev ens33 mtu 1600: 改变网络设备最大传输单元 MTU的值为1600

推荐阅读