Quick Retrieve on Google     Quick Retrieve on Bing

Combine Art and Sciences

Blogs transfered from: blog.csdn.net/sonictl

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Linux 网络、Daemon、systemd 相关命令

=== CentOS 7+ 网络、Daemon 相关命令 ===

包含了centos system 中 firewalld, port occupation, systemd service management 相关常用命令。

1. firewalld

firewall-cmd --permanent --add-port=100/tcp # open specific port
firewall-cmd --permanent --add-port=200-300/tcp
firewall-cmd --permanent --add-service=http # open port for service
firewall-cmd --reload # take changes into effect
firewall-cmd --list-ports # check the ports opened.
firewall-cmd --list-services # check the service
iptables-save # check all currently applied rules

2. port

netstat -tlunp # display all ports opened in host
lsof -i # list the network open ports
netstat -lptu # the process that owns them
netstat -tulpn # You can add " | grep "kw1|kw2|kw3' " for keywords grep

3. daemon 守护与开机(开机启动可用)

vim /etc/rc.d/rc.local # edit script in this file for script running at boot
vim ~.bash_profile # exe script at log on. and ~.bash_logout for log out.
shutdown -r now
systemctl reboot # Reboot to verify scripts launching during system boot

4. systemd(开机启动可用)

vim /etc/systemd/system/sample.service

		[Unit]
		Description=Description for sample script goes here
		After=network.target

		[Service]
		Type=simple
		ExecStart=/var/tmp/test_script.sh
		TimeoutStartSec=0

		[Install]
		WantedBy=default.target

systemctl daemon-reload
systemctl enable sample.service
systemctl start sample.service
systemctl list-unit-files | grep enabled # list all enabled ones.
systemctl list-unit-files | grep disabled # list all disabled ones.

posted on 2020-04-14 12:14  sonictl  阅读(316)  评论(0)    收藏  举报