Linux文件、用户权限及文本处理训练

注:通过练习发现在使用grep时,使用-e选项(即扩展正则表达式),可以避免添加更多的转义字符

1

cp -r /etc/skel /home/tuser1 && chmod -R 000 /home/tuser1

Linux文件、用户权限及文本处理训练

Linux文件、用户权限及文本处理训练

2

vi /etc/group

Linux文件、用户权限及文本处理训练

3

Vi /etc/passwd

Linux文件、用户权限及文本处理训练

4

cp -r /etc/skel /home/hadoop && chmod 700 /home/hadoop

Linux文件、用户权限及文本处理训练

5

chown -R hadoop:hadoop /home/hadoop/

Linux文件、用户权限及文本处理训练

6

cat /proc//meminfo | grep  "^[s,S]"

cat /proc//meminfo | grep -e "^[s|S]"

Linux文件、用户权限及文本处理训练

Linux文件、用户权限及文本处理训练

7、

cat /etc/passwd | grep -v "/sbin/nologin\>" | cut -d: -f1

Linux文件、用户权限及文本处理训练

8、

cat /etc/passwd | grep "/bin/bash\>" | cut -d: -f1

Linux文件、用户权限及文本处理训练

9、

cat /etc/passwd | grep -E -o "[0-9]{1,2}"

Linux文件、用户权限及文本处理训练

10、

cat /boot/grub/grub.conf | grep "^[[:space:]]"

cat /boot/grub/grub.conf | grep "^[[:space:]]\+"

Linux文件、用户权限及文本处理训练

11

cat /etc/rc.d/rc.sysinit | grep "^#[[:space:]]\+[^[:space:]]\+"

cat /etc/rc.d/rc.sysinit | grep -E "^#[[:space:]]+[^[:space:]]+"

Linux文件、用户权限及文本处理训练

12

netstat -tan | grep -E "LISTEN[[:space:]]*$"

Linux文件、用户权限及文本处理训练

13

useradd bash && useradd testbash && useradd basher && useradd -s /sbin/nologin nologin |grep -E "^([[:alnum:]]+\>).*\1$" /etc/passwd

Linux文件、用户权限及文本处理训练

Linux文件、用户权限及文本处理训练