Linux System Management Preliminary (ix) System log and screen program

Source: Internet
Author: User
Tags custom name

First, the system log

System log is our understanding of the status of the system, service startup situation, learning to read the log is our basic skills to understand the health of the system and management.

(a)/var/log/messages

Various operations in the system will be recorded in the system log, logs stored in the/var/log/directory, the log will be automatically cut by the system's Logrotate program, that is, the log files to achieve the conditions you set, the automatic end, and then regenerate a file to start logging.

1. View the System log

Tail/var/log/messages

You can actually record a lot of things.

2. Configuring the logging mechanism through the/logrotate.conf file

Cat/etc/logrotate.conf

The main content is listed in this
# Rotate log Files Weekly
How often does weekly end a log record, weekly or monthly, daily, etc.

# Keep 4 weeks worth of backlogs
Rotate 4 How many copies of the oldest log, that is, you can save a few log files, this is 4, that is, if you have 4 log files, then the extra one will cover the first part, like the monitor you can replay the most video days.

# Create new (empty) log files after rotating old ones
Create

# Use date as a suffix of the rotated file
Dateext

# Uncomment this if you want your log files compressed
#compress

# RPM Packages Drop log rotation information into this directory
Include/etc/logrotate.d
You can use the required

# no packages own wtmp and btmp--we ' ll rotate them here
This statement can be logrotate the program you want to cut the path of the log file to add in, let the program automatically help you to cut log files, common such as Nginx log.

such as handling:

/usr/local/nginx/logs/*.log {
Daily
Dateext
Compress
Rotate 7
Sharedscripts
Postrotate
Kill-usr1cat /var/run/nginx.pid
Endscript
}

/var/log/wtmp {
Monthly
Create 0664 Root utmp
MinSize 1M
Rotate 1
}

/var/log/btmp {
Missingok
Monthly
Create 0600 Root utmp
Rotate 1
}

# system-specific logs May is also is configured here.

(ii) DMSEG order

The DMESG command can display the system's startup information and hardware error messages, which can be used for troubleshooting when a hardware problem is in the system.

Note that this command displays a log that is not related to the/var/log/dmseg log.

(iii) Last Order and Lastb order

The last command and the LASTB command are used to view the logged-on user of the system, which displays the system's most recent user login by invoking the system log/var/log/wtmp and/var/log/btmp to use the command when making security.

>last

>lastb

Log/var/log/wtmp and/var/log/btmp are binary files and cannot be directly cat

system security-related logs also have secure logs (/var/log/secure), which record the user's attempts to log on to the system, or brute-force system password information, to help you do the next step, such as using Fail2ban to lock the attack IP.

Second, screen tools

Screen is a virtual terminal tool, some programs do not have a long execution time, and we log on to the server is a remote login, in order to prevent accidental interruption of the system can continue to run a program we can use the screen tool. Note Even if we disconnect

Screen tool non-system comes first requires Yum installation

Tool options
CTRL + A again +d: Create a new screen
Screen-s "Custom name": Custom Terminal name New screen
Screen-ls: Lists the screens that exist in the system
Screen-r ID number or custom name: Enter a specific screen

Operation Example
1. Create a new screen and run the Vnstat 1 command

Screen
Vmstat 1
CTRL + A again +d

He's moving backstage.

2. Switch back to the screen you just

Screen-r 1960
Screen-r test1

Two can be, the latter one is generated with screen-s test1.

3. Kill an already detached screen session

Screen-x-S (ID number or screen name) quit

Linux System Management Preliminary (ix) System log and screen program

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.