The third week focuses knowledge

/ etc / passwd empty password code recovery mode clear
the chage the vipw the newgrp
chgrp chown root.root Luo f.txt F.log chown -R & lt root.luo / Data /
chomd U + RW, GR, W + O -R & lt f.txt the chmod RW = U, X = G, X = O the dir /
the chmod -R & lt X-A + the dir / Windows FAT system does not support linux permission to modify
the umask default = 777 + (the dir) 666 (File)
CP -R & lt / etc / skel /. [^.] / Home / git
cp -r / etc / skel /
./home/git obtain all the files

cp -r / etc / skel / home / go; git.git chown -R / home / go; chmod 700 / home / Go

u+s u+t lsattr chattr -i chattr +a
setfacl -m u:luo rwx getfacl f.log setfacl -x u:luo f.log
setfacl -b f.log

= 777-umask directory file = 666-umask Results odd +1

head -c # get the first few bytes of head -n # get the first few lines N1-tail
tail -f F.log Cut -d -f 1, 3-4 / etc / passwd
ifconfig eth0 | -n2 head | tail -n1 | -s TR '' | Cut -d '' - f3
TR a.log b.log Paste Paste -d -d delimiter
SEQ 10 | Paste -sd + | BC
WC f.txt
DF | TR -s ""% | Cut % -F5 -d | Sort -NR
SEQ 55 | -R & lt Sort | head -n1 randomly ordered echo $ = [55% +. 1 the rANDOM]
Cut -d "" -f1 access_log | Sort -u | WC -l
CAT -E ns-CAT
tac Rev NL uniq a.log adjacent characters a.log the Sort | uniq -c
diff -u a.log b.log grep.log grep -f / etc / passwd
"... log" grep | LS. represents any string
grep o / etc / o represents the passwd repeated several times. any character of any length
grep "Go GLE {2}" F1.log
DF | grep "/ dev / SD" | grep -o "[[: digit:]] +% "| TR -d% | -nr the Sort
ip address representation
[0-9] [[: digit: ]] 0 . 9 to
[1-9] [0-9] 10-99
. 1 [0-9] 100-199 {2}
2 [0-4] [0-9 ] 200-249
25 [0-5] 250-255

(([1-9] [0-9] |? 1 [0-9] {2} | 2 [0-4] [0-9] |. 25 [0-5])) {3} ([ 1-9] [0-9] |?. 1 [0-9] {2} | 2 [0-4] [0-9] | 25 [0-5])
echo abcabcabc123 | grep "(ABC). 3 { } "
% S / (root) / A \ 1B / G
extended regular expressions do not \
grep -E" ^ (. ) \>. \ <\ $ 1 "/ etc / passwd
shell script
#! / bin / bash
execution bash hello.sh ./hello.sh
lscpu | grep "Model name" | TR -s "" | Cut -d: -f2
as Free -h | grep Mem | TR -s "" | Cut -d "" -f2
variable
= DATE 'DATE + F.%'
the let N = 2. 3 * echo echo $ N $ [2 . 3] echo $ ((2 . 3))

10.9
username=jie; id $username &> /dev/null && echo $username is exist
||(useradd $username;echo $username is created)

= ~ Behind expressions with positive
file = a.log; [[ "$ file" = ~ .log $]] && echotrue || echo false

file=hello.sh;[[ "$file" =~ .sh$ ]] && chmod +x $file || echo false

==支持通配符
file=hello.txt ;[[ "$file" == *.txt ]] &&echo txt file
file=hello.txt; [[ "$file" =~ .(sh|txt)$ ]] && echo txt or sh file
[ $i -gt $j ] && echo true || echo false
n=99;[ "$n" -gt 90 -a "$n" -lt 100 ] && echo true ||echo false
i="123" ;
file=/etc/issue;[ -f "$file" -a -r "$file" ] && echo true || echo false

i="23"; [[ $i =~ ^[[:digit:]]+$ ]] && echo digit || echo no digit

{ echo hello ;exit; }
df -i |grep "^/dev/sd" | grep -Eo "[0-9]+%" | grep -Eo "[0-9]+"|sort -nr|head -n1

read -p "Please input your name:" NAME
2 read -sp "Please input your passwd:" PASSWD
3 echo
4 echo "your name is $NAME"
5 echo "yourpasswd is $PASSWD"

locate -r "passwd$" locate -r ".conf$"
find /root -maxdepth 2 -mindepth 1
find -name ".sh"
find /data -inum 139 find /data -links 2
find /home -user luo -ls
find /data -type d -empty
find /home -type d -a -name "
luo*"
find /data -size -2M
find / -size +10M | xargs ls -lh
find /data -perm 444 -ls

ls l*| xargs rm

Guess you like

Origin blog.51cto.com/14319741/2442136