Learn the script for a few days, summarize under the Linux Debian Script common commands.
Linux
1. Add Delete account Useradd/userdel
2. Modify "Zhang San" password passwd Zhang San or echo "User:password" |chpasswd
3. Find grep {-r path} {file} "Find what" or grep-rrni "content" to find "content" in all files in the current directory.
4.PWD Output Current Path
5.tail-n rows shows the last n rows of the file
6.time time/xxx.sh View Script Runtime
7.cut {-d ' split by this character '} {-F 2-5 for segmented area, 2-5 zone} {-C 1-8 pre-cut 1-8-bit} eg:8-bit random password $RANDOM |md5sum|cut-c 1-8
8.shift for function or script input parameters before further
9.test-eq = =-ne! =-gt >-lt <-le <=-ge >=-e file exists-f file-D directory
Multi-with if test ... Or test ... $? (whether the previous statement was executed successfully)
If [];then if test-f./xx.txt; then
Expression A-expression a
else elif []; then
Expression b-expression B
Fi Else
Expression C
Fi
One. While the Read line
Do
Echo $line
Done
12.for i in ' seq 1-5 '
Do
Echo $i
Done
Eg:mybash.sh-a-B 1-c1 (next to)
While getopts AB:C::
Do
Case $ARGV in
A
echo "a";;
b
Bb= $OPTARG echo $bb;;
C
Cc= $OPTARG echo $cc;;
*) exit 1;;
Esac
Done
14.echo-n no return output-e support "\n\t ..."
15.. + library file (Reference library)
16. Package Tar ZCVF file name directory Eg:tar zcvf/root/etc/etc.tar.gz/etc >>file 2>>file Unpack tar zxvf files directory
17. Arithmetic Operation $ ((&i + 1)) equals i++ or expr $i \+1
Fun () {
echo $
}
Fun 1 2
#函数调用
. Cat <<eof
1.aaa
2.bbb
Eof
#打印菜单
20. [[string comparison equals = greater than > less than <]]
[Integer judgment-eq-nq-f-D ...] && YES | | NO
I=1.
echo "String${i}" output string1
Seq 3 Output
1
2
3
Back quotes Echo ' seq 3 ' and echo $ (seq 3) Output 1 2 3
Seq-s "=" 3 output 1=2=3 seq-w 10 output n/a 02 .... 10
$PATH path $UID User ID $ #输入参数个数 $? If the previous instruction is executed correctly, the first parameter $RANDOM a random number
24. Stream redirect Cat 1.txt >/dev/null 2>&1 (2 with 1) 0 standard input 1 standard output 2 error output
25.raad-p "Input:" var read input to parameter Var
26.su root root user logout exit root su user users
27.FG back to Hang program general with Ctrl +z (pause) shared BG Suspend program continues execution
28.=~ and regular expressions
29.vim config file vim ~/.vimrc input set Nu (show line number) syntax on (syntax highlighting)
30. Add path Path 1 "Vim/etc/profile 2" append expot path= "MyPath: $PATH" 3 "Source/etc/profile
31. Set Prophecy lang=en Change English
Dos2unix myfile windos file to UNIX file
diff file1 file2 table file1 file2 and Vimdiff
34.>> Append file > Inflow < outflow | Pipeline
basename file name dirname directory
36. Command statement may error can be added | | Exit 2
PNs. Touch + File Creation file
Awk-f ' split character ' {printf $ awk-f} ' [' Recognize multiple character splits '] ' begin{printf} {} end{} '
39.find directory operation-type f file d directory C character device-mtime modified +1 days ago-11 days-name "Name *.sh"-size file size
Eg: delete current directory 7 days ago SH file find./-type f-name "*.sh"-mtime +7 |xargs RM
40.xargs for commands that do not support pipelines
RM-RF forced recursive deletion
A. alias custom directive permanently added VIM/ROOT/.BASHRC VIM/USER/.BASHRC add rm-i mv-i cp-i ls-a ls-al
Kill-9 Strong killing process
The. Sort Uniq
Curl-i www.baidu.com Server header information curl-s ip.cn?ip=201.37.45.107 query IP address
Not to be continued ...
Reference URL:
Http://edu.51cto.com/course/course_id-6068.html
Linux Common Command Summary