1. Display the usernames and UIDs of all system users.
cut -d: -f1,3 /etc/passwd |grep "\<[[:digit:]]\{1,3\}\>"
2. Display the users whose default shell is sbin/nologio in the etc/passwd file.
cat /etc/passwd |grep "sbin/nologin"
3. Display the users whose default shell is bin/bash in the etc/passwd file.
cat /etc/passwd |grep "bin/bash"
4. Find the one-digit or two-digit number in the /etc/passwd file.
cat /etc/passwd|grep -o "\<[0-9]\{1,2\}\>"
5. Display lines starting with at least one blank character in /boot/grub/grub.conf.
cat /etc/grub2.cfg |grep "^ "
6. Display the lines in the /etc/rc.d/rc.sysinit file that begin with #, followed by at least one blank character, and then at least one non-blank character.
cat /etc/rc.d/rc.local | grep "^#\s.\+\S" #小写s是空白字符、大写S是非空白字符
The second method
cat etc/rc.d/rc.local |grep "^[#]\+[[:space:]].\+[^[:space:]]"
7. Add users bash, testbash, basher.nologin (this user’s shell is /sbin/nologin). Then find out the information of other users on the current system whose username is the same as the default shell.
cat /etc/passwd|grep "\(^.*\)\>.*/\1$"