随笔- 310  文章- 1  评论- 0  阅读- 85655 

随笔分类 -  linux

linux 查看某个进程和服务内存占用情况命令
摘要:CPU占用最多的前10个进程 ps auxw|head -1;ps auxw|sort -rn -k3|head -10 内存消耗最多的前10个进程 ps auxw|head -1;ps auxw|sort -rn -k4|head -10 虚拟内存使用最多的前10个进程 ps auxw|head 阅读全文
posted @ 2024-06-21 09:57 boye169 阅读(19) 评论(0) 推荐(0) 编辑
SSH实践生成密码
摘要:$ ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa $ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys $ chmod 0600 ~/.ssh/authorized_keys -t:指定生成密钥类型(rsa、dsa、e 阅读全文
posted @ 2024-06-14 10:07 boye169 阅读(23) 评论(0) 推荐(0) 编辑
Linux 修改文件和文件夹权限
摘要:在 Linux 中,你可以使用 chmod 命令来修改文件和文件夹的权限。chmod 命令用于更改文件和目录的访问权限,即控制谁可以读取、写入和执行文件。以下是在 Linux 中修改文件和文件夹权限的基本方法 使用数字表示法修改权限 使用数字表示法来设置文件或文件夹的权限。数字表示法使用三个数字来表 阅读全文
posted @ 2024-06-04 11:00 boye169 阅读(1585) 评论(0) 推荐(0) 编辑
awk 时间戳格式化
摘要:awk 'BEGIN{aa=strftime("%a","1370210542");print aa}' #Mon awk 'BEGIN{aa=strftime("%Y-%m-%d %H:%M:%S","1370210542");print aa}' #2013-06-03 06:02:22 awk 阅读全文
posted @ 2024-04-12 09:29 boye169 阅读(53) 评论(0) 推荐(0) 编辑
linux一次性新建多个文件/目录
摘要:创建目录 mkdir -p {a,b,c}/src 批量创建文件 touch file{1..10}.txt touch file{a,b}.txt 阅读全文
posted @ 2024-01-19 15:55 boye169 阅读(256) 评论(0) 推荐(0) 编辑
shell getopts 用法
摘要:#!/bin/bash func() { echo "Usage:" echo "test.sh [-j S_DIR] [-m D_DIR]" echo "Description:" echo "S_DIR,the path of source." echo "D_DIR,the path of d 阅读全文
posted @ 2023-12-28 11:09 boye169 阅读(9) 评论(0) 推荐(0) 编辑
AWK 内置函数
摘要:字符串函数 参考:https://www.runoob.com/w3cnote/awk-built-in-functions.html gsub( Ere, Repl, [ In ] ) gsub 是全局替换( global substitution )的缩写。除了正则表达式所有具体值被替代这点,它 阅读全文
posted @ 2023-09-07 10:26 boye169 阅读(45) 评论(0) 推荐(0) 编辑
awk 替换字符串
摘要:test.txt Test|A|0|zhangsan Test|B|0|liming Test|C|1|lisi sub替换 cat test.txt |awk -F'|' '{sub("A","90",$2);sub("B","80",$2);sub("C","60",$2);print $1,$ 阅读全文
posted @ 2023-09-07 10:16 boye169 阅读(196) 评论(0) 推荐(0) 编辑
linux判断文件是否存在
摘要:#!/bin/bash file="/home/test.txt" now_time=`date -u "+%Y-%m-%d %H:%M:%S" -d "8 hour"` if [ ! -f "$file" ];then echo "check time:[$now_time] file $file 阅读全文
posted @ 2023-06-14 17:00 boye169 阅读(80) 评论(0) 推荐(0) 编辑
grep -A -B -C使用介绍
摘要:grep -A 显示匹配指定内容及之后的n行 grep -B 显示匹配指定内容及之前的n行 grep -C 显示匹配指定内容及其前后各n行 grep -A 5 name test.txt 搜索匹配test.txt文件中与”name”字符串匹配的行,并显示其后的5行 阅读全文
posted @ 2023-05-25 15:35 boye169 阅读(96) 评论(0) 推荐(0) 编辑
linux date显示指定时区时间
摘要:显示北京时间 export TZ='Asia/Shanghai' date +"%F %T" 显示指定时区时间 utc0time=`date -u "+%Y-%m-%d %H:%M"` utc8time=`date -u "+%Y-%m-%d %H:%M" -d "8 hour"` 时间运算部分 d 阅读全文
posted @ 2023-04-10 11:13 boye169 阅读(332) 评论(0) 推荐(0) 编辑
awk if else用法
摘要:awk '{if ($1==1) print "A"; else if ($1==2) print "B"; else print "C"}' awk中也支持++或者+=运算符 grep '接口耗时:' test.log|cut -d "m" -f 1 |cut -d ":" -f 2|awk 'B 阅读全文
posted @ 2023-04-06 15:09 boye169 阅读(144) 评论(0) 推荐(0) 编辑
shell sed命令
摘要:命令介绍 sed 主要是用来将数据进行选取、替换、删除、新増的命令。我们看看命令的语法 选项: -n:一般 sed 命令会把所有数据都输出到屏幕上。如果加入此选项,则只会把经过 sed 命令处理的行输出到屏幕上; -e: 允许对输入数据应用多条 sed 命令编辑; -f 脚本文件名:从 sed 脚本 阅读全文
posted @ 2023-03-24 10:49 boye169 阅读(79) 评论(0) 推荐(0) 编辑
awk统计命令
摘要:求和 cat file|awk '{sum+=$1} END {print "Sum = ", sum}' cat file|awk '{sum[$1]+=$2}END{for(c in sum){print c,sum[c]}}' #当第一列相同时,对应的第二列相加 求平均 cat fiile|a 阅读全文
posted @ 2023-02-22 16:05 boye169 阅读(61) 评论(0) 推荐(0) 编辑
使用curl带上用户名和密码
摘要:使用-u标志来包含用户名,并且curl将提示输入密码: curl -u username http://example.com 在命令中包含密码,但您的密码将在bash历史记录中显示 curl -u username:password http://example.comcurl http://us 阅读全文
posted @ 2023-01-11 11:53 boye169 阅读(1850) 评论(0) 推荐(0) 编辑
通过ps命令查看进程启动时间以及运行时间
摘要:ps -eo pid,lstart,etime,cmd | grep tns 阅读全文
posted @ 2023-01-10 14:21 boye169 阅读(644) 评论(0) 推荐(0) 编辑
Linux查看公网IP和私网(内网)IP的方法
摘要:查看Linux公网IP地址 查看Linux公网IP结合第三方网站辅助一下即可,直接curl一下http://ifconfig.me或者http://cip.cc即可 命令:curl ifconfig.me 命令:curl cip.cc 查看Linux的内网IP地址 命令:ifconfig -a 阅读全文
posted @ 2023-01-09 10:53 boye169 阅读(1388) 评论(0) 推荐(0) 编辑
linux进程后台运行及输出重定向
摘要:linux启动后,会默认打开3个文件描述符,0表示标准输入,1表示正确输出,2表示错误输出。 nohup ping www.baidu.com 1>result.out 2>result.out & #将正确输出和错误输出均写入result.out文件nohup ./program > /dev/n 阅读全文
posted @ 2023-01-06 14:26 boye169 阅读(347) 评论(0) 推荐(0) 编辑
linux 下根据服务名称杀死进程
摘要:ps -ef|grep query_test.sh|grep -v grep #查看进程是否存在 ps -ef|grep query_test.sh|grep -v grep |awk '{print $2}'|xargs kill -9 阅读全文
posted @ 2023-01-06 14:21 boye169 阅读(213) 评论(0) 推荐(0) 编辑
linux ls命令详解
摘要:参数 含义-a all, 显示所有文件及目录 (. 开头的隐藏文件也会列出)-A 同-a ,但不列出 “.” (目前目录) 及 “…” (父目录)-l 以长格式显示目录下的内容列表,包括文件的权限、链接数、所有者名称和组所有者、文件大小、最后修改日期时间和文件/目录名称-r reverse,将排序结 阅读全文
posted @ 2022-11-30 16:52 boye169 阅读(226) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示