CentOS7 firewall and system service operations

Firewall

1
2
3
4
5
6
7
8
firewall-cmd --state  #check the firewall on centos 7 running state:

systemctl stop firewalld.service #Stop the firewall

systemctl disable firewalld.service #disable the auto-startup of firewall

firewall-cmd --zone=public --list-ports # list all open ports

more operations on centos 7 firewall:
https://www.cnblogs.com/heqiuyong/p/10460150.html

System service

create service config file.

1
2
cd /etc/systemd/system
vim subtitlex.service

edit below 2 files
./subtitlex.service

1
2
3
4
5
6
7
[Unit]
Description=SubtitleX
After=network.target
[Service]
ExecStart=/root/subtitlex/sh/start_goapi.sh
[Install]
WantedBy=default.target

/root/subtitlex/sh/start_goapi.sh

1
2
3
cd /home/elvin/subtitlex/goapi/
./goapi
echo "goapi started"

Continue to enable and start the service

1
2
3
systemctl enable subtitlex.service
systemctl start subtitlex.service
systemctl status subtitlex.service