• 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.
  • 相关阅读:
    C++解析(5):内联函数分析
    C++解析(4):引用的本质
    C++解析(3):布尔类型与三目运算符
    C++解析(2):进化后的 const 分析
    C++解析(1):C到C++的升级
    net与树莓派的情缘(二)
    net与树莓派的情缘(一)
    Ngin 简单配置文件
    sql geography类型(地理坐标) 赋值
    MongoDB与c#(二)简单例子 使用1.7版本驱动
  • 原文地址:https://www.cnblogs.com/sonictl/p/12697121.html
Copyright © 2020-2023  润新知