作者:微信小助手
发布时间:2020-11-30T08:18:46
文章来源 51CTO博客 点击蓝字:波哥的IT人生,关注我们 1、删除0字节文件 3、按 CPU 利用率从大到小排列 4、打印 cache 里的URL 5、查看 http 的并发请求数及其 TCP 连接状态: 7、如何杀掉 MySQL 进程 8、显示运行 3 级别开启的服务: 9、如何在编写 SHELL 显示多个信息,用 EOF 10、for 的巧用(如给 MySQL 建软链接)
</ul>
<pre class="code-snippet__js" data-lang="bash"><code style=" white-space:pre-wrap;max-width: 1000%;text-align: left;display: flex; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;box-sizing: border-box !important;overflow-wrap: break-word !important; "><span class="code-snippet_outer" style="max-width: 1000%;box-sizing: border-box !important;overflow-wrap: break-word !important;">find -type f -size 0 -exec rm -rf {} \;</span></code></pre>
</ul>
<pre class="code-snippet__js" data-lang="perl"><code style=" white-space:pre-wrap;max-width: 1000%;text-align: left;display: flex; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;box-sizing: border-box !important;overflow-wrap: break-word !important; "><span class="code-snippet_outer" style="max-width: 1000%;box-sizing: border-box !important;overflow-wrap: break-word !important;">PS -e -o "%C : %p : %z : %a"|sort -k5 -nr</span></code></pre>
</ul>
<pre class="code-snippet__js" data-lang="perl"><code style=" white-space:pre-wrap;max-width: 1000%;text-align: left;display: flex; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;box-sizing: border-box !important;overflow-wrap: break-word !important; "><span class="code-snippet_outer" style="max-width: 1000%;box-sizing: border-box !important;overflow-wrap: break-word !important;">ps -e -o "%C : %p : %z : %a"|sort -nr</span></code></pre>
</ul>
<pre class="code-snippet__js" data-lang="nginx"><code style=" white-space:pre-wrap;max-width: 1000%;text-align: left;display: flex; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;box-sizing: border-box !important;overflow-wrap: break-word !important; "><span class="code-snippet_outer" style="max-width: 1000%;box-sizing: border-box !important;overflow-wrap: break-word !important;">grep -r -a jpg /data/cache/* | strings | grep "http:" | awk -F'http:' '{print "http:"$2;}'</span></code></pre>
</ul>
<pre class="code-snippet__js" data-lang="nginx"><code style=" white-space:pre-wrap;max-width: 1000%;text-align: left;display: flex; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;box-sizing: border-box !important;overflow-wrap: break-word !important; "><span class="code-snippet_outer" style="max-width: 1000%;box-sizing: border-box !important;overflow-wrap: break-word !important;">netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'</span></code></pre>
sed -i '/Root/s/no/yes/' /etc/ssh/sshd_config
sed 在这个文里 Root 的一行,匹配 Root 一行,将 no 替换成 yes。
</ul>
<pre class="code-snippet__js" data-lang="perl"><code style=" white-space:pre-wrap;max-width: 1000%;text-align: left;display: flex; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;box-sizing: border-box !important;overflow-wrap: break-word !important; "><span class="code-snippet_outer" style="max-width: 1000%;box-sizing: border-box !important;overflow-wrap: break-word !important;">ps aux |grep mysql |grep -v grep |awk '{print $2}' |xargs kill -9 (从中了解到awk的用途)</span></code><code style=" white-space:pre-wrap;max-width: 1000%;text-align: left;display: flex; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;box-sizing: border-box !important;overflow-wrap: break-word !important; "><span class="code-snippet_outer"><br></span></code><code style=" white-space:pre-wrap;max-width: 1000%;text-align: left;display: flex; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;box-sizing: border-box !important;overflow-wrap: break-word !important; "><span class="code-snippet_outer" style="max-width: 1000%;box-sizing: border-box !important;overflow-wrap: break-word !important;">killall -TERM mysqld</span></code><code style=" white-space:pre-wrap;max-width: 1000%;text-align: left;display: flex; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;box-sizing: border-box !important;overflow-wrap: break-word !important; "><span class="code-snippet_outer"><br></span></code><code style=" white-space:pre-wrap;max-width: 1000%;text-align: left;display: flex; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;box-sizing: border-box !important;overflow-wrap: break-word !important; "><span class="code-snippet_outer" style="max-width: 1000%;box-sizing: border-box !important;overflow-wrap: break-word !important;">kill -9 `cat /usr/local/apache2/logs/httpd.pid` 试试查杀进程PID</span></code></pre>
</ul>
<pre class="code-snippet__js" data-lang="nginx"><code style=" white-space:pre-wrap;max-width: 1000%;text-align: left;display: flex; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;box-sizing: border-box !important;overflow-wrap: break-word !important; "><span class="code-snippet_outer" style="max-width: 1000%;box-sizing: border-box !important;overflow-wrap: break-word !important;">ls /etc/rc3.d/S* |cut -c 15- (从中了解到cut的用途,截取数据)</span></code></pre>
</ul>
<pre class="code-snippet__js" data-lang="diff"><code style=" white-space:pre-wrap;max-width: 1000%;text-align: left;display: flex; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;box-sizing: border-box !important;overflow-wrap: break-word !important; "><span class="code-snippet_outer" style="max-width: 1000%;box-sizing: border-box !important;overflow-wrap: break-word !important;">cat << EOF</span></code><code style=" white-space:pre-wrap;max-width: 1000%;text-align: left;display: flex; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;box-sizing: border-box !important;overflow-wrap: break-word !important; "><span class="code-snippet_outer" style="max-width: 1000%;box-sizing: border-box !important;overflow-wrap: break-word !important;">+--------------------------------------------------------------+</span></code><code style=" white-space:pre-wrap;max-width: 1000%;text-align: left;display: flex; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;box-sizing: border-box !important;overflow-wrap: break-word !important; "><span class="code-snippet_outer" style="max-width: 1000%;box-sizing: border-box !important;overflow-wrap: break-word !important;">| === Welcome to Tunoff services === |</span></code><code style=" white-space:pre-wrap;max-width: 1000%;text-align: left;display: flex; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;box-sizing: border-box !important;overflow-wrap: break-word !important; "><span class="code-snippet_outer" style="max-width: 1000%;box-sizing: border-box !important;overflow-wrap: break-word !important;">+--------------------------------------------------------------+</span></code><code style=" white-space:pre-wrap;max-width: 1000%;text-align: left;display: flex; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;box-sizing: border-box !important;overflow-wrap: break-word !important; "><span class="code-snippet_outer" style="max-width: 1000%;box-sizing: border-box !important;overflow-wrap: break-word !important;">EOF</span></code></pre>
</ul>
<pre class="code-snippet__js" data-lang="bash"><code style=" white-space:pre-wrap;max-width: 1000%;text-align: left;display: flex; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;box-sizing: border-box !important;overflow-wrap: break-word !important; "><span class="code-snippet_outer" style="max-width: 1000%;box-sizing: border-box !important;overflow-wrap: break-word !important;">cd /usr/local/mysql/bin</span></code><code style=" white-space:pre-wrap;max-width: 1000%;text-align: left;display: flex; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;box-sizing: border-box !important;overflow-wrap: break-word !important; "><span class="code-snippet_outer" style="max-width: 1000%;box-sizing: border-box !important;overflow-wrap: break-word !important;">for i in *</span></code><code style=" white-space:pre-wrap;max-width: 1000%;text-align: left;display: flex; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;box-sizing: border-box !important;overflow-wrap: break-word !important; "><span class="code-snippet_outer" style="max-width: 1000%;box-sizing: border-box !important;overflow-wrap: break-word !important;">do ln /usr/local/mysql/bin/$i /usr/bin/$i</span></code><code style=" white-space:pre-wrap;max-width: