For personal notes only


Linux operating system > [Linux command of (manual)] (https://www.linuxcool.com/)Copy the code

Common Linux Commands

1. The firewall
# check the process that occupies the port.
netstat -tunlp | grep port
# View open firewall ports
firewall-cmd --list-ports
Enable firewall specific ports
# --zone scope
# --add-port Open port
# -- whether permanent takes effect permanently (default)
firewall-cmd --zone=public --add-port=80/tcp --permanent
# restart firewall
firewall-cmd --reload
# enable firewall
systemctl start firewalld
# stop firewall
systemctl stop firewalld.service
Copy the code
2. File operations
#Enable reverse match command (otherwise special characters such as parentheses cannot be recognized)
shopt -s extglob
 
#Disable the unselected match command
shopt -u extglob

#Delete all files except some files/directoriesrm -rf ! (node-server.tar.gz|dist)Copy the code
3. The PM2 operation
#Start the
pm2 start app.js

pm2 restart app_name
pm2 reload app_name
pm2 stop app_name
pm2 delete app_name

#View all processes
pm2 list

#View process details (serverName Process name)
pm2 show serverName
Copy the code

Nginx related commands

#Start the 
nginx
#restart
nginx -s reload
#stop
nginx -s stop
nginx -s quit
Copy the code

Common Docker commands

#Start the Docker service
service docker start
#Start the Docker background service
systemctl start docker
#Restart the Docker daemon
systemctl daemon-reload
#Restart the Docker service
systemctl restart docker

#Docker pulls the imageDocker pull Image alias: version number#--node-cache does not use caching
docker build --rm --no-cache=true  -t node-server .
#Remove the mirrorDocker RMI image ID#Example Delete an image: Docker RMI button-API /v2
docker rmi REPOSITORY/TAR
#Viewing the Mirror List
docker images

#To view the list of containers, do not add -a to view running containers, add -a to view all containers
docker ps -a
#Remove the containerDocker rm Container ID/ container alias#Start the container
#(-d background run, --name container alias, -p host port: container port, --network bridge network alias, and finally mirror name: mirror version)Docker run -d --restart always --name Jianghu-server -p 3006:3006 node-server:1.0.0#Close an started containerDocker stop Container ID/ container alias#Start a closed containerDocker start Container ID/ container alias#View the details of a containerDocker inspect Container ID/ container alias#Inside the containerDocker exec -it Container ID/ container alias /bin/bash
#Create a network in bridge mode with local-net as the network alias
docker network create -d bridge local-net
#View network configuration details
docker network inspect local-net

#Configuring a Mirror TagDocker tag vue - BPMN - image: 1.0.0 192.168.1.98 / docker - steps/vue - BPMN - image: 1.0.0#Publish image to remote server (need to tag first)Docker push 192.168.1.98 / docker - steps/vue - BPMN - image: 1.0.0Copy the code