设置开机自启不好使
记得reboot重启
任务 | 旧指令 | 新指令 |
---|---|---|
使某服务开机启动 | chkconfig --level 3 httpd on | systemctl enable httpd.service |
使某服务不开机启动 | chkconfig --level 3 httpd off | systemctl disable httpd.service |
启动某服务 | service httpd start | systemctl start httpd.service |
停止某服务 | service httpd stop | systemctl stop httpd.service |
重启某服务 | service httpd restart | systemctl restart httpd.service |
检查服务状态 | service httpd status | systemctl status httpd.service (服务详细信息) systemctl is-active httpd.service (仅显示是否 Active) |
显示所有已启动的服务 | chkconfig --list | systemctl list-units --type=service |
开启防火墙22端口
iptables -I INPUT -p tcp --dport 22 -j ACCEPT
如果仍然有问题,就可能是SELinux导致的
关闭SElinux:
修改/etc/selinux/config文件中的SELINUX=""为disabled,然后重启
彻底关闭防火墙:
sudo systemctl status firewalld.service
sudo systemctl stop firewalld.service
sudo systemctl disable firewalld.service //sudo是临时使用root权限执行命令
chkconfig
[root@localhost ~]# chkconfig [选项] [服务名]
选项:
–add: 把服务加入 chkconfig 命令的管理
–del: 把服务从 chkconfig 命令的管理中删除
#chkconfig: 运行级别 启动顺序 关闭
例如
[root@localhost ~]# chkconfig –del httpd
#把 apache 服务从 chkconfig 命令的管理中删除
[root@localhost ~]# chkconfig --list
abrt-ccpp 0:关闭 1:关闭 2:关闭 3:启用 4:关闭 5:启用 6:关闭
abrt-oops 0:关闭 1:关闭 2:关闭 3:启用 4:关闭 5:启用 6:关闭
#–list:列出 RPM 包默认安装的所有服务的自启动状态;
服务分类
RPM 包默认安装的服务
这些服务是通过 RPM 包安装的,可以被服务管理命令识别。又分为两种子分类:
独立的服务:就是独立启动的意思,这类型的服务可以自行启动,而不用依赖其他的管
理服务。不依赖其他管理服务,那么当客户端请求访问时,独立的服务响应请求更快速。
Linux 中目前大多数服务都是独立的服务,比如 apache 服务,FTP 服务,Samba 服务等。
基于 xinetd 的服务:这种服务就不能独立启动了,而是要依靠管理服务来调用这种服
务。这个负责管理的服务就是 xinetd 服务,xinetd 服务是系统的超级守护进程。xinetd
服务的作用就是管理不能独立启动的服务,当有客户端请求时,先请求 xinetd 服务,
由 xinetd 服务去唤醒相对应的服务。当客户端请求结束后,被唤醒的服务会关闭并释
放资源。这样做的好处是只需要持续启动 xinetd 服务,而其他基于 xinetd 的服务只有
在需要时才启动,不会占用过的的服务器资源。但是这种服务由于在有客户端请求时才
会被唤醒,所以相应时间相对较慢。