In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
本篇内容主要讲解"Linux 运维必备的命令有哪些",感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习"Linux 运维必备的命令有哪些"吧!
1、删除0字节文件
find -type f -size 0 -exec rm -rf {} \;`
2、查看进程
按内存从大到小排列
PS -e -o "%C : %p : %z : %a"|sort -k5 -nr
3、按 CPU 利用率从大到小排列
ps -e -o "%C : %p : %z : %a"|sort -nr
4、打印 cache 里的URL
grep -r -a jpg /data/cache/* | strings | grep "http:" | awk -F'http:' '{print "http:"$2;}'
5、查看 http 的并发请求数及其 TCP 连接状态:
netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
6、 sed -i '/Root/s/no/yes/' /etc/ssh/sshd_config sed 在这个文里 Root 的一行,匹配 Root 一行,将 no 替换成 yes。
7、如何杀掉 MySQL 进程
ps aux |grep mysql |grep -v grep |awk '{print $2}' |xargs kill -9 (从中了解到awk的用途)killall -TERM mysqldkill -9 `cat /usr/local/apache2/logs/httpd.pid` 试试查杀进程PID
8、显示运行 3 级别开启的服务:
ls /etc/rc3.d/S* |cut -c 15- (从中了解到cut的用途,截取数据)
9、如何在编写 SHELL 显示多个信息,用 EOF
cat /root/pkts
38、然后检查IP的重复数并从小到大排序 注意 "-t\ +0" 中间是两个空格
# less pkts | awk {'printf $3"\n"'} | cut -d. -f 1-4 | sort | uniq -c | awk {'printf $1" "$2"\n"'} | sort -n -t\ +0
39、查看有多少个活动的 php-cgi 进程
netstat -anp | grep php-cgi | grep ^tcp | wc -l
40、查看系统自启动的服务
chkconfig --list | awk '{if ($5=="3:on") print $1}'
41、kudzu 查看网卡型号
kudzu --probe --class=network常用正则表达式
1.匹配中文字符的正则表达式: [\u4e00-\u9fa5]
评注:匹配中文还真是个头疼的事,有了这个表达式就好办了
2.匹配双字节字符(包括汉字在内):1
评注:可以用来计算字符串的长度(一个双字节字符长度计2,ASCII字符计1)
3.匹配空白行的正则表达式:\n\s*\r
评注:可以用来删除空白行
4.匹配 HTML 标记的正则表达式:.?|
评注:网上流传的版本太糟糕,上面这个也仅仅能匹配部分,对于复杂的嵌套标记依旧无能为力
5.匹配首尾空白字符的正则表达式:^\s|\s$
评注:可以用来删除行首行尾的空白字符(包括空格、制表符、换页符等等),非常有用的表达式
6.匹配Email地址的正则表达式:
\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
评注:表单验证时很实用
7.匹配网址URL的正则表达式:[a-zA-z]+://3*
评注:网上流传的版本功能很有限,上面这个基本可以满足需求
8.匹配帐号是否合法(字母开头,允许5-16字节,允许字母数字下划线):
^[a-zA-Z][a-zA-Z0-9_]{4,15}$
评注:表单验证时很实用
9.匹配国内电话号码:\d{3}-\d{8}|\d{4}-\d{7}
评注:匹配形式如 0511-4405222 或 021-87888822
10.匹配腾讯QQ号:1-9{4,}
评注:腾讯QQ号从10000开始
11.匹配中国邮政编码:[1-9]\d{5}(?!\d)
评注:中国邮政编码为6位数字
12.匹配×××:\d{15}|\d{18}
评注:中国的×××为15位或18位
13.匹配ip地址:\d+.\d+.\d+.\d+
评注:提取 IP 地址时有用
14.匹配特定数字:
^[1-9]\d*$ //匹配正整数^-[1-9]\d*$ //匹配负整数^-?[1-9]\d*$ //匹配整数^[1-9]\d*|0$ //匹配非负整数(正整数 + 0)^-[1-9]\d*|0$ //匹配非正整数(负整数 + 0)^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$ //匹配正浮点数^-([1-9]\d*\.\d*|0\.\d*[1-9]\d*)$ //匹配负浮点数^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$ //匹配浮点数^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0$ //匹配非负浮点数(正浮点数 + 0)^(-([1-9]\d*\.\d*|0\.\d*[1-9]\d*))|0?\.0+|0$ //匹配非正浮点数(负浮点数 + 0)
评注:处理大量数据时有用,具体应用时注意修正
15.匹配特定字符串:
^[A-Za-z]+$ //匹配由26个英文字母组成的字符串^[A-Z]+$ //匹配由26个英文字母的大写组成的字符串^[a-z]+$ //匹配由26个英文字母的小写组成的字符串^[A-Za-z0-9]+$ //匹配由数字和26个英文字母组成的字符串^\w+$ //匹配由数字、26个英文字母或者下划线组成的字符串
评注:最基本也是最常用的一些表达式
到此,相信大家对"Linux 运维必备的命令有哪些"有了更深的了解,不妨来实际操作一番吧!这里是网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 210
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.