Marco 2016 new Linux+python high-end Operation fourth week

Source: Internet
Author: User

1. Display the line beginning with at least one blank character in/boot/grub/grub.conf;
[[email protected]/]# grep "^[[:space:]]\+"/boot/grub/grub.conf root (hd0,0) kernel/vmlinuz-2.6.32-504.el6.x86_64 ro ROOT=UUID=AA5CF6B3-E1B5-4EB2-95E6-E202F2890EDF Rd_no_luks RD_NO_LVM Lang=en_us. UTF-8 rd_no_md sysfont=latarcyrheb-sun16 crashkernel=auto keyboardtype=pc keytable=us Rd_NO_DM rhgb quietinitrd/ Initramfs-2.6.32-504.el6.x86_64.img
2, the display/etc/rc.d/rc.sysinit file with the beginning of #, followed by at least one white space character, and then have at least one non-whitespace character line;
[[email protected]/]# grep "^#[[:space:]]\+[^[:space:]]"/etc/rc.d/rc.sysinit
3, the Netstat-tan command execution results in the "LISTEN", followed by or with a blank character end of the line;
[[email protected] /]# netstat -tan | grep  "LISTEN[[:space:]]*$" tcp         0      0 0.0.0.0:22                   0.0.0.0:*                     LISTEN      tcp        0       0 127.0.0.1:631                0.0.0.0:*                    LISTEN      tcp         0      0 127.0.0.1:25                 0.0.0.0:*                    listen      tcp         0      0 0.0.0.0:80                   0.0.0.0: *                    LISTEN      tcp        0       0 :::22                        :::*                           listen      tcp        0      0 : :1:631                      :::*                          LISTEN       tcp        0      0 ::1:25                        :::*                          listen      [[email  protected] /]#
4, add user bash, Testbash, basher, Nologin (this one user's shell is/sbin/nologin), and then find the current system on its user name and the default shell of the same user information;
[Email protected]/]# grep-e ' ^ (\<[a-z]+\>). *\1$ '/etc/passwdsync:x:5:0:sync:/sbin:/bin/syncshutdown:x:6:0: shutdown:/sbin:/sbin/shutdownhalt:x:7:0:halt:/sbin:/sbin/haltnologin:x:501:501::/home/nologin:/sbin/ Nologinbash:x:502:502::/home/bash:/bin/bash[[email protected]/]#
5. Display the default shell of root, fedora or User1 user on the current system;
[Email protected]/]# grep-e ' ^ (root|fedora|user1) '/etc/passwdroot:x:0:0:root:/root:/bin/bash[[email protected]/]#
6. Find the line with a set of parentheses after a word in the/etc/rc.d/init.d/functions file, such as: Hello ();
[Email protected]/]# grep-e "[A-z]+\ (\)"/etc/rc.d/init.d/functions
7. Use the echo command to output an absolute path, use grep to remove its base name, expand: Take out its path name
[Email protected] network-scripts]# echo/etc/sysconfig/network-scripts | Grep-o "[^/]*$" Network-scripts[[email protected] network-scripts]# echo/etc/sysconfig/network-scripts | Grep-op "^.* (? =/)"/etc/sysconfig[[email protected] network-scripts]#

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

[Email protected] ~]# Ifconfig | Egrep-o "[1-9]{1,2}|2[0-5]{1,2}"
9, Challenge: Write a mode, can match the reasonable IP address;
[Email protected] ~]# Ifconfig | Egrep-o "[1-9]{1,3}\. [1-9] {1,3}\. [1-9] {1,3}\. [1-9] {1,3} "192.168.1.8192.168.1.255192.168.1.25192.168.253.135192.168.253.255192.168.253.25[[email protected] ~]# Note: This will match numbers like 888.888.888.888, but the results in Ifconfig will not appear in dotted decimal numbers!! The lazy wording
10, Challenge: Write a pattern, can match out all the email address;
[email protected] ~]# Cat Mail.txt | grep ' [[: Alnum:]]\[email protected][[:alnum:]]\+\. [[: alnum:]]\+$ ' [email protected][email protected][email protected][email protected][[email protected] ~]# cat Mail.txt [Email protected]@126.com[email protected][email protected][email protected] @sina. Com[[email protected] ~]#
11. Find the main root of the/var directory, and belong to all files or directories of mail;
[Email protected] ~]# find/var-user root-group mail/var/spool/mail/var/spool/mail/root[[email protected] ~]#
12. Find files that are not owned or owned by the current system; further: Find files or directories that are not owned or owned by the current system and have been accessed in the last 3 days;
[[email protected]/]# Find/-nouser-o-nogroup [[email protected] ~]# Find/-nouser-o-nogroup-a-atime 3
13, find all the users in/etc directory have write permission files;
[Email protected] ~]# Find/etc-perm-222-ls
14. Find all files that are larger than 1M in/etc directory and are of normal file type;
[Email protected] ~]# find/etc-type f-size +1m-ls668012 7892-rw-r--r--1 root root 8080653 Jul 4 08:37 /etc/selinux/targeted/modules/active/policy.kern668019 7892-rw-r--r--1 root root 8080653 Jul 4 08:37/etc/se linux/targeted/policy/policy.24794284 1976-rw-r--r--1 root root 2020885 Jul 4 08:34/etc/gconf/gconf.xml.def Aults/%gconf-tree.xml[[email protected] ~]#
15, find/etc/init.d/directory, all users have execute permission, and other users have write permission files;
[Email protected] ~]# find/etc/init.d/-type f-perm-102-ls663307 0-rwxrwxrwx 1 root root 0 Jul 9 17:20/etc/init.d/test.txt
16. Find files that do not belong to root, bin or hadoop in the/usr directory;
[[email protected] ~]# touch/usr/2.txt[[email protected] ~]# chown test:test/usr/2.txt[[email protected] ~]# find/usr/  -type f! \ (-user root-o-user bin-o-user hadoop \)-ls400099 12-rwsr-xr-x 1 abrt abrt 10296 Oct 2014/usr/ libexec/abrt-action-install-debuginfo-to-abrt-cache395439 0-rw-r--r--1 Test test 0 Jul 9 17:29/usr /2.txt[[email protected] ~]#
17, to find at least one type of/etc/directory Users do not have write permission files;
[[email protected] ~]# find/etc/! -perm +222-ls
18. Find files whose contents have been modified and not rooted or Hadoop for the last week in/etc directory;
[Email protected] ~]# find/etc/-type f-ctime-7-A! \ (-user root-o-user hadoop \)-ls663346 4-rw-r--r--1 Test test 2 Jul 9 17:37/etc/2.txt[[email p Rotected] ~]#


Marco 2016 new Linux+python high-end Operation fourth week

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.