Home > Operation and Maintenance > Windows Operation and Maintenance > How to troubleshoot problems by viewing logs during server operation and maintenance

How to troubleshoot problems by viewing logs during server operation and maintenance

坏嘻嘻
Release: 2018-09-15 16:34:57
Original
3866 people have browsed it

The content of this article is about how to troubleshoot problems by checking logs during server operation and maintenance. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

Basic Guide to Server Operation and Maintenance

As a developer, it is inevitable to operate the server. The most common operation is to deploy applications to servers and troubleshoot problems by viewing logs in production and test environments.

Generally, servers have Linux operating systems and no graphical interface, so any operation is done through the command line. Since the new generation of programmers start with the graphical interface, they start using the command line. If you are used to using the command line, you can do many interesting and efficient things using the command line, improve productivity, and allow programmers to focus more on high-tech work.

Linked server entrance

Mac can log in to the server directly using its own terminal. Windows requires downloading tools, for example:

Password-free login

    ssh -l user ip/domain name
  • ssh: secure shell secure shell protocol, designed for remote login sessions A protocol that provides security for other network services. The use of ssh protocol can effectively prevent information leakage during remote management.
  • Log in with password

  • Enter: ssh -l user ip/domain name

user: login user name

ip/domain name: Server belongs The public network ID address, or the domain name of the application. If you want to view the IP after domain name resolution, enter ping domain name on the command line to view the public network IP to which the application belongs (provided that the server does not perform load balancing, proxy...).

The terminal will prompt you to enter the password. Enter the password at this time. If the password is correct, you can log in to the server.

Password-free login

Password-free login method still requires you to enter a password to log in for the first time. The difference is that after logging in, you add your own key to the server, and you can use it without a password next time. Log in.

Generate ssh key

Log in to the server, enter .ssh in the ~ directory, open the authorized_keys file, create it if it does not exist, and add your public key to authorized_keys. When you use ssh to enter the server again, you can log in directly without entering a password.

Tips: Mac can create a new .sh file, add ssh -l user ip/domain name to the .sh file, put it on the desktop and use the terminal to open it by default. In the future, you can double-click the .sh file to directly enter the server (you can even Write other commands in .sh to achieve automation).

Exit the server exit

exit

View the current directory location pwd


pwd

Display all files in the current directory ls

ls: List all files in the current directory

ls -l: List all files and file details in the current directory

Enter and exit the directory cd

cd .. :Return to the upper directory

cd /.: Return to the root directory

cd directory name: Enter the specific directory

Create a new directory mkdir

mkdir file/filename

Start the running script./

./xx.sh

View file content cat/tail

cat xxx.xx: View all contents of the file

tail -n number of lines xxx.xxx: View the number of xx lines at the end of the file

vi/vim xxx.xxx: View and modify the file content

Move the file to a specific directory mv

mv xx sss: Move the xx file to the sss directory

It is recommended that when deleting a file, you first move the file to the /tmp directory (the temporary directory of Linux will be cleared when you shut down, so it is recommended to delete it in this directory).

Delete files rm

rm -f xxx: forcefully delete files

rm -rf xxx: -r means downward recursive deletion -f delete without prompt Note: rm - rf (without parameters) will delete the entire system. Even if there are parameters, Linux does not have the concept of a recycle bin. Use with caution

rm -f

.

: Use the plum blossom method with caution, it may be deleted by mistake. Delete the entire server

Modify the user permissions of the file chown/chmod

chown -R user:user file: Modify the user permissions of the file File supports wildcards

chmod 777 xxxx:Change File permission 777 means high permissions (read, write, execute). The logged-in user's group and others have the highest permissions. (A more dangerous operation)

View the related processes of the java program jpsjps: View the java program process

Copy the file to the specific directory cp/scp

cp -r copyed copy: Copy copied to the copy directory

scp xxx root:ip:/directory: Copy xxx to the remote ip server directory

Start the service, close the terminal, and continue running nohup

Sometimes we need to run some jar packaged applications on the server. The application will be closed after closing the terminal. We can add nohup before the command to start the jar application

Decompress/compress the file unzip/zip

unzip -o xxx.xx -d sss: Decompress the file xxx.xx to sss and overwrite all

zip -r xxx.zip ./*: Compress all files in the current directory of the file

If the unzip zip command is not executed, you can install unzip/zip

yum install -y unzip zip

Summary

At present, these commands can basically meet the daily development of Yunxi server, but these are just some simple commands to operate the server. If there is more demand to learn Linux systematically, that is also a big problem. Topic operation and maintenance.

The above is the detailed content of How to troubleshoot problems by viewing logs during server operation and maintenance. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template