Linux system service Management NTSYSV, log, Exec,xargs, screen, curl,

Source: Internet
Author: User
Tags dmesg


Linux system service Management


1. Linux system service Management

Tool NTSYSV similar to the graphical interface management tool, if the command is not installed using the

Installation:Yum install-y ntsysv

Common services: Crond, iptables, Network, sshd, Syslog, Irqbalance, SendMail, Microcode_ctl

chkconfig--list: Lists the services and whether they are turned on at each level

chkconfig--add/del ServiceName


Turn off or turn on services at a level, 0,1,2,6 level is off by default, just pay attention to the 3,4,5 level

Syntax: Chkconfig--level [level] [service name] on/off

You can also specify multiple levels to turn the AUDITD service off at level 34

Chkconfig--level AUDITD off


Close all the services below all levels

Chkconfig [service name] off


Hosting directory for startup scripts

/etc/init.d/


/etc/rc3.d/

List of all services in Level 3

lrwxrwxrwx. 1 root root 19 June 1 19:21 k10saslauthd. /init.d/saslauthdlrwxrwxrwx. 1 root root 17 June 3 15:55 s01sysstat. /init.d/sysstat

K10: Indicates the order in which the process was killed

S01: Indicates the order of initiation


The Chkconfig definition description in the service script, each service will have the following definition

# chkconfig:2345 11 88

2345: Is the level of service operation

11: Is the service opening order, this number can be defined by itself, but the number cannot drink other services overlap, after overlapping will cause the service can not start

88: Is the service close order


2. Linux system logs

/etc/rsyslog.conf

/var/log/messages Core System log files

Archive one log per week messages-20130901

/etc/logrotate.conf

Messages is generated by the syslogd daemon, and if this service is stopped, the system will not generate/var/log/messages


/var/log/wtmp: View User Login History Last

/var/log/btmp: This is a binary file, you need to use strings to see the content

LASTB Viewing Invalid login history


/var/log/maillog: Mail Log

MAILQ: Check if the message is sent out

/var/log/secure: Records the information used to log in, and the file is also archived.

DMESG: Display boot information for the system

/VAR/LOG/DMESG: The hardware log recorded when the system was started


grep ' 126.com '/var/log/maillog

Search for characters related to 126.com in the/var/log/maillog file


3. Exec and Xargs

Both exec and find use

Find files with the current directory creation time greater than 10 days and delete

Find. -mtime +10-exec rm-rf {} \;


Bulk Change file name: Find./*-exec mv {} {}_bak \;

Xargs used behind the pipe symbol


Find logs for 10 days ago and delete

Find. -mtime +10 |xargs RM-RF


find/var/log/-type f-mtime +10 |xargs-i mv {} {}.back

The normal files created in the/var/log/directory 10 days ago are all changed to. back end.

-I: Represents a loop, similar to a for


ls-d./* |xargs-n1-i{} MV {} {}_bak

Xargs can turn multiple lines into a row of cat 1.txt|xargs




4. Screen Tool Introduction

Screen is equivalent to a virtual terminal, is not installed by default, it will not be due to network interruption, and each login can enter the screen

Installation: [[email protected] ~]# yum install-y screen

How to use: Directly enter the screen command


Screen-ls

View the screen virtual terminal that is already turned on


Exit screen, not end

Ctrl +a then press D to exit the screen session, just exit, and not end.

End: Ctrl +d or enter exit

After exiting, you also want to log in to a screen session again, using Sreen-r Screenid if there is only one screen direct screen-r


Support for name input

screen-s [Name]

Screen-s aming; login words screen-r aming


5. Learn to use the Curl command

Curl is a tool for simple testing of Web Access under the Linux system command line, with a few common options you need to master

Curl-xip:port www.baidu.com #-X can specify IP and port, omit write hosts, convenient and practical

Curl-iv http://www.qq.com #-I can drop the content of the access, only show the status code,-V can show the detailed process

Curl-u User:password http://123.com #-u can specify user name and password

Curl Http://study.lishiming.net/index.html-O (large O) #可以下载

You can also use the-O (Small o) to customize the name


Curl-o index2.html http://study.lishiming.net/index.html


6. Several network-related commands

Ping

Telnet Www.lishiming.net 80

Traceroute www.baidu.com


Dig: Domain Name query tool to test whether the domain Name system is working properly

The dig command is not installed by default and needs to be installed to

Installation: Yum install-y bind*

Dig @8.8.8.8 study.lishiming.net


NC is not installed by default and needs to be installed

Installation: Yum install-y NC

Nc-z-w2 www.baidu.com 1-1024 #-w2 indicates a 2s timeout

Port Here you can write only one port, or you can write a range.

When using the NC scan port, you must add-Z or the result will not be displayed.

Also, if you want to display the ports that are not open, you can add a-V


This article is from the It Exchange Learning blog, so be sure to keep this source http://sxct168.blog.51cto.com/824373/1660006

Linux system service Management NTSYSV, log, Exec,xargs, screen, curl,

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.