System service management and log management under Linux

Source: Internet
Author: User

1. NTSYSV Service Configuration Tool

Used to configure which services are turned on or off, the graphical interface, using the keyboard to operate.

commands for installing the NTSYSV service: Yum install-y ntsysv

Direct Run command NTSYSV popup configuration interface;

Press the keyboard up and DOWN ARROW keys to move, press the space bar to select, the brackets show that there is * to open, otherwise do not open. With this tool you can see all the services in the current system. It is recommended to stop all other services except "Crond,iptables,network,sshd,syslog,irqbalance,sedmail,microcode_ctl". Press the TAB key to switch to OK, save, restart the machine to take effect;

2. Chkconfig Service Management Tools

Linux system all the preset services can be viewed/etc/init.d/directory to get;

The system preset services can be stopped or started and viewed by the command: Serviceservice name Start|stop|restart|status ;

The service name here is the System preset service under the/etc/init.d/directory, so you can also start or stop the service using the /etc/init.d/service name Start|stop|restart ;

You can use chkconfig or chkconfig--list to list all services and whether each level is turned on:

The level here (0-6) is/etc/inittab corresponding level, 0,1,6 runlevel is reserved by the system, 0 for shutdown shutdown, 1 for restart to single-user mode, 6 for restart; In the general Linux system implementation, are used 2,3,4,5 several levels ; Level 2 for multi-user mode without NFS, 3 for full multiuser mode (most commonly used), 4 reserved for user customization, and 5 for graphical interface login.

chkconfig--level Specifies the level of service name on or off to change which level of service is turned on;

--level can be omitted, default for 2,3,4,5 level operation;

Example: Turn off Crond service, turn on level 3 Crond service, turn on level 345 Crond service;

1234567891011 [[email protected] ~]# chkconfig --list |grep crondcrond          0:off1:off2:on3:on4:on5:on6:off[[email protected] ~]# chkconfig crond off[[email protected] ~]# chkconfig --list |grep crondcrond          0:off1:off2:off3:off4:off5:off6:off[[email protected] ~]# chkconfig --level 3 crond on[[email protected] ~]# chkconfig --list |grep crondcrond          0:off1:off2:off3:on4:off5:off6:off[[email protected] ~]# chkconfig --level 345 crond on[[email protected] ~]# chkconfig --list |grep crondcrond          0:off1:off2:off3:on4:on5:on6:off

Chkconfig also has a function to add a service to the system service, the custom service if want to add to the system service, copy the executable service into the/etc/init.d/directory, after joining the system service can use: Service name start operation, And can also be found in the Chkconfig--list list, of course, can also be deleted;

chkconfig--del Service name removal service

chkconfig--add Service name Adding a service This feature is often used to add a custom startup script to the system service.

12345 [[email protected] ~]# chkconfig --del crond[[email protected] ~]# chkconfig --list |grep crond[[email protected] ~]# chkconfig --add crond[[email protected] ~]# chkconfig --list |grep crondcrond          0:off1:off2:on3:on4:on5:on6:off

3. Linux System Log

The main functions of the log are: Audit and detection, but also real-time monitoring system status, monitoring and tracking intruders and so on;

Common log files have /var/log/message core system log files that contain boot messages at system startup and other status messages when the system is running. IO errors, network errors, and system system errors are all recorded in this file. Other information, such as a person's identity switch to root and user-defined software logs, will also be listed here.

123 [[email protected] ~]# ls /var/log/messagesmessages           messages-20150407  messages-20150420  messages-20150330  messages-20150413

Together with messages There are 5 log files, and the system has a log polling mechanism that switches one log per week and is generated in date format.

System polling is achieved through the control of the Logrotate tool, the configuration file for/etc/logrotate.conf No special needs please do not modify.

/var/log/messages is generated by rsyslogd this daemon, if this service is stopped, the system will not generate/var/log/messages, so the service does not stop.

The configuration file for the RSYSLOGD service defines the level of logging for/etc/rsyslogd.conf, and does not modify this profile if there is no special requirement.

DMESG Displays the boot information of the system and can be viewed with this command if there is a problem with the hardware.

Last to view historical information about logging in to Linux

Last command output information is actually read /var/log/wtmp binary file, do not use cat vim head tail view;

From left to right: account name, login terminal, login client IP, logon date is long.

LASTB View Invalid login history, someone malicious login will be logged; actually read the/var/log/btmp file

/var/log/maillog also has 5 log files of Maillog;

123 [[email protected] ~]# head /var/log/maillogApr 20 13:55:41 yong postfix/postfix-script[1980]: stopping the Postfix mail systemApr 20 13:55:41 yong postfix/master[1143]: terminating on signal 15

/var/log/secure System Login Information log file , record authentication and authorization information, such as SSH login system success or failure.

1234567891011 [[email protected] ~]# tail /var/log/secureApr 20 18:29:05 yong login: pam_unix(login:session): session closed foruser rootApr 20 18:29:06 yong sshd[954]: Received signal 15; terminating.Apr 20 18:29:06 yong sshd[1863]: Exiting on signal 15Apr 20 18:29:06 yong sshd[1863]: pam_unix(sshd:session): session closed foruser rootApr 20 18:29:06 yong sshd[2040]: pam_unix(sshd:session): session closed foruser user1Apr 20 18:29:06 yong sshd[1863]: syslogin_perform_logout: logout() returned an errorApr 21 10:33:50 yong sshd[951]: Server listening on 0.0.0.0 port 22.Apr 21 10:33:50 yong sshd[951]: Server listening on :: port 22.Apr 21 10:39:11 yong sshd[986]: Accepted password forroot from 192.168.20.1 port 61567 ssh2Apr 21 10:39:11 yong sshd[986]: pam_unix(sshd:session): session opened foruser root by (uid=0)

System service management and log management under Linux

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.