随笔分类 -  linux

摘要:【转载】:https://blog.51cto.com/hanzhichao/3436177 在日常Linux操作常常需要对一些文件或屏幕数次中重复的字段进行分组统计。另外分组统计也是常考的面试题之一。实现的方法非常简单,核心命令为:sort | uniq --c | sort -rn 。 sort 阅读全文
posted @ 2022-09-28 17:36 aaacarrot 阅读(1489) 评论(0) 推荐(0)
摘要:背景: 问题描述:too many open files 相信做过开发的人,对这个错误是不会陌生的。 一次服务上线,发现文件上传失败,查看了一下,是说open files不够大了,还是咋的。emmm,怎么办呢。先查看一下 把内存文件dump出来 jmap -dump:live,format=b,fi 阅读全文
posted @ 2022-03-16 21:17 aaacarrot 阅读(272) 评论(0) 推荐(0)
摘要:在linux下想监控一下内存信息,比如每5秒钟,去打印一下 free -m 的结果,并且存储起来,做问题定位用。 就可以想到,用定时任务,crontab, 但有时候并不太想用这个,比如还有一些逻辑要做什么的。这个时候,脚本是一个比较好的选择。 记录一个简单脚本写法 #!/bin/bash while 阅读全文
posted @ 2022-03-09 11:52 aaacarrot 阅读(506) 评论(0) 推荐(0)
摘要:背景 经常遇到一些关于 linux 服务器相关的报错,也挺有意思,记录之 问题1: there is insufficient memory for the java runtime 问题发生:这是怎样发生的呢,在一个服务器上,把一个服务停掉了(服务本来是用 root 起的)。停掉后,因为不想用ro 阅读全文
posted @ 2022-03-02 19:51 aaacarrot 阅读(101) 评论(0) 推荐(0)
摘要:背景 创建了一个用户 useradd -g mygroup -m myuser 创建完之后,切换到 myuser,发现,窗口只显示 $ 了 解决方案 切换到 root vim /etc/passwd 找到 myuser 这一行, 把 bin/sh 改成 bin/bash 保存,即可。 阅读全文
posted @ 2022-03-01 11:51 aaacarrot 阅读(578) 评论(0) 推荐(0)
摘要:背景 时常要在linux下创建用户,要做一些操作。 指令 查看有多少组cat /etc/group 查看当前是什么组groups 查看当前组有多少用户groups test 查看当前登录用户whoami 创建用户 1、useradd -m test 这种写法是不指定组,也不指定目录的,默认产生与用户 阅读全文
posted @ 2022-03-01 11:42 aaacarrot 阅读(1630) 评论(0) 推荐(0)
摘要:查找操作文件 1、linux shell下除了某个文件外的其他文件全部删除的命令 rm -rf !(***.jar) 2、递归删除 find ./ -name "_remote.repositories" -print -exec rm -rf {} \; 3、全量替换文件 sed -i "s/10 阅读全文
posted @ 2022-02-22 13:48 aaacarrot 阅读(235) 评论(0) 推荐(0)
摘要:1、使用方式,修改文件或文件夹的归属 举个例子: 修改单个文件: chown user:user /opt/local/nginx/conf/nginx.conf 修改整个文件夹:chown -R user:user /opt/local/nginx/* 阅读全文
posted @ 2022-02-11 17:45 aaacarrot 阅读(139) 评论(0) 推荐(0)
摘要:1、从本地上传 scp /usr/local/xx.tar.gz root@10.12.3.101:/opt/gd/server/nginx/html 2、从服务器下载到当前目录 scp root@10.12.3.101:/opt/gd/server/nginx/html/gd20220106.zi 阅读全文
posted @ 2022-02-11 17:29 aaacarrot 阅读(128) 评论(0) 推荐(0)