pstree -p 显示进程的pid
-u 显示进程的所属用户。
service 本质就是进程,但是是运行在后台的,通常会监听端口。等待其他程序的请求,比如(mysqld.sshd 防火墙等)因此又称为守护进程,
service 服务名 客户端通过端口连接服务。
service 服务名 start启动 stop 停止 restart重启 reload重载 status 查看状态
systemctl 服务名 centOS7.0使用
serice 其指令管理在/etc/init.d
setup
时间不对
yum install -y ntpdate 安装ntpdate
264 rm -rf /etc/localtime 删除文件, 复制上海的时区替换
265 cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
266 ntpdate -u ntp.api.bz 更新时间,
267 date 查看时间对不对
service 运行级别
0系统停机状态,runlevel运行级别
1单用户状态,root权限,用户系统维护,进制远程登录
2多用户状态没有NFS 不知网络
3完全的多用户状态,登录后进入控制台命令行模式,
4系统未使用保留
5X11控制台,登录后进入图形GUI模式
6 系统正常关闭并重启,默认运行级别不设为6 否则不能正常使用
开机流程-->BIOS--->/boot—>systemd进程--->运行级别—>运行级对应的服务
CentOS7 后运行级别说明,
在/etc/initab
multi-user.target:analogus to runleve 3 运行级别
graphicl.target:analogus to runleve 5 图形化界面5运行级别
systemctl get-defult 进入3运行级别
systemctl set-default graphical.target 设置为图形化界面
reboot 重启后会进入设置的界面
chkconfig
可以给服务的各各运行级别设置自,启动,关闭
chkconfig 指令管理的服务在/etc/init.d 查看
chkconfig ---list [|grep xx] 过滤只查看,该服务
chkconfig 服务名 --list
chkconfig ---level 5服务名 on /off
chkconfig 重新设置后自启动或关闭,需要重启机器reboot生效
案例演示,
把network在3运行级别。关闭自启动
chkonfig --level 3 network off
chkconfig --level 3 network on
systemctl 指令管理在 /usr/lib/system
systemctl list-unit-files [|grep 服务名] 查看服务开机启动状态,grep 可以进行过滤
systemctl enable 服务名,设置开机启动
systemctl disable 服务名 关闭服务器开机启动
systemctl is-enabled 服务名 查询某个服务是否会自启动的
查看当前防火墙状态,关闭防火墙,和重启防火墙。
systemctl status firewalld 查看
systemctl stop firewalld(这里是简写,)
只能暂时起效,服务器重启后,会还原,
若想让某个服务,自启动,或关闭永久生效,要使用,systemctl [enable| disable]服务名,
在生产环境中,是需要将制定的端口打开的。
打开端口firewall-cmd --permanent --add-port=端口号/协议
管闭端口firewall-cmd --permanent --remove-port=端口号/协议
重新载入才有效,firewall-cmd --reoad
查询是否开放,firewall-cmd --query-port=端口号/协议、
端口号,协议要懂,
案例,
启用防火墙,
firewall-cmd --permanent --add-port=111/tcp;firewall-cmd --reoad重新载入。
关闭
--remove-port=111/tcp
网友评论