1. Display the default shell of root, fedora or User1 user on the current system;
For:
[[email protected] ~]# egrep ' ^ (root|user1) \> '/etc/passwd | Cut-d:-f7/bin/bash/bin/bash
2. Find the line with a set of parentheses after a word in the/etc/rc.d/init.d/functions file, such as: Hello ();
For:
[[email protected] ~]# grep ' \<[[:alpha:]]\+\> () '/etc/rc.d/init.d/functionscheckpid () {daemon () {Killproc () { Pidfileofproc () {Pidofproc () {status () {success () {failure () {passed () {warning () {action () {strstr () {
3. Use the echo command to output an absolute path, using grep to remove its base name;
Extension: Take out its path name
For:
#基名 [[email protected] ~]# echo "/tmp/log/txt" | Egrep-o "[^/]+/?$" txt# path name [[email protected] ~]# echo "/tmp/log/txt" | Egrep-o ". * *"/tmp/log/
4, find out the results of the ifconfig command between 1-255 numbers;
For:
[Email protected] ~]# Ifconfig | Egrep-ow ' \<[1-9]| [1-9] [0-9]|1[0-9][0-9]|2[0-5][0-5]\> ' 101125525525510255642941717312712551128
5, Challenge: Write a mode, can match the reasonable IP address;
For:
Egrep "(\< ([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]) \> "comment: [0,1]? [0-9]? [0-9]: Match 0-1992[0-4][0-9]: match 200-24925[0-5]: Match 250-255 ([0,1]?[ 0-9]? [0-9]|2[0-4][0-9]|25[0-5]): Match 0-255
6, Challenge: Write a pattern, can match out all the email address;
For:
[[email protected] ~]# egrep "^ ([[: alpha:]]|[ 0-9]|\_) *@ ([[: alpha:]]|[ 0-9]) *.com$ "
7. Find the main root of the/var directory, and belong to all files or directories of mail;
For:
[Email protected] ~]# Find/var-user root-group mail/var/spool/mail
8, find the current system does not belong to the main or group of files;
For:
[[email protected] ~]# Find/-nouser-a-nogroupfind: '/PROC/2883/TASK/2883/FD/6 ': No file or directory find: '/proc/2883/task/2883 /FDINFO/6 ': No file or directory find: '/PROC/2883/FD/6 ': No file or directory find: '/PROC/2883/FDINFO/6 ': no file or directory
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;
[[email protected] ~]# Find/-nouser-nogroup-mtime-3find: '/PROC/2890/TASK/2890/FD/6 ': No that file or directory find: '/proc/2890/tas K/2890/FDINFO/6 ': No file or directory find: '/PROC/2890/FD/6 ': No file or directory find: '/PROC/2890/FDINFO/6 ': no file or directory
9, find all the users in/etc directory have write permission files;
[[email protected] ~]# find /etc -perm - 222 -ls134320260 0 lrwxrwxrwx 1 root root 17 8 Month 14 16:45 /etc/mtab -> /proc/self/mounts67332427 0 lrwxrwxrwx 1 root root 49 8 Month 14 16:45 /etc/pki/tls/certs/ca-bundle.crt -> /etc/pki /ca-trust/extracted/pem/tls-ca-bundle.pem67332428 0 lrwxrwxrwx 1 root root 55 8 month 14 16:45 /etc/pki/tls .... Slightly
10. Find all files that are larger than 1M in/etc directory and are of normal file type;
For:
[Email protected] ~]# find/etc-size +1m-type f-exec ls-lh {} \;-r--r--r--. 1 root root 6.7M August 16:50/etc/udev/hwdb.bin-rw-r--r--. 1 root root 3.7M November 2015/etc/selinux/targeted/policy/policy.29
11, find/etc/init.d/directory, all users have execute permission, and other users have write permission files;
For:
[[email protected] ~]# find/etc/init.d-perm-113-ls134356480 0 lrwxrwxrwx 1 root root 11 August 14 16:45 /ETC/INIT.D-RC.D/INIT.D
12. Find files that do not belong to root, bin or hadoop in the/usr directory;
For:
[[email protected] ~]# find/usr-not \ (-user root-o-user bin-o-user hadoop \)-ls134672278 0 drwx------2 Polki TD Root 6 June 2014/USR/SHARE/POLKIT-1/RULES.D
13, to find at least one type of/etc/directory Users do not have write permission files;
For:
[[Email protected] ~] #find/etc-not-perm 222-ls
14. Find files whose contents have been modified and not rooted or Hadoop for the last week in/etc directory;
For:
[Email protected] ~]# find/etc-mtime-7-a-not-user root-a-not-user Hadoop
Marco Linux Network class assignment (5)