Record common commands in daily development of Linux
Article Directory
start java program
(1) Start directly, and close the application when the console exits
java -jar xxxxxx.jar
(2) Background startup, console exit will not turn off the application
nohup java -jar xxxxxx.jar &
(3) Start the background and output the log, the console exit will not turn off the application
nohup java -jar xxxxxx.jar >> ./projectStart.log 2>&1 &
(4) Start in the background (add memory) and output logs, console exit will not turn off the application
nohup java -jar -Xms1024m -Xmx2048m xxxxxx.jar>> ./projectStart.log 2>&1 &2>&1 &
turn off an app
(1) Query the java application process (grep is followed by conditional filtering)
ps -ef | grep java
(2) Forcibly kill the process
kill -9 process number
View port netstat
netstat -nltp //Note: View all ports
netstat -ano | grep :8081 //Note: View the programs running on port 8081
netstat -ano | grep :8081 |wc -l //Note: View the total number of connections on port 8081
Firewall command: firewall
Close the firewall or open the port so that other hosts can access it
systemctl start firewalld //Comment: Open the firewall
systemctl stop firewalld //Comment: Close the firewall
systemctl status firewalld //Comment: View the firewall status
firewall-cmd --zone=public --list-ports //Comment: View all ports opened by the firewall Port
firewall-cmd --permanent --zone=public --add-port=8081/tcp //Note: Add a firewall to open ports to the outside world (add a single port)
firewall-cmd --reload //Note: Reload the firewall configuration
firewall -cmd --zone=public --list-ports //Note: View all ports opened by the firewall
nginx related: start stop restart
-
The executable directory sbin starts nginx
/usr/local/nginx/sbin/nginx
or first enters the executable directory sbin
cd /usr/local/nginx/sbin/
and then executes
./nginx // Note: start
./nginx -s stop //Note: Stop method 1
./nginx -s quit //Note: Stop method 2
./nginx -s reload //Note: Restart -
nginx.service starts nginx
cd /usr/lib/systemd/system/
This directory must have nginx.service, if not, it must be configured, otherwise the following commands cannot be executed:
systemctl start nginx.service // Note: start nginx
systemctl stop nginx.service //Note: Stop nginx
systemctl restart nginx.service //Note: Restart nginx
systemctl status nginx.service //Note: View the current nginx status Execution results are divided into two types>> Active: failed [This means it is closed] Active: active (running) [this indicates the running state] -
The configuration file is specified to start nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
Note: nginx installation directory path -c nginx configuration file path parameter -c specifies the configuration file path, if not specified, the default configuration file is used
Full disk search by filename
find / -name xxxxxx.txt // Note: / can be followed by a path to limit which directory, -name is followed by the target file name to be searched
Common errors (continuously updated)
- -bash: ./startup.sh: Permission denied
Reason: This is because there is no execution permission. Just add execute permissions.
Solution: Add execution permission to the target file
chmod +x xxxxxx.sh or chmod 777 xxxxxx.sh