Some frequently used Linux commands

Source: Internet
Author: User

1. Kill a process with a specific keyword:

PS-Ef | grep lxs | grep-ev grep | awk '{print $2}' | xargs-t-I kill-9 {}

Or:

Kill-9 $ (PS-Ef | grep lxs | grep-ev grep | awk '{print $2 }')

Change the keyword httpd to the keyword that you need to kill the process.


2. grep filters specific rows, such as empty rows.

 

Some configuration files are required at work. the command in conf is displayed. to view my. you can use Cat my. CNF | grep-EVN "^ $ | #"

 

Grep-e extension normalization expression

 

-V exclusion

 

-N: number of printed rows


3. Search for rows in a file that do not contain a certain string.

Most of the records in the query logs are correct, but there are also a small number of errors. You need to find these errors. You can do this:

Grep "get packet" Serv. Log> t.txt

Awk '{if ($6! = "Size: 28") Print $0} 't.txt

First, output all rows containing "get packet" in serv. log to t.txt.

In the second sentence, print the rows that do not contain "Size: 28 ".

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.