1. 程式人生 > >Linux文件、用戶權限及文本處理訓練

Linux文件、用戶權限及文本處理訓練

Linux基礎

技術分享圖片

註:通過練習發現在使用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

技術分享圖片

技術分享圖片

Linux文件、用戶權限及文本處理訓練