Linux basic operation notes

Posted by Pavel_Nedved on Fri, 07 Jan 2022 09:19:56 +0100

Common commands

Enter directory
cd /usr #Enter the usr directory
View catalog file
ls #View all files in the current directory
ll #View the details, permissions, size, time, etc. of all files in the current directory
#ll command = = ls -l command
ls Directory name #ls + directory name, you can view all files in the specified directory
#ll similarly
Transferring files in xshell
rz -y #transfer files
move file
mv [-f] [-i] Source file destination file #-There is no prompt for f to overwrite the file, - i has a prompt
Copy file
cp [-a] Source file destination file #-a represents all files under the source file
Delete file
rm [-r] [-f] file #-r can delete the directory, - f does not prompt
Unzip the file to the specified directory

c: Packaged, but not compressed

x: Decompress

z: Do you need gzip compression

v: Display documents during decompression or compression

f: Set the top document name, followed by the file name immediately after F, and no parameters can be added

tar zxvf Files to be extracted [-C] Target directory  #Decompress - c to the specified directory in uppercase and compress c in lowercase
Compressed file
tar czvf Compressed name file to be compressed #Packing compression

Installing jdk1.0 on linux eight

1. Download from the official website

Find the linux version and download tar GZ compressed file (usually the bottom one).

2. Under root

xshell input

cd /usr && rz -y #Enter usr transfer file
ls #Command view file
tar -zxvf file name #Unzip to the current / usr directory
3. Configure environment variables

Type the command vim /etc/profile to modify the configuration file. Remember to modify it under root permission

Enter i to enter the editing state, then move the cursor to the last line and paste the following content, JAVA_HOME=/usr/jdk1.8. Set it according to your own decompression directory

#java environment
export JAVA_HOME=/usr/jdk1.8
export CLASSPATH=.:${JAVA_HOME}/jre/lib/rt.jar:${JAVA_HOME}/lib/dt.jar:${JAVA_HOME}/lib/tools.jar
export PATH=$PATH:${JAVA_HOME}/bin

Click esc to enter the command mode and enter: wq! Save modification information

Then type the command source /etc/profile to make the configuration file effective

Deploy tomcat

CentOS 7 Tomcat service installation and configuration - cloud + community - Tencent cloud (

cd /usr/local enter local under usr, and install tomcat here later

1. Image download


 tar zxvf Compressed package 
4. Modify Tomcat environment variable

Tomcat needs jdk to run. After the above decompression and installation, you also need to configure the directory of jdk in Tomcat

There are three methods to modify tomcat environment variables: * * the first method: * * defined in the global context; If multiple jdks are installed, the global definitions will conflict. It is not recommended

[root@Tomcat ~] vim /etc/profile

**Second: * * write the environment variable file in the user's home directory bash_profile

**The third type: * * is defined in the startup and shutdown procedures of a single tomcat. It is recommended to use this type

[root@Tomcat ~] vim /usr/local/tomcat/bin/                  --tomcat Startup procedure for
[root@Tomcat ~] vim /usr/local/tomcat/bin/             --tomcat Shutdown procedure for

Start up SH and shutdown SH add the following paragraph at the beginning of the two scripts:

export JAVA_HOME=/usr/local/java export TOMCAT_HOME=/usr/local/tomcat export CATALINA_HOME=/usr/local/tomcat export CLASS_PATH= J A V A H O M E / b i n / l i b : JAVA_HOME/bin/lib: JAVAH‚ÄčOME/bin/lib:JAVA_HOME/jre/lib: J A V A H O M E / l i b / t o o l . j a r e x p o r t P A T H = JAVA_HOME/lib/tool.jar export PATH= JAVAH‚ÄčOME/lib/tool.jarexportPATH=PATH:/usr/local/java/bin:/usr/local/tomcat/bin

Start tomcat
[root@Tomcat ~] /usr/local/tomcat/bin/ 

Browser input ip and 8080 port to view

Close tomcat
[root@Tomcat ~] /usr/local/tomcat/bin/   
Project deployment

Just put the packaged war package into the webapps directory, and tomcat will unpack it automatically.

Multiple tomcat

Modify conf / server XML file, two places

<Server port="18005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
Second place
    <Server port="18005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />


Nginx command

View process id
ps -ef | grep nginx
Start close restart reload configuration

In root mode

/usr/local/webserver/nginx/sbin/nginx   #start-up
/usr/local/webserver/nginx/sbin/nginx -s reload            # Reload configuration file
/usr/local/webserver/nginx/sbin/nginx -s reopen            # Restart Nginx
/usr/local/webserver/nginx/sbin/nginx -s stop              # Stop Nginx

Slow shutdown. pid is the master process number

kill -QUIT main pid

Close it

kill -TERM main pid
nginx configuring reverse proxy tomcat

Modify / usr / local / webserver / nginx / conf / nginx Conf file

	 # Multiple servers are configured here. The "test" must be the same as the proxy_ Corresponding to "test" in pass
    upstream test{
        /*First: visit once each
        /*The second method: set the weight, access 8080 twice and access 18080 once
        server weight=2;
        server weight=1;*/
     #The following is the configuration of the server virtual host
	server {
        listen       80;
        server_name  localhost;
	index index.html;
	location /{
		proxy_pass http://test; 
		index index.html index.htm;

Reload configuration, restart

Build clusters

How to build a local server cluster - Huanxin (

Topics: Linux bash server