Marco Linux jobs Fifth week '

Source: Internet
Author: User
Tags alphabetic character echo command egrep

1. Display the default shell of root, fedora or User1 user on the current system;

Egrep "^ (root|fedora|user1) \>"/etc/passwd |cut-d:-f1,7

Root|fedora|user1 said that the three were in accordance with one of the choice conditions

() Make It grouped

^ Represents the beginning of a condition after a face-to-group

\> indicates that the previous conditional character was truncated with a null character, that a word followed by another character would not match


2. Find the line with a set of parentheses after a word in the/etc/rc.d/init.d/functions file, such as: Hello ();

Egrep-o "[_[:alpha:]]+\ (\)"/etc/rc.d/init.d/functions

[: Alpha:] Single alphabetic character (case insensitive)

[_[:alpha:]] indicates matching alphabetic characters and underscores

+ means match the previous condition one or more times

() need to be escaped

-O indicates that only matching parts are output


3. Use the echo command to output an absolute path, using grep to remove its base name;

echo/etc/httpd/conf | Egrep-o "[^/]+/?$"

[^/]: Match non-"/" character

/?: Match 0 or 1 "/"

$: End With previous match criteria


Extension: Take out its path name

echo/etc/httpd/conf | Egrep-o "/.*/"

. *: Multiple arbitrary characters


4, find out the results of the ifconfig command between 1-255 numbers;

Ifconfig|egrep "\< ([1-9]|[ 1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]) \> "

Matches: single digit | 10 digit |100-199|200-249|250-255


5, Challenge: Write a mode, can match the reasonable IP address;

"(\< ([0,1]?[ 0-9]? [0-9]|2[0-4][0-9]|25[0-5]) \>\.) {3}\< ([0,1]?[ 0-9]? [0-9]|2[0-4][0-9]|25[0-5]) \> "


6, Challenge: Write a pattern, can match out all the email address;

"^ ([[: alpha:]]| [0-9]|\_] *@ ([[: alpha:]]|[ 0-9]) *. (com|cn|com\.cn) $ "

Match: Multiple letters, numbers, underscores @ multiple letters, numbers match characters. Characters ending in COM or cn or com.cn


7. Find the main root of the/var directory, and belong to all files or directories of mail;

Find/var-user Root-group Mail


8, find the current system does not belong to the main or group of files;

Find/-nouser-o-nogroup


Further: Find files or directories that are not owned by the master or group on the current system and have been visited in the last 3 days;

Find/-nouser-a-nogroup-a-atime-3

-a:and

-atime-3: Files accessed within 3 days


9, find all the users in/etc directory have write permission files;

find/etc-perm-222

Any one of the Find-perm-mode:mode must match the criteria.


10. Find all files that are larger than 1M in/etc directory and are of normal file type;

Find/etc-size +1m-type F


11, find/etc/init.d/directory, all users have execute permission, and other users have write permission files;

find/etc/init.d-perm-113

All users have execute permissions of-perm-111

Other users have write permission, then in their o bit +2,-perm-113


12. Find files that do not belong to root, bin or hadoop in the/usr directory;

Find/usr-not \ (-user root-o-user bin-o-user hadoop \)


13, to find at least one type of/etc/directory Users do not have write permission files;

Find/etc! -perm-222

Perm-222 indicates that each class of users has write permissions, which is reversed, there is at least one class of users do not have write permissions


14. Find files whose contents have been modified and not rooted or Hadoop for the last week in/etc directory;

Find/etc mtime-7-not \ (-user root-o-user hadoop \)

\ (-user root-o-user hadoop \): Users who belong to the user group or Hadoop group are matched

-not: For subsequent inversion, which matches users who do not belong to the user group or to the Hadoop group


Spit the Trough, 51cto blog typesetting function really slag

Marco Linux jobs Fifth week '

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.