随笔分类 -  linux shell

上一页 1 ··· 47 48 49 50 51 52 53 54 55 ··· 78 下一页
摘要:1、查看系统环境变量:env、export 2、查看自定义变量: set、declare 测试系统环境变量: [root@rhel7pc1 test]# ls [root@rhel7pc1 test]# env > a.txt && export > b.txt ## 将env和export命令的输 阅读全文
posted @ 2022-04-16 17:51 小鲨鱼2018 阅读(480) 评论(0) 推荐(0)
摘要:1、自定义变量:人为设置的变量 系统环境变量:系统默认的变量 2、查看自定义变量 和 系统环境变量 [root@rhel7pc1 test]# echo $a [root@rhel7pc1 test]# a=100 ## 自定义变量 [root@rhel7pc1 test]# echo $a 100 阅读全文
posted @ 2022-04-16 17:00 小鲨鱼2018 阅读(222) 评论(0) 推荐(0)
摘要: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] 阅读全文
posted @ 2022-04-16 13:58 小鲨鱼2018 阅读(251) 评论(0) 推荐(0)
摘要: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 [ 阅读全文
posted @ 2022-04-16 13:30 小鲨鱼2018 阅读(215) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2022-04-16 11:46 小鲨鱼2018 阅读(264) 评论(0) 推荐(0)
摘要: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的 阅读全文
posted @ 2022-04-15 11:41 小鲨鱼2018 阅读(444) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2022-04-15 11:19 小鲨鱼2018 阅读(80) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2022-04-15 09:02 小鲨鱼2018 阅读(619) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2022-04-15 08:21 小鲨鱼2018 阅读(1152) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2022-04-14 14:59 小鲨鱼2018 阅读(190) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2022-04-14 14:52 小鲨鱼2018 阅读(432) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2022-04-14 14:38 小鲨鱼2018 阅读(528) 评论(0) 推荐(0)
摘要: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@ 阅读全文
posted @ 2022-04-14 14:24 小鲨鱼2018 阅读(348) 评论(0) 推荐(0)
摘要: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 阅读全文
posted @ 2022-04-12 14:07 小鲨鱼2018 阅读(657) 评论(0) 推荐(0)
摘要: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的内核 阅读全文
posted @ 2022-04-12 14:00 小鲨鱼2018 阅读(149) 评论(0) 推荐(0)
摘要:linux中当目录具有SGID权限时, 任何用户在该目录中创见的文件将自动继承该目录的所属组。 测试。 1、普通用户家目录创建一个普通文件, 观察文件的所属组 [liujiaxin01@rhel7pc1 ~]$ ls [liujiaxin01@rhel7pc1 ~]$ whoami liujiaxi 阅读全文
posted @ 2022-04-10 18:07 小鲨鱼2018 阅读(333) 评论(0) 推荐(0)
摘要:1、问题 2、解决方法,切换至root用户,修改/etc/sudoers配置文件 [root@rhel7pc1 ~]# vim /etc/sudoers ………… ## The COMMANDS section may have other options added to it. ## ## Al 阅读全文
posted @ 2022-04-10 17:33 小鲨鱼2018 阅读(136) 评论(0) 推荐(0)
摘要:1、linux中文件或者目录的权限针对用户分为三类,即: 所有者,用u表示; 所属组,用g表示; 其他人,用o表示; 针对每一种用户,权限有可以分为三种,即: 读的权限,用r表示,也用数字4代替。 写的权限,用w表示,也用数字2代替。 执行的权限,用x表示,也用数字1代替。 2、举例 文件a.txt 阅读全文
posted @ 2022-04-10 16:45 小鲨鱼2018 阅读(2634) 评论(0) 推荐(0)
摘要:1、 -: 普通文件。 d: 目录文件。 l: 链接文件。 例如:软连接 b: 块设备文件 例如:硬盘 c: 字符设备文件 例如: 系统外设, 鼠标、键盘等。 p: 管道文件 ??? 阅读全文
posted @ 2022-04-10 16:15 小鲨鱼2018 阅读(277) 评论(0) 推荐(0)
摘要:1、 [root@rhel7pc1 test]# ls a.txt [root@rhel7pc1 test]# cat a.txt 1 k d f 2 x c g 3 z c b 4 f i j 5 e d g 6 i j e [root@rhel7pc1 test]# sed '/x/, +1d' 阅读全文
posted @ 2022-04-10 14:52 小鲨鱼2018 阅读(88) 评论(0) 推荐(0)

上一页 1 ··· 47 48 49 50 51 52 53 54 55 ··· 78 下一页