{"id":914,"date":"2014-08-08T06:14:50","date_gmt":"2014-08-08T06:14:50","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=914"},"modified":"2014-08-08T06:14:50","modified_gmt":"2014-08-08T06:14:50","slug":"linux%e5%91%bd%e4%bb%a4%e5%ad%a6%e4%b9%a0_2","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/914.html","title":{"rendered":"Linux\u547d\u4ee4\u5b66\u4e60_2"},"content":{"rendered":"<div>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n:%s\/hello\/&amp;\/gn\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 #\u5728Vim\u4e2d\u67e5\u627e\u6587\u4ef6\u91cc\u4efb\u4f55\u5730\u65b9\u51fa\u73b0\u4e86\u201chello\u201d\u7684\u6b21\u6570<br \/>\n:%s\/&lt;hello&gt;\/&amp;\/gn\u00a0\u00a0\u00a0 #\u5728Vim\u4e2d\u67e5\u627e\u6587\u4ef6\u91cc\u4efb\u4f55\u5730\u65b9\u51fa\u73b0\u4e86\u5355\u8bcd\u201chello\u201d\u7684\u6b21\u6570<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/div>\n<div>\n<h6>VIM\u7edf\u8ba1\u5355\u8bcd\u6570\u3001\u884c\u6570\u7b49 *count-items*<\/h6>\n<div style=\"padding-left: 30px;\">:%s\/.\/&amp;\/gn \u5b57\u7b26\u6570<br \/>\n:%s\/i+\/&amp;\/gn \u5355\u8bcd\u6570<br \/>\n:%s\/^\/\/n \u884c\u6570<br \/>\n:%s\/the\/&amp;\/gn \u4efb\u4f55\u5730\u65b9\u51fa\u73b0\u7684 &#8220;the&#8221;<\/div>\n<div>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/div>\n<\/div>\n<h6>pgrep\u548cpkill\u547d\u4ee4<\/h6>\n<div>\n<pre class=\"lang:default decode:true\">$ ps -ef | grep swiftfox\n$ ps aux | grep swiftfox\n$ pgrep -l swiftfox\n$ pkill -e swiftfox\n\n# pgrep --help\nUsage:\npgrep [options] &lt;pattern&gt;\n\n...\n-l, --list-name list PID and process name #\u6253\u5370pid\u548c\u8fdb\u7a0b\u540d\n-v, --inverse negates the matching\uff08negate n. \u5bf9\u7acb\u9762\uff1b\u53cd\u9762\uff1bv. \u5426\u5b9a\uff1b\u65e0\u6548\uff09\n-f, --full use full process name to match #\u5168\u540d\u5339\u914d\n...<\/pre>\n<p>\u5b9e\u4f8b\uff1a<\/p>\n<pre class=\"lang:default decode:true\"># pgrep hydra\n20138\n20141\n20142\n20143\n20144\n20145\n20146\n20147\n20148\n20149\n20150\n20152\n20153\n20154\n20155\n20158\n20159\n\n# pkill hydra #\u6740\u6389\u4e86\uff0c\u4f46\u662f\u6ca1\u6709\u56de\u663e\uff0c\u4e0d\u6e05\u695a\u5177\u4f53\u600e\u4e48\u4e86\uff0c\u9700\u8981\u201c-e\u201d\u9009\u9879\n# ps aux | grep hydra\nroot 20262 0.0 0.1 4676 832 pts\/1 S+ 18:07 0:00 grep --color=auto hydra\n\n# pkill --help\nUsage:\npkill [options] &lt;pattern&gt;\n...\n-e, --echo display what is killed #\u5728kill\u8fdb\u7a0b\u65f6\uff0c\u6253\u5370\u88abkill\u6389\u7684\u8fdb\u7a0b\u4fe1\u606f\n...<\/pre>\n<\/div>\n<h6>\u83b7\u53d6\u6307\u5b9a\u540e\u7f00\u540d\u7684\u6587\u4ef6\u603b\u4e2a\u6570\u547d\u4ee4\uff1a<\/h6>\n<div>\n<pre class=\"lang:default decode:true\">find . -name \"*.html\" | wc -l<\/pre>\n<\/div>\n<h6>\u83b7\u53d6\u5f53\u524d\u76ee\u5f55\u4e0b\u6587\u4ef6\u603b\u884c\u6570\u4ee5\u53ca\u5355\u4e2a\u6587\u4ef6\u884c\u6570\uff1a<\/h6>\n<div>\n<pre class=\"lang:default decode:true\">find . -name \"*.html\" | xargs wc -l<\/pre>\n<\/div>\n<h6>\u7edf\u8ba1\u67d0\u6587\u4ef6\u5939\u4e0b\u6587\u4ef6\u7684\u4e2a\u6570<\/h6>\n<div>ls -l |grep &#8220;^-&#8220;|wc -l<\/div>\n<h6>\u7edf\u8ba1\u67d0\u6587\u4ef6\u5939\u4e0b\u76ee\u5f55\u7684\u4e2a\u6570<\/h6>\n<div>ls -l |grep &#8220;^\uff44&#8221;|wc -l<\/div>\n<h6>\u7edf\u8ba1\u6587\u4ef6\u5939\u4e0b\u6587\u4ef6\u7684\u4e2a\u6570\uff0c\u5305\u62ec\u5b50\u6587\u4ef6\u5939\u91cc\u7684<\/h6>\n<div>ls -lR|grep &#8220;^-&#8220;|wc -l<\/div>\n<h6>\u7edf\u8ba1\u6587\u4ef6\u5939\u4e0b\u76ee\u5f55\u7684\u4e2a\u6570\uff0c\u5305\u62ec\u5b50\u6587\u4ef6\u5939\u91cc\u7684<\/h6>\n<div>ls -lR|grep &#8220;^d&#8221;|wc -l<\/div>\n<div><\/div>\n<div>\u8bf4\u660e\uff1a<\/div>\n<div>\u00a0ls -l<br \/>\n\u957f\u5217\u8868\u8f93\u51fa\u8be5\u76ee\u5f55\u4e0b\u6587\u4ef6\u4fe1\u606f(\u6ce8\u610f\u8fd9\u91cc\u7684\u6587\u4ef6\uff0c\u4e0d\u540c\u4e8e\u4e00\u822c\u7684\u6587\u4ef6\uff0c\u53ef\u80fd\u662f\u76ee\u5f55\u3001\u94fe\u63a5\u3001\u8bbe\u5907\u6587\u4ef6\u7b49)<br \/>\ngrep &#8220;^-&#8221;<br \/>\n\u8fd9\u91cc\u5c06\u957f\u5217\u8868\u8f93\u51fa\u4fe1\u606f\u8fc7\u6ee4\u4e00\u90e8\u5206\uff0c\u53ea\u4fdd\u7559\u4e00\u822c\u6587\u4ef6\uff0c\u5982\u679c\u53ea\u4fdd\u7559\u76ee\u5f55\u5c31\u662f ^d<br \/>\nwc -l<br \/>\n\u7edf\u8ba1\u8f93\u51fa\u4fe1\u606f\u7684\u884c\u6570\uff0c\u56e0\u4e3a\u5df2\u7ecf\u8fc7\u6ee4\u5f97\u53ea\u5269\u4e00\u822c\u6587\u4ef6\u4e86\uff0c\u6240\u4ee5\u7edf\u8ba1\u7ed3\u679c\u5c31\u662f\u4e00\u822c\u6587\u4ef6\u4fe1\u606f\u7684\u884c\u6570\uff0c\u53c8\u7531\u4e8e\u4e00\u884c\u4fe1\u606f\u5bf9\u5e94\u4e00\u4e2a\u6587\u4ef6\uff0c\u6240\u4ee5\u4e5f\u5c31\u662f\u6587\u4ef6\u7684\u4e2a\u6570\u3002<\/div>\n<h5>Linux\u73af\u5883\u4e2d\u7edf\u8ba1\u6587\u4ef6\u5939\u4e2d\u6587\u4ef6\u6570\u76ee<\/h5>\n<h6>\u7b2c\u4e00\u79cd\u65b9\u6cd5\uff1a<\/h6>\n<div>\u00a0ls -l|grep \u201c^-\u201d|wc -l<\/div>\n<div><\/div>\n<div>ls -l \u957f\u5217\u8868\u8f93\u51fa\u8be5\u76ee\u5f55\u4e0b\u6587\u4ef6\u4fe1\u606f(\u6ce8\u610f\u8fd9\u91cc\u7684\u6587\u4ef6\uff0c\u4e0d\u540c\u4e8e\u4e00\u822c\u7684\u6587\u4ef6\uff0c\u53ef\u80fd\u662f\u76ee\u5f55\u3001\u94fe\u63a5\u3001\u8bbe\u5907\u6587\u4ef6\u7b49)\u3002\u5982\u679cls -lR | grep \u201c^-\u201d | wc -l \u5219\u53ef\u4ee5\u8fde\u5b50\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u4e00\u8d77\u7edf\u8ba1\u3002<\/div>\n<div><\/div>\n<div>grep ^- \u8fd9\u91cc\u5c06\u957f\u5217\u8868\u8f93\u51fa\u4fe1\u606f\u8fc7\u6ee4\u4e00\u90e8\u5206\uff0c\u53ea\u4fdd\u7559\u4e00\u822c\u6587\u4ef6\uff0c\u5982\u679c\u53ea\u4fdd\u7559\u76ee\u5f55\u5c31\u662f ^d<\/div>\n<div><\/div>\n<div>wc -l \u7edf\u8ba1\u8f93\u51fa\u4fe1\u606f\u7684\u884c\u6570\uff0c\u56e0\u4e3a\u5df2\u7ecf\u8fc7\u6ee4\u5f97\u53ea\u5269\u4e00\u822c\u6587\u4ef6\u4e86\uff0c\u6240\u4ee5\u7edf\u8ba1\u7ed3\u679c\u5c31\u662f\u4e00\u822c\u6587\u4ef6\u4fe1\u606f\u7684\u884c\u6570\uff0c\u53c8\u7531\u4e8e\u4e00\u884c\u4fe1\u606f\u5bf9\u5e94\u4e00\u4e2a\u6587\u4ef6\uff0c\u6240\u4ee5\u4e5f\u5c31\u662f\u6587\u4ef6\u7684\u4e2a\u6570\u3002<\/div>\n<h6>\u7b2c\u4e8c\u79cd\u65b9\u6cd5\uff1a<\/h6>\n<div>find .\/ -type f | wc -l<\/div>\n<div><\/div>\n<div>\u7531\u4e8e\u9ed8\u8ba4find\u4f1a\u53bb\u5b50\u76ee\u5f55\u67e5\u627e\uff0c\u5982\u679c\u53ea\u60f3\u67e5\u627e\u5f53\u524d\u76ee\u5f55\u7684\u6587\u4ef6\u7528find .\/ -maxdepth 1 -type f | wc -l\u5373\u53ef\u3002<\/div>\n<div><\/div>\n<div><strong><span style=\"color: #ff0000;\">\u9700\u8981\u8bf4\u660e\u7684\u662f\u7b2c\u4e8c\u79cd\u65b9\u6cd5\u4f1a\u6bd4\u7b2c\u4e00\u79cd\u65b9\u6cd5\u5feb\u5f88\u591a\uff0c\u5c24\u5176\u662f\u4e5f\u7edf\u8ba1\u5b50\u76ee\u5f55\u65f6\u3002<\/span><\/strong><\/div>\n<hr \/>\n<h5>Linux shell\u7528\u6cd5\u548c\u6280\u5de7<\/h5>\n<div>\u4f7f\u7528Linux shell\u662f\u6211\u6bcf\u5929\u7684\u57fa\u672c\u5de5\u4f5c\uff0c\u4f46\u6211\u7ecf\u5e38\u4f1a\u5fd8\u8bb0\u4e00\u4e9b\u6709\u7528\u7684shell\u547d\u4ee4\u548c\u6280\u5de7\u3002\u5f53\u7136\uff0c\u547d\u4ee4\u6211\u80fd\u8bb0\u4f4f\uff0c\u4f46\u6211\u4e0d\u6562\u8bf4\u80fd\u8bb0\u5f97\u5982\u4f55\u7528\u5b83\u6267\u884c\u67d0\u4e2a\u7279\u5b9a\u4efb\u52a1\u3002\u4e8e\u662f\uff0c\u6211\u5f00\u59cb\u5728\u4e00\u4e2a\u6587\u672c\u6587\u4ef6\u91cc\u8bb0\u5f55\u8fd9\u4e9b\u7528\u6cd5\uff0c\u5e76\u653e\u5728\u6211\u7684Dropbox\u91cc\uff0c\u73b0\u5728\uff0c\u5411\u5927\u5bb6\u5206\u4eab\u8fd9\u4e2a\u6587\u4ef6\u3002\u8fd9\u4e2a\u6587\u4ef6\u6211\u4f1a\u4e0d\u65ad\u7684\u66f4\u65b0\u3002\u9700\u8981\u6ce8\u610f\u4e00\u70b9\u7684\u662f\uff0c\u6709\u4e9b\u7528\u6cd5\u9700\u8981\u5728\u4f60\u7684Linux\u7cfb\u7edf\u91cc\u5b89\u88c5\u989d\u5916\u7684\u8f6f\u4ef6\u3002<\/div>\n<div><\/div>\n<div>\n<h6>\u68c0\u67e5\u8fdc\u7a0b\u7aef\u53e3\u662f\u5426\u5bf9bash\u5f00\u653e\uff1a<\/h6>\n<p><span style=\"line-height: 1.5;\">echo &gt;\/dev\/tcp\/8.8.8.8\/53 &amp;&amp; echo &#8220;open&#8221;<\/span><\/p>\n<\/div>\n<h6>\u8ba9\u8fdb\u7a0b\u8f6c\u5165\u540e\u53f0\uff1a<\/h6>\n<div>Ctrl + z<\/div>\n<h6>\u5c06\u8fdb\u7a0b\u8f6c\u5230\u524d\u53f0\uff1a<\/h6>\n<div>fg<\/div>\n<h6>\u4ea7\u751f\u968f\u673a\u7684\u5341\u516d\u8fdb\u5236\u6570\uff0c\u5176\u4e2dn\u662f\u5b57\u7b26\u6570\uff1a<\/h6>\n<div>openssl rand -hex n<\/div>\n<h6>\u5728\u5f53\u524dshell\u91cc\u6267\u884c\u4e00\u4e2a\u6587\u4ef6\u91cc\u7684\u547d\u4ee4\uff1a<\/h6>\n<div>source \/home\/user\/file.name<\/div>\n<h6>\u622a\u53d6\u524d5\u4e2a\u5b57\u7b26\uff1a<\/h6>\n<div>${variable:0:5}<\/div>\n<h6>SSH debug \u6a21\u5f0f\uff1a<\/h6>\n<div>ssh -vvv user@ip_address<\/div>\n<h6>SSH with pem key\uff1a<\/h6>\n<div>ssh user@ip_address -i key.pem<\/div>\n<h6>\u7528wget\u6293\u53d6\u5b8c\u6574\u7684\u7f51\u7ad9\u76ee\u5f55\u7ed3\u6784\uff0c\u5b58\u653e\u5230\u672c\u5730\u76ee\u5f55\u4e2d\uff1a<\/h6>\n<div>\n<pre class=\"lang:default decode:true\">wget -r --no-parent --reject \"index.html*\" http:\/\/hostname\/ -P \/home\/user\/dirs<\/pre>\n<\/div>\n<h6>\u4e00\u6b21\u521b\u5efa\u591a\u4e2a\u76ee\u5f55\uff1a<\/h6>\n<div>mkdir -p \/home\/user\/{test,test1,test2}<\/div>\n<h6>\u5217\u51fa\u5305\u62ec\u5b50\u8fdb\u7a0b\u7684\u8fdb\u7a0b\u6811( pstree -a )\uff1a<\/h6>\n<div>ps axwef<\/div>\n<h6>\u521b\u5efa war \u6587\u4ef6\uff1a<\/h6>\n<div>jar -cvf name.war file<\/div>\n<h6>\u6d4b\u8bd5\u786c\u76d8\u5199\u5165\u901f\u5ea6\uff1a<\/h6>\n<div>dd if=\/dev\/zero of=\/tmp\/output.img bs=8k count=256k; rm -rf \/tmp\/output.img<\/div>\n<h6>\u6d4b\u8bd5\u786c\u76d8\u8bfb\u53d6\u901f\u5ea6\uff1a<\/h6>\n<div>hdparm -Tt \/dev\/sda<\/div>\n<h6>\u83b7\u53d6\u5b57\u7b26\u4e32\/\u6587\u672c\u7684md5 hash\uff1a<\/h6>\n<div>echo -n &#8220;text&#8221; | md5sum<\/div>\n<h6>\u68c0\u67e5xml\u683c\u5f0f\uff1a<\/h6>\n<div>\n<pre class=\"lang:default decode:true \">xmllint --noout file.xml<\/pre>\n<h6>\u5c06tar.gz\u63d0\u53d6\u5230\u65b0\u76ee\u5f55\u91cc\uff1a<\/h6>\n<p><span style=\"line-height: 1.5;\">tar zxvf package.tar.gz -C new_dir<\/span><\/p>\n<\/div>\n<h6>\u4f7f\u7528curl\u83b7\u53d6HTTP\u5934\u4fe1\u606f\uff1a<\/h6>\n<div>curl -I http:\/\/www.example.com<\/div>\n<h6>\u4fee\u6539\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u65f6\u95f4\u6233(YYMMDDhhmm)\uff1a<\/h6>\n<div>touch -t 0712250000 file<\/div>\n<h6>\u7528wget\u547d\u4ee4\u6267\u884cftp\u4e0b\u8f7d\uff1a<\/h6>\n<div>wget -m ftp:\/\/username:password@hostname<\/div>\n<h6>\u751f\u6210\u968f\u673a\u5bc6\u7801(\u4f8b\u5b50\u91cc\u662f16\u4e2a\u5b57\u7b26\u957f)\uff1a<\/h6>\n<div>LANG=c &lt; \/dev\/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-16};echo;<\/div>\n<h6>\u5feb\u901f\u5907\u4efd\u4e00\u4e2a\u6587\u4ef6\uff1a<\/h6>\n<div>cp some_file_name{,.bkp}<\/div>\n<h6>\u8bbf\u95eeWindows\u5171\u4eab\u76ee\u5f55\uff1a<\/h6>\n<div>smbclient -U &#8220;DOMAINuser&#8221; \/\/dc.domain.com\/share\/test\/dir<\/div>\n<h6>\u6267\u884c\u5386\u53f2\u8bb0\u5f55\u91cc\u7684\u547d\u4ee4(\u8fd9\u91cc\u662f\u7b2c100\u884c)\uff1a<\/h6>\n<div>!100<\/div>\n<h6>\u89e3\u538b\uff1a<\/h6>\n<div>unzip package_name.zip -d dir_name<\/div>\n<h6>\u8f93\u5165\u591a\u884c\u6587\u5b57(CTRL + d \u9000\u51fa)\uff1a<\/h6>\n<div>cat &gt; test.txt<\/div>\n<h6>\u521b\u5efa\u7a7a\u6587\u4ef6\u6216\u6e05\u7a7a\u4e00\u4e2a\u73b0\u6709\u6587\u4ef6\uff1a<\/h6>\n<div>&gt; test.txt<\/div>\n<h6>\u4e0eUbuntu NTP server\u540c\u6b65\u65f6\u95f4\uff1a<\/h6>\n<div>ntpdate ntp.ubuntu.com<\/div>\n<h6>\u7528netstat\u663e\u793a\u6240\u6709tcp4\u76d1\u542c\u7aef\u53e3\uff1a<\/h6>\n<div>netstat -lnt4 | awk &#8216;{print $4}&#8217; | cut -f2 -d: | grep -o &#8216;[0-9]*&#8217;<\/div>\n<h6>qcow2\u955c\u50cf\u6587\u4ef6\u8f6c\u6362\uff1a<\/h6>\n<div>qemu-img convert -f qcow2 -O raw precise-server-cloudimg-amd64-disk1.img<br \/>\nprecise-server-cloudimg-amd64-disk1.raw<\/div>\n<h6>\u91cd\u590d\u8fd0\u884c\u6587\u4ef6\uff0c\u663e\u793a\u5176\u8f93\u51fa\uff08\u7f3a\u7701\u662f2\u79d2\u4e00\u6b21\uff09\uff1a\uff08\u6682\u672a\u5c1d\u8bd5\u6548\u679c\uff01\uff09<\/h6>\n<div>watch ps -ef<\/div>\n<h6>\u6240\u6709\u7528\u6237\u5217\u8868\uff1a<\/h6>\n<div>getent passwd<\/div>\n<h6>\u4ee5\u8bfb\u5199\u6a21\u5f0f\u6302\u8f7d\u6839\u76ee\u5f55\uff1a<\/h6>\n<div>mount -o remount,rw \/<\/div>\n<h6>\u6302\u8f7d\u4e00\u4e2a\u76ee\u5f55\uff08\u8fd9\u662f\u4e0d\u80fd\u4f7f\u7528\u94fe\u63a5\u7684\u60c5\u51b5\uff09\uff1a<\/h6>\n<pre class=\"lang:default decode:true\">mount --bind \/source \/destination<\/pre>\n<h6>\u52a8\u6001\u66f4\u65b0DNS server\uff1a<\/h6>\n<div>nsupdate &lt; &lt;EOF<br \/>\nupdate add $HOST 86400 A $IP<br \/>\nsend<br \/>\nEOF<\/div>\n<h6>\u9012\u5f52grep\u6240\u6709\u76ee\u5f55\uff1a<\/h6>\n<div>grep -r &#8220;some_text&#8221; \/path\/to\/dir<\/div>\n<h6>\u5217\u51fa\u524d10\u4e2a\u6700\u5927\u7684\u6587\u4ef6\uff1a<\/h6>\n<div>lsof \/ | awk &#8216;{ if($7 &gt; 1048576) print $7\/1048576 &#8220;MB &#8220;$9 }&#8217; | sort -n -u | tail<\/div>\n<h6>\u663e\u793a\u5269\u4f59\u5185\u5b58(MB)\uff1a<\/h6>\n<div>free -m | grep cache | awk &#8216;\/[0-9]\/{ print $4&#8243; MB&#8221; }&#8217;<\/div>\n<h6>\u6253\u5f00Vim\u5e76\u8df3\u5230\u6587\u4ef6\u672b\uff1a<\/h6>\n<div>vim + some_file_name<\/div>\n<div>\n<hr \/>\n<pre class=\"lang:default decode:true\">Git \u514b\u9686\u6307\u5b9a\u5206\u652f(master):\ngit clone git@github.com:name\/app.git -b master\n\nGit \u5207\u6362\u5230\u5176\u5b83\u5206\u652f(develop):\ngit checkout develop\n\nGit \u5220\u9664\u5206\u652f(myfeature):\ngit branch -d myfeature\n\nGit \u5220\u9664\u8fdc\u7a0b\u5206\u652f\ngit push origin :branchName\n\nGit \u5c06\u65b0\u5206\u652f\u63a8\u9001\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\uff1a\ngit push -u origin mynewfeature<\/pre>\n<\/div>\n<div>\n<pre class=\"lang:default decode:true  \">\u6253\u5370\u5386\u53f2\u8bb0\u5f55\u4e2d\u6700\u540e\u4e00\u6b21cat\u547d\u4ee4\uff1a\n!cat:p\n\n\u8fd0\u884c\u5386\u53f2\u8bb0\u5f55\u91cc\u6700\u540e\u4e00\u6b21cat\u547d\u4ee4\uff1a\n!cat\n\n\u627e\u51fa\/home\/user\u4e0b\u6240\u6709\u7a7a\u5b50\u76ee\u5f55:\nfind \/home\/user -maxdepth 1 -type d -empty\n\n\u83b7\u53d6test.txt\u6587\u4ef6\u4e2d\u7b2c50-60\u884c\u5185\u5bb9\uff08\u8fd8\u6709\u4e00\u4e2a\u5c31\u662f\uff0c\u5728Vim\u4e2d\u7f16\u8f91\u6587\u4ef6\u7684\u7b2c50-60\u884c\u5185\u5bb9\u81f3\u67d0\u4e2a\u6587\u4ef6\uff09\uff1a\n&lt; test.txt sed -n '50,60p'\n\n\u8fd0\u884c\u6700\u540e\u4e00\u4e2a\u547d\u4ee4(\u5982\u679c\u6700\u540e\u4e00\u4e2a\u547d\u4ee4\u662fmkdir \/root\/test, \u4e0b\u9762\u5c06\u4f1a\u8fd0\u884c: sudo mkdir \/root\/test)\uff1a\nsudo !!\n\n\u521b\u5efa\u4e34\u65f6RAM\u6587\u4ef6\u7cfb\u7edf \u2013 ramdisk (\u5148\u521b\u5efa\/tmpram\u76ee\u5f55):\nmount -t tmpfs tmpfs \/tmpram -o size=512m\n\nGrep\u67e5\u627e\u6574\u4e2a\u5355\u8bcd\uff08-w \u9009\u9879\uff09:\ngrep -w \"name\" test.txt\n\n\u5728\u9700\u8981\u63d0\u5347\u6743\u9650\u7684\u60c5\u51b5\u4e0b\u5f80\u4e00\u4e2a\u6587\u4ef6\u91cc\u8ffd\u52a0\u6587\u672c\uff1a\necho \"some text\" | sudo tee -a \/path\/file\n\n\u5217\u51fa\u6240\u6709kill signal\u53c2\u6570:\nkill -l<\/pre>\n<\/div>\n<div>\n<hr \/>\n<\/div>\n<h6>\u5728bash\u5386\u53f2\u8bb0\u5f55\u91cc\u7981\u6b62\u8bb0\u5f55\u6700\u540e\u4e00\u6b21\u4f1a\u8bdd\uff1a<\/h6>\n<div>kill -9 $$<\/div>\n<h6>\u626b\u63cf\u7f51\u7edc\u5bfb\u627e\u5f00\u653e\u7684\u7aef\u53e3\uff1a<\/h6>\n<div>nmap -p 8081 172.20.0.0\/16<\/div>\n<h6>\u8bbe\u7f6egit email\uff1a<\/h6>\n<pre class=\"lang:default decode:true\">git config --global user.email \"me@example.com\"<\/pre>\n<h6>To sync with master if you have unpublished commits:<\/h6>\n<pre class=\"lang:default decode:true\">git pull --rebase origin master<\/pre>\n<h6>\u5c06\u6240\u6709\u6587\u4ef6\u540d\u4e2d\u542b\u6709\u201dtxt\u201d\u7684\u6587\u4ef6\u79fb\u5165\/home\/user\u76ee\u5f55\uff1a<\/h6>\n<div>find -iname &#8220;*txt*&#8221; -exec mv -v {} \/home\/user ;<\/div>\n<h6>\u5c06\u6587\u4ef6\u6309\u884c\u5e76\u5217\u663e\u793a\uff1a<\/h6>\n<div>paste test.txt test1.txt<\/div>\n<h6>shell\u91cc\u7684\u8fdb\u5ea6\u6761\uff1a<\/h6>\n<div>pv data.log<\/div>\n<h6>\u4f7f\u7528netcat\u5c06\u6570\u636e\u53d1\u9001\u5230Graphite server\uff1a<\/h6>\n<div>echo &#8220;hosts.sampleHost 10 `date +%s`&#8221; | nc 192.168.200.2 3000<\/div>\n<h6>\u5c06tabs\u8f6c\u6362\u6210\u7a7a\u683c\uff1a<\/h6>\n<div>expand test.txt &gt; test1.txt<\/div>\n<h6>\u4e0d\u5c06\u547d\u4ee4\u8bb0\u5165history\uff1a<\/h6>\n<div>&lt; space &gt;cmd<\/div>\n<h6>\u53bb\u4e4b\u524d\u7684\u5de5\u4f5c\u76ee\u5f55\uff1a<\/h6>\n<div>cd &#8211;<\/div>\n<h6>\u62c6\u5206\u5927\u4f53\u79ef\u7684tar.gz\u6587\u4ef6(\u6bcf\u4e2a100MB)\uff0c\u7136\u540e\u5408\u5e76\u56de\u53bb\uff1a<\/h6>\n<div>split \u2013b 100m \/path\/to\/large\/archive \/path\/to\/output\/files<br \/>\ncat files* &gt; archive<\/div>\n<h6>\u4f7f\u7528curl\u83b7\u53d6HTTP\u72b6\u6001\u7801\uff1a<\/h6>\n<div>curl -sL -w &#8220;%{http_code}\\n&#8221; www.example.com -o \/dev\/null<\/div>\n<h6>\u8bbe\u7f6eroot\u5bc6\u7801\uff0c\u5f3a\u5316MySQL\u5b89\u5168\u5b89\u88c5\uff1a<\/h6>\n<div>\/usr\/bin\/mysql_secure_installation<\/div>\n<h6>\u5f53Ctrl + c\u4e0d\u597d\u4f7f\u65f6\uff1a<\/h6>\n<div>Ctrl + <\/div>\n<h6>\u83b7\u53d6\u6587\u4ef6owner\uff1a<\/h6>\n<div>stat -c %U file.txt<\/div>\n<h6>block\u8bbe\u5907\u5217\u8868\uff1a<\/h6>\n<div>lsblk -f<\/div>\n<h6>\u627e\u51fa\u6587\u4ef6\u540d\u7ed3\u5c3e\u6709\u7a7a\u683c\u7684\u6587\u4ef6\uff1a<\/h6>\n<div>find . -type f -exec egrep -l &#8221; +$&#8221; {} ;<\/div>\n<h6>\u627e\u51fa\u6587\u4ef6\u540d\u6709tab\u7f29\u8fdb\u7b26\u7684\u6587\u4ef6\uff1a<\/h6>\n<div>find . -type f -exec egrep -l $&#8217;t&#8217; {} ;<\/div>\n<h6>\u7528\u201d=\u201d\u6253\u5370\u51fa\u6a2a\u7ebf\uff1a<\/h6>\n<div>printf &#8216;%100sn&#8217; | tr &#8216; &#8216; =<\/div>\n<h6>\u53c2\u8003\u5730\u5740\uff1a<\/h6>\n<div>\n<ul>\n<li><a href=\"http:\/\/www.techbar.me\/linux-shell-tips\/\" target=\"_blank\">http:\/\/www.techbar.me\/linux-shell-tips\/<\/a> #\u82f1\u6587\u539f\u6587<\/li>\n<li><a href=\"http:\/\/www.vaikan.com\/linux-shell-tips-and-tricks\/\" target=\"_blank\">http:\/\/www.vaikan.com\/linux-shell-tips-and-tricks\/<\/a> #\u8bd1\u6587<\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; :%s\/h [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,11],"tags":[30,306,46,43],"class_list":["post-914","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-linux","tag-linux","tag-pgrep","tag-skills","tag-vim"],"views":3435,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/914","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=914"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/914\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=914"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=914"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=914"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}