菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
377
0

liunx命令

原创
05/13 14:22
阅读数 18881

(2)sudo -i 通过这种方法输入当前管理员用户的密码就可以进到root用户。

tar -cvf target_name.tar dir_or_file # 将目标打包成一个*.tar格式的文件

tar -czvf target_name.tar.gz dir_or_file # 将目标打包并压缩成一个*.tar.gz格式的文件

tar -cjvf target_name.tar.bz2 dir_or_file # 将目标打包并压缩成一个*.tar.bz2格式的文件 

 

du -sh /var/lib/docker/containers/* | sort -nr

du -hxa --max-depth=3 / | sort -h

:g/str1/s//str2/g

zip -r crypto-config.zip  ./crypto-config/*

端口占用

netstat -aon|findstr "49157"

netstat -anpc |grep 10440
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp6       0      0 :::10440                :::*                    LISTEN      28879/java          
>ps -ef | grep 28879

 

ll -h 显示文件大小

grep的-A, -B, -C选项分别可以显示匹配行的后,前,后前多少行内容:

cat myb-service.all.log | grep --count -B 1 '短信发送失败'   --计算总行数
cat myb-service.all.log | grep  -B 1 '短信发送失败'  | grep 'userId' >>1.txt  --显示短信发送失败前一行

cat catalina.2016-05-27.out |grep -C 200  '查询用户开户信息userId=709111956' | grep 'DealFastOpenAccountLogic'

 find /app/server -mmin    +60

 tail -100f  catalina.2016-10-26.out

less file  ; q 退出

对于一些很大的log文件,我们用more查看时会很费劲,没有办法直接跳到末尾再向前查看。

我们可以用less来解决,less查看一个文件时,可以使用类似vi的command命令,在command模式下按G跳到文件末尾,再使用f或B来翻页。

然后Ctrl+G

然后 

按f键,是向前查看  forword

按b键,是向后查看 backword

more 从前往后

发表评论

0/200
377 点赞
0 评论
收藏