栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

linux常用命令top(linux常用命令手册)

linux常用命令top(linux常用命令手册)

常用命令

top

那么首先需要获取这个进程的PID:

ps -ef|grep [process name] 获取某个进程名的进程号

ps -ef |grep mesos | grep -v grep | awk ‘{print $2}’

ps -ef |grep YarnChild | awk ‘{print $2}’| xargs kill -9

然后查看该进程的CPU:

top -p [PID] 查看这个进程的各个线程的CPU:

top -H -p [PID]

CPU,内存,虚拟内存占用最多的前10个进程

ps auxw|head -1;

ps auxw|sort -rn -k3|head -10
该命令组合实际上是下面两句命令:

ps aux|head -1
ps aux|grep -v PID|sort -rn -k +3|head

内存占用最多
ps auxw|head -1;ps auxw|sort -rn -k4|head -10

虚拟内存占用最多
ps auxw|head -1;ps auxw|sort -rn -k5|head -10

接下来的grep -v PID是将ps aux命令得到的标题去掉,即grep不包含PID这三个字母组合的行,再将其中结果使用sort排序。
sort -rn -k +3该命令中的-rn的r表示是结果倒序排列,n为以数值大小排序,而-k +3则是针对第3列的内容进行排序,再使用head命令获取默认前10行数据。(其中的|表示管道操作)

dstat

sudo apt-get install dstat vmstat

sudo apt-get install sysstat pidstat

pidstat -w -p 38264 -t 1
w: context switches, p:pid, t:thread context switches 1: 1 second interval u: CPU utilizationpidstat -w -u count the total number of processes and threads

process:ps axu | wc -lthreads:ps -eo nlwp | tail -n +2 | awk ‘{ num_threads += $1 } END { print num_threads }’ grep

grep “ExecutorDriver” -nr ./* --exclude-dir=“tests” --exclude-dir=“python” --exclude=".py" --exclude=".in" --exclude="*.am" --exclude-dir=“java”

只在目录中所有的.php和.html文件中递归搜索字符"main()"
grep “main()” . -r --include *.{php,html}

grep and or

-E -i “uah|ee”

grep sed 大批量替换字符串

sed -i s/slave0/slave4/g grep "slave0" -rl ./*
将当前目录下的所有.c、.h文件中的str1字符串替换为str2字符串。

sed -i s/“spark.eventLog.compress True”/“spark.eventLog.compress False”/g grep "spark.eventLog.compress True" -rl ./*

参数解释:
sed:
-i 表示操作的是文件,``括起来的grep命令,表示将grep命令的的结果作为操作文件
s/“str1”/“str2”/表示查找str1并替换为str2,后面跟g表示一行中有多个str1的时候,都替换,而不是仅替换第一个

grep:
-r表示查找当前目录以及所有子目录
-l表示仅列出符合条件的文件名,传给sed命令做替换操作
–include="*.[ch]" 表示仅查找.c、.h文件

sed

sed -i s/“str1”/“str2”/g ./*.[ch]
注:如果不需要查找子目录,仅需要在当前目录替换,可直接用sed命令:

其中第一句主要是为了获取标题(USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND)。

ps auxw --sort=rss
ps auxw --sort=%cpu
找出消耗资源最高的线程

top -H -p 1114 可以不用第一步,直接执行命令 top -H ,就可以查看到消耗资源最高的线程

dstat -tcdngmy --output ./test_word_count_182cores.csv 1 120

hadoop

hadoop fs -mkdir /user/lemaker/logshadoop fs -mkdir -p /user/lemaker/flink/completed-jobs/
hadoop shell 命令
https://hadoop.apache.org/docs/r1.0.4/cn/hdfs_shell.html 查看这个线程所有系统调用

strace -p 1228 或 strace -cp 1228 ssh

ssh-copy-id -i ~/.ssh/id_rsa.pub lemaker@p10 sudo 免密码

lemaker ALL=NOPASSWD: ALL

ssh-keygen -R 172.20.110.213

tar

tar -C /usr/local -xzf go1.14.6.linux-amd64.tar.gz 解压文件到到某个目录

tar -zcvf file.tar.gz file1 file2 压缩若干个文件

tar -zcvf test.tar.gz --exclude=test/1 test 压缩文件但并不包含其中某个目录

vim

全局替换1,$ s/172.20.110.53/localhost:%s/abc/ew/g find

find /home -name “*.txt” 在某个目录下查找名为txt后缀的文件

find . -maxdepth 3 -type f
-find -name ‘.php’|xargs grep ‘include’//在当前目录及其子目录的php文件中查找include字符串
 -  find . -name '
.php’ -exec grep -i -nH “include” {} ;//同上

find . -name “.git” | xargs rm -Rf 查找对应文件并删除

du 文件大小倒序排序

du -sh * | sort -nr

du -s * | sort -nr

sudo du -h --max-depth=1

kill

kill -9 ps -ef|grep "pycharm" |grep -v grep|awk '{print $2}'

kill -9 ps -ef|grep "slave" |grep -v grep|awk '{print $2}'

ps -ef |grep master |awk ‘{print $2}’|xargs kill -9

ps -ef |grep clion |awk ‘{print $2}’|xargs kill -9

ps -ef |grep zookeeper |awk ‘{print $2}’|xargs kill -9

ps -ef |grep sunlo |awk ‘{print $2}’|xargs kill -9

ps -ef |grep “mesos-master --wor” |awk ‘{print $2}’| xargs kill -9

ps -ef |grep “mesos-master --work” | grep -v grep | awk ‘{print $2}’ | xargs top -p

kill -9 ps -ef|grep "wps" |grep -v grep|awk '{print $2}'

netstat

netstat -lntp |grep 8082 rsync

将dirA的所有文件同步到dirB,但是在dirB内除了fileB3.txt这个文件不删之外,其他的都删除。

rsync -avz --delete --exclude “fileB3.txt” dirA/ dirB/

rsync -avz --delete Hibench

rsync -avz Chameleon --delete --exclude “work_dir” lemaker@ccrfox247:~/open-source/

rsync -avz Chameleon lemaker@ccrfox247:~/open-source/

ftp

安装vsftpd

sudo apt-get install vsftpd (安装)sudo service vsftpd start (启动)

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/772211.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号