search
HomeOperation and MaintenanceWindows Operation and MaintenanceHow to troubleshoot problems by viewing logs during server operation and maintenance

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!

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software