1.
[root@localhost ~]# grep bash /etc/passwd
root:x:0:0:root:/root:/bin/bash
open:x:1000:1000:open:/home/open:/bin/bash
2.
[root@localhost ~]# grep -o "\<[0-9]\{3,4\}\>" /etc/passwd
100
999
997
998
997
996
177
177
996
994
995
992
990
990
989
989
988
988
1000
1000
3.
[root@localhost ~]# grep E "^[[:space:]]+[^[:space:]]+" /etc/grub2.cfg
grep: ^[[:space:]]+[^[:space:]]+: No such file or directory
/etc/grub2.cfg:# DO NOT EDIT THIS FILE
/etc/grub2.cfg:### BEGIN /etc/grub.d/00_header ###
/etc/grub2.cfg:### END /etc/grub.d/00_header ###
/etc/grub2.cfg:### BEGIN /etc/grub.d/00_tuned ###
/etc/grub2.cfg:### END /etc/grub.d/00_tuned ###
/etc/grub2.cfg:### BEGIN /etc/grub.d/01_users ###
/etc/grub2.cfg:### END /etc/grub.d/01_users ###
/etc/grub2.cfg:### BEGIN /etc/grub.d/10_linux ###
/etc/grub2.cfg:menuentry 'openEuler (5.10.0-153.12.0.92.oe2203sp2.x86_64) 22.03 (LTS-SP2)' --class openeuler --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-5.10.0-153.12.0.92.oe2203sp2.x86_64-advanced-ebb79a5c-063b-4f85-9c57-4d690e736c5e'
4.
[root@localhost ~]# netstat -tan | grep "\<LISTEN.*\>"
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp6 0 0 :::22 :::* LISTEN
5.
[root@localhost ~]# fdisk -l | grep -E "^/dev/[sh]d[a-z]"
/dev/sda1 * 2048 2099199 2097152 1G 83 Linux
/dev/sda2 2099200 6293503 4194304 2G 82 Linux swap / Solaris
/dev/sda3 6293504 41943039 35649536 17G 83 Linux
6.
[root@localhost ~]# ldd /usr/bin/cat | grep -o "/[^[:space:]]\+"
/usr/lib64/libc.so.6
/lib64/ld-linux-x86-64.so.2
7.
[root@localhost ~]# grep -i ^s /proc/meminfo
SwapCached: 0 kB
SwapTotal: 2097148 kB
SwapFree: 2097148 kB
[root@localhost ~]# grep -i ^[sS] /proc/meminfo
SwapCached: 0 kB
SwapTotal: 2097148 kB
SwapFree: 2097148 kB
Shmem: 17352 kB
8.
[root@localhost ~]# grep -E "(root|centos|spark)" /etc/passwd
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
9.
[root@localhost ~]# echo /mnt/sdc/ | grep -E -o "[^/]+/?$" | cut -d "/" -f 1
sdc
10.
[root@localhost ~]# ifconfig | grep -o -E "\<([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\>"
192
168
30
130
255
255
255
192
168
30
255
64
29
61
9
5
73
127
1
255
1
128
8
8
11.
[root@localhost ~]# grep "^\(.*\):.*\1$" /etc/passwd
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt