linux
Neil_001
这个作者很懒,什么都没留下…
展开
-
linux 杀死僵尸进程
top及ps显示为zombie的进程# 1. top 查看zombie进程数量# 2.ps -A -ostat,ppid,pid,cmd | grep -e '^[zZ]'# 3.kill -HUP <pid># 4.kill -HUP <ppid>原创 2020-08-03 22:39:56 · 224 阅读 · 0 评论 -
linux VM设置静态网络
1. VMware编辑->虚拟网络编辑器2.设置成如下图,主要是VMnet8的DHCP设置为不启用。同时记住子网、掩码和网关。3.网络共享中心->网络连接->IPv4设置成如下图,注意,首选DNS不要设置,否则可能主机上不了网。4. centos设置TYPE=EthernetPROXY_METHOD=noneBROWSER_ONLY=noB...原创 2020-05-01 01:18:47 · 245 阅读 · 0 评论 -
vim 常用配置
常用设置:set ff=unix (fileformat=unix,即文件使用unix换行符,ff=dos为windows下的换行符)set tabstop=4 (一个tab显示出多少个空格长度,默认为8个)set softtabstop=4 (编辑模式下使用退格键回退缩进的长度)set shiftwidth=4 (每一级缩进的长度, 一般和softtabstop一致)set expa...原创 2020-04-04 02:14:55 · 168 阅读 · 0 评论 -
vim windows下使用
1.下载 git windows客户端2. git bash命令行窗口可以直接使用vi/vim原创 2020-04-04 02:07:27 · 167 阅读 · 0 评论 -
shell 编程 (12)函数
格式:[function] fun(){ action; [return int;]}eg:[root@k8s-master test7]# cat t0.sh #!/bin/bashfun() { echo 'helloworld'}echo 'start...'funecho 'end...'[root@k8s-master test7]#...原创 2020-03-21 02:53:16 · 134 阅读 · 0 评论 -
shell 编程 (11)流程控制
sh脚本的流程控制不可为空,如else后如果没有需要执行的语句,则不要写else1. if-else# 适用于脚本形式if conditionthen command1 command2 ... commandnfi# ---------------------if condition1then command1elif condition2then...原创 2020-03-21 02:40:59 · 161 阅读 · 0 评论 -
shell 编程 (10)test
test命令用于检查某条件是否成立,适用于数值、字符串、文件。数值:-eq:等于为true-ne:不等于为true-gt:大于为true-lt:小于为true-ge:大于等于为true-le:小于等于为true[]中执行基本算述运算字符串:=:等于为true!=:不等于为true-n:不为0为true-z:为0为true文...原创 2020-03-21 02:02:13 · 167 阅读 · 0 评论 -
shell 编程 (9)printf
仿C程序的printf()程序printf format-string [arguments...]format-string用双引号或单引号括起来,如果只有1个输出可不用引号printf需手动添加\n才能起到换行效果。echo会自动添加换行符。%-ns:宽度为n个字符,-左对齐,否则右对齐,不足用空格,超过全部显示%m.nf:整数m位,小数n位。%d:整数无对应参数%...原创 2020-03-21 01:49:46 · 159 阅读 · 0 评论 -
shell 编程 (8)重定向
cmd > file:输出重定向到文件cmd < file:输入重定向到文件cmd >>file:输出追加重定向到文件n > file:将文件描述符为n的文件重定向到filen >> file:描述符为n的文件追加重定向到filen >$ m:输出文件m和n合并到mn <$ m:输入文件m合并到n...原创 2020-03-21 01:34:43 · 167 阅读 · 0 评论 -
shell 编程 (7)文件包含
在一个sh脚本中执行另一个sh脚本使用:. ./t0.shsource ./t0.sh中间有一空格eg:[root@k8s-master test3]# ll总用量 8-rw-r--r--. 1 root root 28 3月 21 01:15 t0.sh-rw-r--r--. 1 root root 60 3月 21 01:16 t2.sh[root@k8s...原创 2020-03-21 01:18:20 · 126 阅读 · 0 评论 -
shell 编程 (6)echo read -e \n \c 重定向
echo str1.显示普通字符串echo "str"可不带""双引号可转义\"str\"eg:[root@k8s-master test2]# echo strstr[root@k8s-master test2]# echo "str"str[root@k8s-master test2]# echo \"str\""str"[root@k8s-master...原创 2020-03-21 01:03:53 · 862 阅读 · 0 评论 -
shell 编程 (5)基本运算符
一、算术运算1. expr支持算术运算使用反引号``,表达式与运算符之间必须有空格。`expr 2 + 3`中的2、3与+之间必须有空格。[root@k8s-master ~]# val=`expr 2 + 3`[root@k8s-master ~]# echo $val5+:加-:减*:乘 (符号前必须加转义符反余杠/)/:除%:取余=:赋值==...原创 2020-03-21 00:48:20 · 263 阅读 · 0 评论 -
shell 编程 (4)传参
向脚本传递参数:./script_name.sh var0 var1 var2脚本内取参:$0:文件名$1:第1个参数$2:第2个参数[root@k8s-master test0]# cat test8.sh #!/bin/bashecho "params:"echo "script name: $0";echo "first param: $1";...原创 2020-03-20 01:26:25 · 167 阅读 · 0 评论 -
shell 编程 (3)注释
1. 使用#进行单行注释。2. 将要注释的代码块放在函数中,没有地方调用此函数,达到相同效果。3.:<<EOFXXXEOF其中EOF可换成其他字符(不能用单引号)。[root@k8s-master test0]# sh test7.sh startsecondtest7.sh:行25: 警告:立即文档在第 22 行被文件结束符分隔 (需要 `...原创 2020-03-20 01:10:55 · 950 阅读 · 0 评论 -
shell 编程 (2) 数组
数组:只支持一维,不限定大小。下标由0开始,可以是整数或算数表达式,大于或等于0。1.定义数组arr_name=(val0, val1, ..., valn)arr_name=(val00val11)arr_name[n]=valuen下标可以不连续。[root@k8s-master test0]# arr_name=(val0, val1, val...原创 2020-03-20 00:59:53 · 142 阅读 · 0 评论 -
shell 编程 (1)简单使用
1. helloworld(1)作为可执行程序第1行指定解释器信息:#!/bin/bash(2)作为解释器参数,直接运行解释器,参数为shell脚本文件名eg: /bin/sh test.sh[root@k8s-master test0]# sh test.sh Hello World![root@k8s-master test0]# chmod +x ./test...原创 2020-03-20 00:49:21 · 153 阅读 · 0 评论 -
centos 网络工具
yum install tcpdump:截获数据包yum install traceroute: 路由跳数tcpdump -i ens33 icmp and src host "192.168.159.132" -nn原创 2020-03-16 02:10:56 · 162 阅读 · 0 评论 -
linux xargs
[root@k8s-master test2]# cat test2.txt HELLOWORLDTHIS IS A TESTEOF TEST![root@k8s-master test2]# cat test2.txt | xargs -I {} echo start {} endstart HELLOWORLD endstart THIS IS A TEST end...原创 2020-02-08 17:01:42 · 99 阅读 · 0 评论 -
linux find
[root@k8s-master test2]# ll总用量 8-rw-r--r--. 1 root root 11 2月 8 16:32 test1.txt-rw-r--r--. 1 root root 36 2月 8 16:34 test2.txt[root@k8s-master test2]# find . -type f -name '*1.txt'./test1...原创 2020-02-08 16:53:09 · 320 阅读 · 0 评论 -
linux EOF
EOF: END OF FILE>>输入追加>输入重定向<输出重定向<<输出追加[root@k8s-master test2]# ll总用量 0[root@k8s-master test2]# cat <<EOF >test1.txt> A> B> CDEFG> EOF[r...原创 2020-02-08 16:36:07 · 124 阅读 · 0 评论 -
linux grep
-c: --count列数-d: --directories目录-e: --regexp:正则-f: --file规则文件-l: --file-with-matches匹配的文件-L: --files-without-match不符合的文件-n: --line-number:标出该行的列-o: --only-matching:只显示匹配的部分-v: ...原创 2020-02-08 16:27:27 · 88 阅读 · 0 评论 -
linux sed
说明:[root@k8s-master test1]# cat test.txthello1worldhello1worldhello1world221hellothis is a test!^开始$结束.任意一个* 0个或多个[]指定范围中[^] 不在指定范围中\(..\)保存匹配的字符,后面用数字表式[root@k8s-master t...原创 2020-02-08 15:30:17 · 148 阅读 · 0 评论 -
linux grep cut tr
[root@k8s-master ~]# kubectl config viewapiVersion: v1clusters:- cluster: certificate-authority-data: DATA+OMITTED server: https://192.168.159.135:6443 name: kubernetescontexts:- co...原创 2020-02-02 10:37:46 · 290 阅读 · 0 评论 -
vim
Vim命令参考:(https://www.runoob.com/linux/linux-vim.html)命令 功能 (次数)hjkl 移动多少行(格) ctrl + f(下页),b(上页),u(上半页),d(下半页) +/-(非空格符上/下一行) n<space>向右移动n个字符 0/$(一行的开头/结尾) ...原创 2019-09-28 19:07:03 · 120 阅读 · 0 评论 -
awk的使用
参考1:https://www.cnblogs.com/bugingcode/p/8287914.html参考2:https://blog.csdn.net/ha_weii/article/details/80761559来自:创始人Alfred Aho 、Peter Weinberger 和 Brian Kernighan的首字母样式扫描和处理语言awk 'BEGIN{comma...原创 2019-09-28 18:55:16 · 124 阅读 · 0 评论