day14 服务管理篇的学习
day14 服务管理的学习
1.Linux的默认提供的服务
1. shhd 的命令
[root@linux-yzk ~]# netstat -tnlp | grep 'sshd'
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1137/sshd
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 3029/sshd: root@pts
tcp6 0 0 :::22 :::* LISTEN 1137/sshd
tcp6 0 0 ::1:6010 :::* LISTEN 3029/sshd: root@pts
[root@linux-yzk ~]#
## 可以看出sshd 的服务是被22端口所监听
学习了centos7我们可以开启,关闭,重启,查看效果
命令如下形式
systemctl start/stop/status/restart 服务名
举个例子:列如 sshd 服务
查看状态:
systemctl status sshd
开启服务:
systemctl start sshd
重启服务:
systemctl restart sshd
停止服务:
systemctl stop sshd
2.对于chkconfig 指定的服务是否开机自启动
但是已经被systemctl取代,这个命令变得更加的强大
备注
在centos7中,service启停服务的命令和 chkconfig命令,都被统一整合为了systemctl
并且你依然可以使用旧的命令,系统会自动的转变为systemctl去执行。
做了向下兼容的操作,新命令,兼容旧命令。
3.从centos7开始一般使用的是systemctl 命令它同时兼备啦service 和 chkconfig命令
4.systemctl 命令
- systemctl (system control )用于控制systemd 系统和服务的管理
NAME
systemctl - Control the systemd system and service manager
#管理系统和管理服务
SYNOPSIS 语法
systemctl [OPTIONS...] COMMAND [NAME...]
命令 参数 要控制的服务
DESCRIPTION
systemctl may be used to introspect and control the state of the "systemd" system
and service manager. Please refer to systemd(1) for an introduction into the
basic concepts and functionality this tool manages.
# 这个描述,自己翻译
-
这几个命令代替啦 service 服务名 start /stop/等等
-
start 指定启动unit
-
stop 指定停止unit
-
restart 指定重启unit
-
status 指定状态unit
-
reload 指定重载unit
-
is-enable 查看是否开机自启动
5.修改网络的模式。修改静态的IP,动态的ip获取的方式
system control 系统的控制 简称->systemctl
[root@linux-yzk ~]# systemctl is-enabled network
network.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig network --level=5
enabled #开启的
[root@linux-yzk ~]#
6.这个是网络的链接的日志
[root@linux-yzk ~]# cd /etc/sysconfig/network-scripts/
[root@linux-yzk network-scripts]# ll
总用量 252
-rw-r--r--. 1 root root 279 2月 19 19:09 ifcfg-ens33
-rw-r--r--. 1 root root 254 5月 22 2020 ifcfg-lo
lrwxrwxrwx. 1 root root 24 12月 17 00:03 ifdown -> ../../../usr/sbin/ifdown
7.需要关闭,禁用centos7在图形化下设置网络的服务,同时管理WIFI 和有线网络
服务的名称 NetworkMananger
systemctl satrt NetworkMananger # 关闭管理
开机自启动 systemctl enable NetworkManager
[root@linux-yzk network-scripts]# systemctl is-enabled NetworkManager
enabled
[root@linux-yzk network-scripts]#
8.启动网络的服务的命令
systemctl status network
9.通过命令获取ip的信息
ifconfig
或者
ip addr

10.改静态ip的步骤
1.桥接:
你的linux采用桥接,等于你去这个路由器分配的局域网中,拿走一个ip,等于教室多了一个学生
2.nat:
可以理解为-> 主机网络地址的分配
- 确认你所在的网段环境 (10.96.0.xx)
- 确认网关
- 填写dns服务器地址
- 修改网卡为 static模式
浙公网安备 33010602011771号