Linux exercises-text management tools and regular expressions

Source: Internet
Author: User

1. Find the IPV4 address of this machine in Ifconfig "NIC name" command result

Method 1:ifconfig Ens33 | Grep-w "inet" | Tr-s ': | Cut-d: F3

Method 2:ifconfig Ens33 | Grep-o ' \ ([0-9]\{1,3\}\.\) \{3\}[0-9]\{1,3\} ' | Head-n1 or Ifconfig ens33 | Grep-oe ' ([0-9]{1,3}\.) {3} [0-9] {1,3} '


2. Find out the maximum percentage value of partition space utilization

DF | grep '/dev/sd ' |grep-oe ' [0-9]{1,3}% ' |sort-nr |head-n1


3, identify the user UID maximum user name, UID and shell type

CAT/ETC/PASSWD |sort-rnt:-k3 |head-n1


4. Find out the permissions of/tmp and display them digitally

stat/tmp | Grep-o ' Access: (. *) ' | Grep-oe ' [0-9]{4} '

The diagram also attempts to view the/etc and/root directory permissions


5. Count the number of connections to each remote host IP currently connected to this machine, and sort from large to small

In the topic there is a tool can query the number of IP connections connected to the computer, which can be used as a keyword to find the IP address to sort, because I temporarily did not have this tool, so with the last command to do the problem

Last | Grep-eo ' ([0-9]{1,3}\.) {3} [0-9] {1,3} ' | uniq-c | Sort-rn

6. Display lines starting with size s in the/proc/meminfo file (required: use two methods)

7. Display lines in the/etc/passwd file that do not end in/bin/bash

8. Show user RPC default shell program

9. Find out the two-bit or three-digit number in/etc/passwd

10. A line that displays at least one white-space character that starts with a CentOS7/etc/grub2.cfg file, followed by a non-whitespace character

11. Find the line that ends with listen followed by any number of whitespace characters in the "Netstat-tan" command result

12. Display user name and UID of all system users on CentOS7

13, add user bash, Testbash, basher, SH, nologin (its shell is/sbin/nologin), find the/etc/passwd user name and shell the same name row

14, take advantage of DF and grep, remove the disk partition utilization, and from large to small sort

15. Display three user root, Mage, Wang's UID and default shell

16. Find the line at the beginning of the/etc/rc.d/init.d/functions file that has a word (including an underscore) followed by a parenthesis

17. Use Egrep to remove its base name in/etc/rc.d/init.d/functions

18. Use Egrep to remove the directory name of the path above

19. Count the number of logins per host IP address that was logged in as root in the last command

20. Use extended regular expressions to represent 0-9, 10-99, 100-199, 200-249, 250-255, respectively

21. Display all IPV4 addresses in ifconfig command results

22, this string: Welcome to magedu each character in Linux to go to the weight and sort, repeat the number of rows to the front

23, the XXX number, QQ number, mailbox, mobile phone number


Linux exercises-text management tools and regular expressions

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.