注:通过练习发现在使用grep时,使用-e选项(即扩展正则表达式),可以避免添加更多的转义字符
1
cp -r /etc/skel /home/tuser1 && chmod -R 000 /home/tuser1
2
vi /etc/group
3
Vi /etc/passwd
4
cp -r /etc/skel /home/hadoop && chmod 700 /home/hadoop
5
chown -R hadoop:hadoop /home/hadoop/
6
cat /proc//meminfo | grep "^[s,S]"
cat /proc//meminfo | grep -e "^[s|S]"
7、
cat /etc/passwd | grep -v "/sbin/nologin\>" | cut -d: -f1
8、
cat /etc/passwd | grep "/bin/bash\>" | cut -d: -f1
9、
cat /etc/passwd | grep -E -o "[0-9]{1,2}"
10、
cat /boot/grub/grub.conf | grep "^[[:space:]]"
cat /boot/grub/grub.conf | grep "^[[:space:]]\+"
11、
cat /etc/rc.d/rc.sysinit | grep "^#[[:space:]]\+[^[:space:]]\+"
cat /etc/rc.d/rc.sysinit | grep -E "^#[[:space:]]+[^[:space:]]+"
12
netstat -tan | grep -E "LISTEN[[:space:]]*$
13
useradd bash && useradd testbash && useradd basher && useradd -s /sbin/nologin nologin |grep -E "^([[:alnum:]]+\>).*\1$" /etc/passwd
原文地址:http://blog.51cto.com/13745888/2124328