1. Displays the default shell for root, fedora, or User1 users on the current system ;
#egrep ' ^ (root|fedora|user1) '/etc/passwd|cut-d:-f1,7[[email protected] ~]# egrep ' ^ (root|lanin) '/etc/passwd|cut-d:- F1,7root:/bin/bashlanin:/bin/bash
#awk-F: '/root|fedora|user1/{print $ ' "", $7} '/etc/passwd
Sed-n '/root|fedora|user1/p '/etc/passwd |cut-d:-f1,7
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[[email protected] ~]# egrep-o ' \<[[:alpha:]]+\ >\ (\) '/etc/rc.d/init.d/functionscheckpid () daemon () Killproc () Pidfileofproc () Pidofproc () status () success () Failure () passed () Warning () Action () Strstr () confirm ()
3. Use the echo command to output an absolute path, using grep to remove its base name;
Extension: Take out its path name
Path name:
#echo/etc/sysconfig/network-scripts/ifcfg-eth0|grep-o ' ^/.*/' [[email protected] ~]# echo/etc/sysconfig/ Network-scripts/route-eth0 |grep-o ' ^/.*/'/etc/sysconfig/network-scripts/
Base name:
[[email protected] ~]# echo/etc/sysconfig/network-scripts/ifcfg-eth0|grep-o ' [^/]\+$ ' Ifcfg-eth0
4. Find the number between 1-255 in the ifconfig command result;
#ifconfig |egrep-o ' [1-9]| [0-9] [0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-9] '
5, Challenge: Write a mode, can match the reasonable IP address;
[[email protected] ~]# ifconfig|egrep-o ' ([0-9]|[ 0-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-9]) \.) {3} [0-9] {1,3} ' 192.168.1.159192.168.1.255255.255.255.0127.0.0.1255.0.0.0
6. Challenge: Write a pattern that matches all email addresses;
' [[: Alnum:]][email protected][[:alnum:]]+ (\.[ a-z]+) {1,} ' [[email protected] ~]# egrep-o ' [[: Alnum:]][email protected][[:alnum:]]+ (\.[ a-z]+) {1,} '/tmp/mailtest[email protected][email protected][email protected][email protected][email protected][email Protected][email protected]
find /var directory subordinate to Root, and belong to all files or directories that are Group mail;
#find/var/-user root-a-group mail[[email protected] ~]# find/var/-user root-a-group mail-ls652520 4 drwxrwxr-x 2 root mail 4096 Sep 5 03:48/var/spool/mail664453 4-rw-------1 root mail 4017 Sep 5 0 3:48/var/spool/mail/root
8, find the current system does not belong to the main or group of files;
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-o-nogroup#find/-nouser-o-nogroup-atime-3
9. find files with Write permission for all users in/etc directory;
[Email protected] ~]# find/etc/-perm-222/etc/rc3.d/etc/vmware-tools/icu/etc/vmware-tools/plugins/etc/rc.d/rc3.d/ K10saslauthd/etc/rc.d/rc3.d/k01smartd
10. Find All files that are larger than 1M in the/etc directory and are of the normal file type;
[Email protected] ~]# find/etc/-size +1m-type f/etc/logrotate.conf/etc/ppp/chap-secrets/etc/ppp/ Firewall-standalone ...
Teacher, can you tell me the meaning of the question?
&NBSP; grep ' ^-' &NBSP; awk ' {if ($5>1024) print $} '
Ll/etc/|awk ' {if ($5>1024) print$0} ' |grep ' ^-'
11. Find The/etc/init.d/directory, all users have execute permissions, and other users have write permission files;
[Email protected] ~]# find/etc/init.d/-perm-113-ls397852 16-rwx-wx-wx 1 root root 12709 Sep 4 08:17 /etc/init.d/rdmacopy
As above, this only matches all the files and directories in the first level directory, excluding subdirectories and their files, which is pure text filtering:
LL/ETC/INIT.D |grep ' ^...x. X.wx'
12. Find files that do not belong to root, bin, or Hadoop in the/usr directory;
# find/usr/! -user root-a! -user bin-a! -user hadoop# find/usr/-not \ (-user root-o-user bin-o-user hadoop \)
13. Find at least one class of users who do not have write permission in the/etc/directory;
#find /etc/ ! -perm -222[[email protected] ~]# find /etc/ ! -perm -222 -ls392462 4 -rw-r--r-- 1 root root 203 mar 23 10:03 /etc/alsa/alsactl.conf397775 4 -rw-r--r-- 1 root root 537 may 11 03:39 /etc/alsa/pulse-default.conf395474 4 -rw-r--r-- 1 root root 3384 may 10 21:37 /etc/drirc395467 4 drwxr-xr-x 2 root root 4096 aug 31 00:52 /etc/plymouth395468 4 -rw-r--r-- 1 root root 72 aug 11 2014 /etc/plymouth/plymouthd.conf
14. Find files whose contents have been modified and are not root or Hadoop for the last week in the/etc directory;
# find/etc/-mtime-7-not-user root-not-user hadoop# find/etc/-mtime-7-not \ (-user root-o-user hadoop\)
This article is from the "11460225" blog, please be sure to keep this source http://11470225.blog.51cto.com/11460225/1846407
"Linux Basics" Week fifth job