随笔分类 - linux shell
摘要:1、问题: Network error: Connection refused 2、解决方法 root@DESKTOP-1N42TVH:~# /etc/init.d/ssh status * sshd is not running 3、 root@DESKTOP-1N42TVH:~# /etc/in
阅读全文
摘要:1、问题 openssl: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory 2、查找 libssl.so.1.1 文件 [ro
阅读全文
摘要:1、测试函数 [root@rhel7pc1 test]# ls test.sh [root@rhel7pc1 test]# cat test.sh ## $1 为第一个参数, $2为第二个参数,其余以此类推 #!/bin/bash function fun_test { seq $1 } 2、加载测
阅读全文
摘要:1、创建自定义函数 格式: function name { command } [root@rhel7pc1 test]# ls test.sh [root@rhel7pc1 test]# cat test.sh ## shell中创建函数格式 #!/bin/bash function fun_te
阅读全文
摘要:1、 [root@rhel7pc1 test]# ls [root@rhel7pc1 test]# a=100 ## 生成测试变量 [root@rhel7pc1 test]# echo $a 100 [root@rhel7pc1 test]# echo $SHELL ## 系统环境变量 /bin/b
阅读全文
摘要:1、查看系统环境变量:env、export 2、查看自定义变量: set、declare 测试系统环境变量: [root@rhel7pc1 test]# ls [root@rhel7pc1 test]# env > a.txt && export > b.txt ## 将env和export命令的输
阅读全文
摘要:1、自定义变量:人为设置的变量 系统环境变量:系统默认的变量 2、查看自定义变量 和 系统环境变量 [root@rhel7pc1 test]# echo $a [root@rhel7pc1 test]# a=100 ## 自定义变量 [root@rhel7pc1 test]# echo $a 100
阅读全文
摘要:1、 [root@rhel7pc1 test]# cat test.sh #!/bin/bash NUM=$[RANDOM % 100 + 1] TIMES=0 while : do read -p "please input a 1~100 num: " ANS TIMES=$[TIMES+1]
阅读全文
摘要:1、 [root@rhel7pc1 test]# ls [root@rhel7pc1 test]# echo $a [root@rhel7pc1 test]# a=100 [root@rhel7pc1 test]# echo $a 100 [root@rhel7pc1 test]# b=a+50 [
阅读全文
摘要:1、$RANDOM $RANDOM 的默认范围是 [0, 32767] [root@rhel7pc1 test]# echo $RANDOM % 100 + 1 | bc 80 [root@rhel7pc1 test]# echo $RANDOM % 100 + 1 | bc 10 [root@rh
阅读全文
摘要:1、linux中awk中next命令相当于循环语句中的continue [root@centos7 test2]# seq 6 1 2 3 4 5 6 [root@centos7 test2]# seq 6 | awk '$0 ~ /5/ {next}; {print $0}' ## 当前行匹配5的
阅读全文
摘要:1、测试 数据 [root@centos7 test2]# ls a.txt [root@centos7 test2]# cat a.txt T1 person1 person2 person3 T2 person1 person2 T3 person1 person2 person3 person
阅读全文
摘要:1、测试数据 [root@centos7 test]# ls test.fa [root@centos7 test]# cat test.fa >chr1 addgg ddges df >chr2 ertfg sdf >chr3 edret dfdff sfdfd d >chr4 iejie sdg
阅读全文
摘要:1、测试数据 [root@centos7 test3]# ls test.txt [root@centos7 test3]# cat test.txt deet dggh df 2、awk实现 [root@centos7 test3]# ls test.txt [root@centos7 test3
阅读全文
摘要:1、测试数据 [root@centos7 test4]# ls test.txt [root@centos7 test4]# cat test.txt 3 2 7 3 2 8 7 [root@centos7 test4]# sort -u test.txt ## sort -u命令 2 3 7 8
阅读全文
摘要:1、测试数据 [root@centos7 test4]# ls test.txt [root@centos7 test4]# cat test.txt d j k j x m y e s g j i x v b d z c e t 2、统计行数和列数 [root@centos7 test4]# ls
阅读全文
摘要:1、测试数据 [root@centos7 test4]# ls test.txt [root@centos7 test4]# cat test.txt e f j f f f d x s f f d g f f d e j k i c f w f d 2、替换第一个f为xxx [root@cento
阅读全文
摘要:1、测试数据 [root@centos7 test4]# ls test.txt [root@centos7 test4]# cat test.txt e f j d i x a d g c F w 2、grep 实现 [root@centos7 test4]# ls test.txt [root@
阅读全文
摘要:1、占用内存最高的进程 [root@centos7 ne]# ps -aux | sort -k 4nr | head -n 3 2、占用cpu最高的进程 [root@centos7 ne]# ps -aux | sort -k 3nr | head -n 3
阅读全文
摘要:1、top或者uptime命令查看平均负载 [root@centos7 ne]# uptime ## 分别表示过去一分钟、过去五分钟、过去15分钟的平均负载 13:54:11 up 5:37, 2 users, load average: 0.00, 0.01, 0.05 2、平均负载与cpu的内核
阅读全文