Linux 典型运维应用
Last updated
Was this helpful?
Was this helpful?
启动:systemctl start firewalld
关闭:systemctl stop firewalld
查看状态:systemctl status firewalld
开机禁用:systemctl disable firewalld
开机启用:systemctl enable firewalld启动一个服务:systemctl start firewalld.service
关闭一个服务:systemctl stop firewalld.service
重启一个服务:systemctl restart firewalld.service
显示一个服务的状态:systemctl status firewalld.service
在开机时启用一个服务:systemctl enable firewalld.service
在开机时禁用一个服务:systemctl disable firewalld.service
查看服务是否开机启动:systemctl is-enabled firewalld.service
查看已启动的服务列表:systemctl list-unit-files|grep enabled
查看启动失败的服务列表:systemctl --failed查看版本:firewall-cmd --version
查看帮助:firewall-cmd --help
显示状态:firewall-cmd --state
查看所有打开的端口:firewall-cmd --zone=public --list-ports
更新防火墙规则:firewall-cmd --reload
查看区域信息: firewall-cmd --get-active-zones
查看指定接口所属区域:firewall-cmd --get-zone-of-interface=eth0
拒绝所有包:firewall-cmd --panic-on
取消拒绝状态:firewall-cmd --panic-off
查看是否拒绝:firewall-cmd --query-panic添加:firewall-cmd --zone=public --add-port=80/tcp --permanent (--permanent永久生效,没有此参数重启后失效)
重新载入:firewall-cmd --reload
查看:firewall-cmd --zone= public --query-port=80/tcp
删除:firewall-cmd --zone= public --remove-port=80/tcp --permanentTYPE=Ethernet # 网络类型:Ethernet以太网
BOOTPROTO=none # 引导协议:自动获取、static静态、none不指定
DEFROUTE=yes # 启动默认路由
IPV4_FAILURE_FATAL=no # 不启用IPV4错误检测功能
IPV6INIT=yes # 启用IPV6协议
IPV6_AUTOCONF=yes # 自动配置IPV6地址
IPV6_DEFROUTE=yes # 启用IPV6默认路由
IPV6_FAILURE_FATAL=no # 不启用IPV6错误检测功能
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_PRIVACY="no"
NAME=eno16777736 # 网卡设备的别名(需要和文件名同名)
UUID=90528772-9967-46da-b401-f82b64b4acbc # 网卡设备的UUID唯一标识号
DEVICE=eno16777736 # 网卡的设备名称
ONBOOT=yes # 开机自动激活网卡
IPADDR=192.168.1.199 # 网卡的固定IP地址
PREFIX=24 # 子网掩码
GATEWAY=192.168.1.1 # 默认网关IP地址
DNS1=8.8.8.8 # DNS域名解析服务器的IP地址yum -y install ntpsystemctl start ntpd.service/sbin/iptables -A INPUT -p UDP -i eth0 -s 192.168.0.0/24 --dport 123 -j ACCEPT/usr/sbin/ntpdate ntp.sjtu.edu.cnecho "* 3 * * * /usr/sbin/ntpdate ntp.sjtu.edu.cn" >> /etc/crontab
systemctl restart crond.service#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
/opt/pjt_test/test.pl不同的运行级定义如下:
# 0 - 停机(千万不能把initdefault 设置为0 )
# 1 - 单用户模式 进入方法#init s = init 1
# 2 - 多用户,没有 NFS
# 3 - 完全多用户模式(标准的运行级)
# 4 - 没有用到
# 5 - X11 多用户图形模式(xwindow)
# 6 - 重新启动 (千万不要把initdefault 设置为6 )$ runlevel
N 3# 98 为启动序号
# 2 是系统的运行级别,可自己调整,注意不要忘了结尾的句点
$ update-rc.d mysql start 98 2 .# 启动服务
systemctl start crond.service
# 停止服务
systemctl stop crond.service
# 重启服务
systemctl restart crond.service
# 重新载入配置
systemctl reload crond.service
# 查看状态
systemctl status crond.serviceSHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
# 每天早上3点时钟同步
* 3 * * * /usr/sbin/ntpdate ntp.sjtu.edu.cn
# 每两个小时以root身份执行 /home/hello.sh 脚本
0 */2 * * * root /home/hello.sh$ sed -i 's/id:5:initdefault:/id:3:initdefault:/' /etc/inittab