{"id":214,"date":"2014-06-27T12:58:13","date_gmt":"2014-06-27T12:58:13","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=214"},"modified":"2014-06-27T12:58:13","modified_gmt":"2014-06-27T12:58:13","slug":"%e5%ae%9e%e7%94%a8%e7%9a%84linux-shell%e7%94%a8%e6%b3%95%e5%92%8c%e6%8a%80%e5%b7%a7","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/214.html","title":{"rendered":"\u5b9e\u7528\u7684Linux Shell\u7528\u6cd5\u548c\u6280\u5de7"},"content":{"rendered":"<h6 style=\"color: #333333;\">1\u3001\u4e3a man \u624b\u518c\u521b\u5efa pdf \u7248\u672c<\/h6>\n<pre style=\"color: #333333;\" class=\"\">man -t manpage | ps2pdf - filename.pdf<\/pre>\n<p style=\"color: #333333;\">\u6bd4\u5982\u5236\u4f5c ls \u547d\u4ee4\u7684 man \u624b\u518c pdf \u6587\u4ef6<\/p>\n<pre style=\"color: #333333;\" class=\"\">man -t ls | ps2pdf - ls.pdf<\/pre>\n<p style=\"color: #333333;\">\u9664\u4e86\u5236\u4f5cpdf\uff0c\u8fd8\u6709\u4e00\u79cd\u5236\u4f5ctxt\u7248\u672c\u7684manual\u7684\u65b9\u6cd5\uff1a<\/p>\n<p style=\"color: #333333;\"><span style=\"color: #ff0000;\">man -t find | ps2pdf -&gt; find_manual.pdf<\/span><br \/>\n<span style=\"color: #ff0000;\">man find | col -b &gt; find_manual.txt<\/span><\/p>\n<h6 style=\"color: #333333;\">2\u3001\u4e3a\u547d\u4ee4\u7ed1\u5b9a\u5feb\u6377\u952e<\/h6>\n<pre style=\"color: #333333;\">bind -x '\"C-l\":ls -l'<\/pre>\n<p style=\"color: #333333;\">\u8fd9\u6837\u76f4\u63a5\u6309 CTRL+L \u5c31\u5217\u51fa\u76ee\u5f55\u4e86\uff0c\u4f60\u53ef\u4ee5\u628a\u8fd9\u6761\u547d\u4ee4\u52a0\u5165\u5230 ~\/.bashrc \u4e2d\uff0c\u8fd9\u6837\u4e0d\u5fc5\u6bcf\u6b21\u91cd\u590d\u8bbe\u5b9a\u3002<\/p>\n<h6 style=\"color: #333333;\">3\u3001\u4e00\u952e\u542f\u52a8\u8fdc\u7a0b\u4e3b\u673a\u4e0a\u7684 tmux<\/h6>\n<p style=\"color: #333333;\">tmux \u662f\u4e00\u4e2a GNU Screen \u7684\u66ff\u4ee3\u54c1\uff0c\u4e00\u4e2a\u53ef\u4ee5\u5728\u7ec8\u7aef\u91cc\u5f00\u542f\u591a\u7a97\u53e3\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u8bf4\u662f\u5f88\u597d\u7528\u7684\u8fdc\u7a0b\u670d\u52a1\u7ef4\u62a4\u5de5\u5177\uff0c\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5c31\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u4e00\u6761\u547d\u4ee4\u76f4\u63a5\u5f00\u542f\u8fdc\u7a0b\u670d\u52a1\u5668\u4e0a\u7684 tmux \u3002<\/p>\n<pre style=\"color: #333333;\">ssh -t username@server.com tmux<\/pre>\n<p style=\"color: #333333;\">\u5982\u679c\u4f60\u4e4b\u524d\u5728\u8fdc\u7a0b\u4e3b\u673a\u4e0a\u5df2\u7ecf\u5f00\u542f\u4e86 tmux \u7684\u8bdd\uff0c\u7528\u4ee5\u4e0b\u547d\u4ee4\u3002<\/p>\n<pre style=\"color: #333333;\">ssh -t username@server.com tmux att<\/pre>\n<p style=\"color: #333333;\">\u9664\u6b64\u4e4b\u5916\uff0c\u4f60\u53ef\u4ee5\u7ed3\u5408\u7b2c\u4e8c\u6761\u547d\u4ee4\u6765\u7ed1\u5b9a\u5feb\u6377\u952e\uff0c\u8fd9\u6837\u6211\u4eec\u53ea\u9700\u4e00\u952e\u5c31\u53ef\u4ee5\u5feb\u901f\u767b\u5f55\u5e76\u5f00\u542f tmux \u4e86\u3002<\/p>\n<h6 style=\"color: #333333;\">4\u3001\u7528 file \u547d\u4ee4\u67e5\u770b\u8bbe\u5907\u4fe1\u606f{<span style=\"color: #ff0000;\">\u6bd4\u8f83\u8be6\u7ec6<\/span>}<\/h6>\n<pre style=\"color: #333333;\">file -s \/dev\/sd*<\/pre>\n<h6 style=\"color: #333333;\">5\u3001\u7528 md5 \u503c\u5bf9\u6bd4\u4e24\u4e2a\u6587\u4ef6\u662f\u5426\u4e00\u81f4<\/h6>\n<pre style=\"color: #333333;\" class=\"\">cmp file1 file2<\/pre>\n<p style=\"color: #333333;\">\u4e00\u81f4\u7684\u8bdd\u4e0d\u4f1a\u51fa\u73b0\u63d0\u793a\uff0c\u4e0d\u4e00\u81f4\u7684\u8bdd\u5c31\u4f1a\u6709\u63d0\u793a\u4fe1\u606f<\/p>\n<h6 style=\"color: #333333;\">6\u3001\u4e00\u6761\u547d\u4ee4\u628a CD\/DVD \u4f5c\u6210 ISO \u6587\u4ef6<\/h6>\n<pre style=\"color: #333333;\" class=\"\">dd if=\/dev\/cdrom of=file.iso<\/pre>\n<h6 style=\"color: #333333;\">7\u3001\u901a\u8fc7 ssh \u590d\u5236\u6574\u4e2a\u786c\u76d8\u5230\u8fdc\u7a0b\u76ee\u5f55(\u5e26\u538b\u7f29)<\/h6>\n<pre style=\"color: #333333;\">dd if=\/dev\/sda | gzip -c | ssh user@ip 'dd of=\/mnt\/backups\/sda.dd'<\/pre>\n<h6 style=\"color: #333333;\">8\u3001\u5728\u4e0d\u6d6a\u8d39\u78c1\u76d8\u7684\u60c5\u51b5\u4e0b\u6d4b\u8bd5\u7f51\u7edc\u901f\u5ea6<\/h6>\n<pre class=\"lang:default decode:true\">dd if=\/dev\/zero bs=4096 count=1048576 | ssh user@ip 'cat &gt;\/dev\/null'<\/pre>\n<p style=\"color: #333333;\">\u4ee5\u4e0a\u547d\u4ee4\u901a\u8fc7 ssh \u53d1\u9001 4 GB \u6570\u636e\u5230\u8fdc\u7a0b\u4e3b\u673a\uff0c\u4f46\u4e0d\u4f1a\u5360\u7528\u4efb\u4f55\u78c1\u76d8\u7a7a\u95f4\u3002<\/p>\n<p style=\"color: #333333;\"><span style=\"color: #ff0000;\"><strong>\u539f\u6587\u94fe\u63a5<\/strong><\/span>\uff1a<a style=\"color: #004276;\" href=\"http:\/\/wowubuntu.com\/shell-cmd.html\" target=\"_blank\">http:\/\/wowubuntu.com\/shell-cmd.html<\/a><\/p>\n<hr \/>\n<h4 class=\"entry-title\" style=\"color: #000000;\">Linux shell\u7528\u6cd5\u548c\u6280\u5de7<\/h4>\n<h6 style=\"color: #333333;\">\u68c0\u67e5\u8fdc\u7a0b\u7aef\u53e3\u662f\u5426\u5bf9bash\u5f00\u653e\uff1a<\/h6>\n<pre class=\"lang:default decode:true\">echo &gt;\/dev\/tcp\/8.8.8.8\/53 &amp;&amp; echo \"open\"<\/pre>\n<h6 style=\"color: #333333;\">\u8ba9\u8fdb\u7a0b\u8f6c\u5165\u540e\u53f0\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">Ctrl + z<\/pre>\n<h6 style=\"color: #333333;\">\u5c06\u8fdb\u7a0b\u8f6c\u5230\u524d\u53f0\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">fg<\/pre>\n<h6 style=\"color: #333333;\">\u4ea7\u751f\u968f\u673a\u7684\u5341\u516d\u8fdb\u5236\u6570\uff0c\u5176\u4e2dn\u662f\u5b57\u7b26\u6570\uff1a<\/h6>\n<pre style=\"color: #666666;\">openssl rand -hex n<\/pre>\n<h6 style=\"color: #333333;\"><strong><span style=\"color: #ff0000;\">\u5728\u5f53\u524dshell\u91cc\u6267\u884c\u4e00\u4e2a\u6587\u4ef6\u91cc\u7684\u547d\u4ee4<\/span><\/strong>\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">source \/home\/user\/file.name<\/pre>\n<h6 style=\"color: #333333;\">\u622a\u53d6\u524d5\u4e2a\u5b57\u7b26\uff1a<\/h6>\n<pre style=\"color: #666666;\">${variable:0:5}<\/pre>\n<h6 style=\"color: #333333;\">SSH debug \u6a21\u5f0f\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">ssh -vvv user@ip_address<\/pre>\n<h6 style=\"color: #333333;\">SSH with pem key\uff08-i\u9009\u9879\uff09\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">ssh user@ip_address -i key.pem<\/pre>\n<h6 style=\"color: #333333;\">\u7528wget\u6293\u53d6\u5b8c\u6574\u7684\u7f51\u7ad9\u76ee\u5f55\u7ed3\u6784\uff0c\u5b58\u653e\u5230\u672c\u5730\u76ee\u5f55\u4e2d\uff1a<\/h6>\n<pre style=\"color: #666666;\">wget -r --no-parent --reject \"index.html*\" http:\/\/hostname\/ -P \/home\/user\/dirs<\/pre>\n<h6 style=\"color: #333333;\"><strong><span style=\"color: #ff0000;\">\u4e00\u6b21\u521b\u5efa\u591a\u4e2a\u76ee\u5f55<\/span><\/strong>\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">mkdir -p \/home\/user\/{test,test1,test2}<\/pre>\n<h6 style=\"color: #333333;\">\u5217\u51fa\u5305\u62ec\u5b50\u8fdb\u7a0b\u7684\u8fdb\u7a0b\u6811\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">ps axwef<\/pre>\n<h6 style=\"color: #333333;\">\u521b\u5efa war \u6587\u4ef6:<\/h6>\n<pre style=\"color: #666666;\" class=\"\">jar -cvf name.war file<\/pre>\n<h6 style=\"color: #333333;\">\u6d4b\u8bd5\u786c\u76d8\u5199\u5165\u901f\u5ea6\uff1a<\/h6>\n<pre style=\"color: #666666;\">dd if=\/dev\/zero of=\/tmp\/output.img bs=8k count=256k; rm -rf \/tmp\/output.img<\/pre>\n<h6 style=\"color: #333333;\">\u6d4b\u8bd5\u786c\u76d8\u8bfb\u53d6\u901f\u5ea6\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">hdparm -Tt \/dev\/sda<\/pre>\n<h6 style=\"color: #333333;\"><strong><span style=\"color: #ff0000;\">\u83b7\u53d6\u6587\u672c\u7684md5 hash<\/span><\/strong>\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">echo -n \"text\" | md5sum<\/pre>\n<h6 style=\"color: #333333;\">\u68c0\u67e5xml\u683c\u5f0f\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">xmllint --noout file.xml<\/pre>\n<h6 style=\"color: #333333;\">\u5c06tar.gz\u63d0\u53d6\u5230\u65b0\u76ee\u5f55\u91cc\uff08-C\u9009\u9879\uff09\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">tar zxvf package.tar.gz -C new_dir<\/pre>\n<h6 style=\"color: #333333;\">\u4f7f\u7528curl\u83b7\u53d6HTTP\u5934\u4fe1\u606f\uff08-I\u9009\u9879\uff09\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">curl -I http:\/\/www.example.com<\/pre>\n<h6 style=\"color: #333333;\">\u4fee\u6539\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u65f6\u95f4\u6233(YYMMDDhhmm):<\/h6>\n<pre style=\"color: #666666;\" class=\"\">touch -t 0712250000 file<\/pre>\n<h6 style=\"color: #333333;\">\u7528wget\u547d\u4ee4\u6267\u884cftp\u4e0b\u8f7d\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">wget -m ftp:\/\/username:password@hostname<\/pre>\n<h6 style=\"color: #333333;\">\u751f\u6210\u968f\u673a\u5bc6\u7801(\u4f8b\u5b50\u91cc\u662f16\u4e2a\u5b57\u7b26\u957f):<\/h6>\n<pre class=\"lang:default decode:true\">LANG=c &lt; \/dev\/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-16};echo;<\/pre>\n<h6 style=\"color: #333333;\">\u5feb\u901f\u5907\u4efd\u4e00\u4e2a\u6587\u4ef6\uff08<span style=\"color: #ff0000;\"><strong>\u5b9e\u7528<\/strong><\/span>\uff09\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">cp some_file_name{,.bkp}<\/pre>\n<h6 style=\"color: #333333;\">\u8bbf\u95eeWindows\u5171\u4eab\u76ee\u5f55\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">smbclient -U \"DOMAINuser\" \/\/dc.domain.com\/share\/test\/dir<\/pre>\n<h6 style=\"color: #333333;\">\u6267\u884c\u5386\u53f2\u8bb0\u5f55\u91cc\u7684\u547d\u4ee4(\u8fd9\u91cc\u662f\u7b2c100\u884c):<\/h6>\n<pre style=\"color: #666666;\" class=\"\">!100<\/pre>\n<h6 style=\"color: #333333;\">\u89e3\u538b\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">unzip package_name.zip -d dir_name<\/pre>\n<h6 style=\"color: #333333;\">\u8f93\u5165\u591a\u884c\u6587\u5b57(CTRL + d \u9000\u51fa):<\/h6>\n<pre class=\"lang:default decode:true\">cat &gt; test.txt<\/pre>\n<h6 style=\"color: #333333;\">\u521b\u5efa\u7a7a\u6587\u4ef6\u6216\u6e05\u7a7a\u4e00\u4e2a\u73b0\u6709\u6587\u4ef6\uff1a<\/h6>\n<pre class=\"lang:default decode:true\">&gt;test.txt<\/pre>\n<h6 style=\"color: #333333;\">\u4e0eUbuntu NTP server\u540c\u6b65\u65f6\u95f4\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">ntpdate ntp.ubuntu.com<\/pre>\n<h6 style=\"color: #333333;\">\u7528netstat\u663e\u793a\u6240\u6709tcp4\u76d1\u542c\u7aef\u53e3\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">netstat -lnt4 | awk '{print $4}' | cut -f2 -d: | grep -o '[0-9]*'<\/pre>\n<h6 style=\"color: #333333;\">qcow2\u955c\u50cf\u6587\u4ef6\u8f6c\u6362\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">qemu-img convert -f qcow2 -O raw precise-server-cloudimg-amd64-disk1.img\n                                 precise-server-cloudimg-amd64-disk1.raw<\/pre>\n<h6 style=\"color: #333333;\">\u5468\u671f\u6027\u7684\u8fd0\u884c\u7a0b\u5e8f\uff0c\u5e76\u663e\u793a\u5176\u8f93\u51fa\uff08\u7f3a\u7701\u662f2\u79d2\u4e00\u6b21\uff09\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">watch ps -ef<\/pre>\n<h6 style=\"color: #333333;\">\u6240\u6709\u7528\u6237\u5217\u8868\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">getent passwd<\/pre>\n<h6 style=\"color: #333333;\">Mount root in read\/write mode:<\/h6>\n<pre style=\"color: #666666;\" class=\"\">mount -o remount,rw \/<\/pre>\n<h6 style=\"color: #333333;\">\u6302\u8f7d\u4e00\u4e2a\u76ee\u5f55\uff08\u8fd9\u662f\u4e0d\u80fd\u4f7f\u7528\u94fe\u63a5\u7684\u60c5\u51b5\uff09:<\/h6>\n<pre style=\"color: #666666;\" class=\"\">mount --bind \/source \/destination<\/pre>\n<h6 style=\"color: #333333;\">\u52a8\u6001\u66f4\u65b0DNS server:<\/h6>\n<pre class=\"lang:default decode:true\">nsupdate &lt;&lt;EOF\nupdate add $HOST 86400 A $IP\nsend\nEOF<\/pre>\n<h6 style=\"color: #333333;\">\u9012\u5f52grep\u6240\u6709\u76ee\u5f55\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">grep -r \"some_text\" \/path\/to\/dir<\/pre>\n<h6>\u5217\u51fa\u524d10\u4e2a\u6700\u5927\u7684\u6587\u4ef6\uff1a<\/h6>\n<pre class=\"lang:default decode:true\">lsof \/ | awk '{ if($7 &gt; 1048576) print $7\/1048576 \"MB \"$9 }' | sort -n -u | tail<\/pre>\n<h6 style=\"color: #333333;\">\u663e\u793a\u5269\u4f59\u5185\u5b58(MB):<\/h6>\n<pre style=\"color: #666666;\" class=\"\">free -m | grep cache | awk '\/[0-9]\/{ print $4\" MB\" }'<\/pre>\n<h6 style=\"color: #333333;\">\u6253\u5f00Vim\u5e76\u8df3\u5230\u6587\u4ef6\u672b\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">vim + some_file_name<\/pre>\n<h6 style=\"color: #333333;\">Git \u514b\u9686\u6307\u5b9a\u5206\u652f(master):<\/h6>\n<pre style=\"color: #666666;\" class=\"\">git clone git@github.com:name\/app.git -b master<\/pre>\n<h6 style=\"color: #333333;\">Git \u5207\u6362\u5230\u5176\u5b83\u5206\u652f(develop):<\/h6>\n<pre style=\"color: #666666;\" class=\"\">git checkout develop<\/pre>\n<h6 style=\"color: #333333;\">Git \u5220\u9664\u5206\u652f(myfeature):<\/h6>\n<pre style=\"color: #666666;\" class=\"\">git branch -d myfeature<\/pre>\n<h6 style=\"color: #333333;\">Git \u5220\u9664\u8fdc\u7a0b\u5206\u652f<\/h6>\n<pre style=\"color: #666666;\" class=\"\">git push origin :branchName<\/pre>\n<h6 style=\"color: #333333;\">Git \u5c06\u65b0\u5206\u652f\u63a8\u9001\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">git push -u origin mynewfeature<\/pre>\n<h6 style=\"color: #333333;\">\u6253\u5370\u5386\u53f2\u8bb0\u5f55\u4e2d\u6700\u540e\u4e00\u6b21cat\u547d\u4ee4\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">!cat:p<\/pre>\n<h6 style=\"color: #333333;\">\u8fd0\u884c\u5386\u53f2\u8bb0\u5f55\u91cc\u6700\u540e\u4e00\u6b21cat\u547d\u4ee4\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">!cat<\/pre>\n<h6 style=\"color: #333333;\">\u627e\u51fa\/home\/user\u4e0b\u6240\u6709\u7a7a\u5b50\u76ee\u5f55:<\/h6>\n<pre style=\"color: #666666;\" class=\"\">find \/home\/user -maxdepth 1 -type d -empty<\/pre>\n<h6 style=\"color: #333333;\">\u83b7\u53d6test.txt\u6587\u4ef6\u4e2d\u7b2c50-60\u884c\u5185\u5bb9\uff1a<\/h6>\n<pre class=\"lang:default decode:true\">&lt; test.txt sed -n '50,60p'<\/pre>\n<h6 style=\"color: #333333;\">\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<\/h6>\n<pre style=\"color: #666666;\" class=\"\">sudo !!<\/pre>\n<h6 style=\"color: #333333;\">\u521b\u5efa\u4e34\u65f6RAM\u6587\u4ef6\u7cfb\u7edf \u2013 ramdisk (\u5148\u521b\u5efa\/tmpram\u76ee\u5f55):<\/h6>\n<pre style=\"color: #666666;\" class=\"\">mount -t tmpfs tmpfs \/tmpram -o size=512m<\/pre>\n<h6 style=\"color: #333333;\">Grep whole words:<\/h6>\n<pre style=\"color: #666666;\" class=\"\">grep -w \"name\" test.txt<\/pre>\n<h6 style=\"color: #333333;\">\u5728\u9700\u8981\u63d0\u5347\u6743\u9650\u7684\u60c5\u51b5\u4e0b\u5f80\u4e00\u4e2a\u6587\u4ef6\u91cc\u8ffd\u52a0\u6587\u672c\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">echo \"some text\" | sudo tee -a \/path\/file<\/pre>\n<h6 style=\"color: #333333;\">\u5217\u51fa\u6240\u6709kill signal\u53c2\u6570:<\/h6>\n<pre style=\"color: #666666;\" class=\"\">kill -l<\/pre>\n<h6 style=\"color: #333333;\">\u5728bash\u5386\u53f2\u8bb0\u5f55\u91cc\u7981\u6b62\u8bb0\u5f55\u6700\u540e\u4e00\u6b21\u4f1a\u8bdd\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">kill -9 $$<\/pre>\n<h6 style=\"color: #333333;\">\u626b\u63cf\u7f51\u7edc\u5bfb\u627e\u5f00\u653e\u7684\u7aef\u53e3\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">nmap -p 8081 172.20.0.0\/16<\/pre>\n<h6 style=\"color: #333333;\">\u8bbe\u7f6egit email:<\/h6>\n<pre style=\"color: #666666;\" class=\"\">git config --global user.email \"me@example.com\"<\/pre>\n<h6 style=\"color: #333333;\">To sync with master if you have unpublished commits:<\/h6>\n<pre style=\"color: #666666;\" class=\"\">git pull --rebase origin master<\/pre>\n<h6 style=\"color: #333333;\">\u5c06\u6240\u6709\u6587\u4ef6\u540d\u4e2d\u542b\u6709\u201dtxt\u201d\u7684\u6587\u4ef6\u79fb\u5165\/home\/user\u76ee\u5f55:<\/h6>\n<pre style=\"color: #666666;\" class=\"\">find -iname \"*txt*\" -exec mv -v {} \/home\/user ;<\/pre>\n<h6 style=\"color: #333333;\">\u5c06\u6587\u4ef6\u6309\u884c\u5e76\u5217\u663e\u793a\uff1a<\/h6>\n<pre style=\"color: #666666;\" class=\"\">paste test.txt test1.txt<\/pre>\n<h6 style=\"color: #333333;\">shell\u91cc\u7684\u8fdb\u5ea6\u6761:<\/h6>\n<pre style=\"color: #666666;\" class=\"\">pv data.log<\/pre>\n<h6 style=\"color: #333333;\">\u4f7f\u7528netcat\u5c06\u6570\u636e\u53d1\u9001\u5230Graphite server:<\/h6>\n<pre style=\"color: #666666;\" class=\"\">echo \"hosts.sampleHost 10 `date +%s`\" | nc 192.168.200.2 3000<\/pre>\n<h6 style=\"color: #333333;\">\u5c06tabs\u8f6c\u6362\u6210\u7a7a\u683c\uff1a<\/h6>\n<pre class=\"lang:default decode:true\">expand test.txt &gt;test1.txt<\/pre>\n<h6 style=\"color: #333333;\">Skip bash history\uff08\u4e0d\u5728history\u547d\u4ee4\u4e2d\u8bb0\u5f55\uff09:<\/h6>\n<pre class=\"lang:default decode:true\">&lt;space&gt;cmd<\/pre>\n<h6 style=\"color: #333333;\">\u53bb\u4e4b\u524d\u7684\u5de5\u4f5c\u76ee\u5f55\uff1a<\/h6>\n<pre style=\"color: #666666;\">cd -<\/pre>\n<h6 style=\"color: #333333;\">\u62c6\u5206\u5927\u4f53\u79ef\u7684tar.gz\u6587\u4ef6(\u6bcf\u4e2a100MB)\uff0c\u7136\u540e\u5408\u5e76\u56de\u53bb\uff1a<\/h6>\n<pre class=\"lang:default decode:true\">split \u2013b 100m \/path\/to\/large\/archive \/path\/to\/output\/files\ncat files* &gt; archive<\/pre>\n<h6 style=\"color: #333333;\">\u4f7f\u7528curl\u83b7\u53d6HTTP\u72b6\u6001\u7801<\/h6>\n<pre style=\"color: #666666;\" class=\"\">curl -sL -w \"%{http_code}\\n\" www.example.com -o \/dev\/null<\/pre>\n<h6 style=\"color: #333333;\">\u8bbe\u7f6eroot\u5bc6\u7801\uff0c\u5f3a\u5316MySQL\u5b89\u5168<\/h6>\n<pre style=\"color: #666666;\">\/usr\/bin\/mysql_secure_installation<\/pre>\n<h6 style=\"color: #333333;\">\u5f53Ctrl + c\u4e0d\u597d\u4f7f\u65f6<\/h6>\n<pre style=\"color: #666666;\" class=\"\">Ctrl +<\/pre>\n<h6 style=\"color: #333333;\">\u83b7\u53d6\u6587\u4ef6owner<\/h6>\n<pre style=\"color: #666666;\" class=\"\">stat -c %U file.txt<\/pre>\n<h6 style=\"color: #333333;\">block\u8bbe\u5907\u5217\u8868<\/h6>\n<pre style=\"color: #666666;\">lsblk -f<\/pre>\n<h6 style=\"color: #333333;\">\u627e\u51fa\u6587\u4ef6\u540d\u7ed3\u5c3e\u6709\u7a7a\u683c\u7684\u6587\u4ef6<\/h6>\n<pre style=\"color: #666666;\" class=\"\">find . -type f -exec egrep -l \" +$\" {} ;<\/pre>\n<h6 style=\"color: #333333;\">\u627e\u51fa\u6587\u4ef6\u540d\u6709tab\u7f29\u8fdb\u7b26\u7684\u6587\u4ef6<\/h6>\n<pre style=\"color: #666666;\" class=\"\">find . -type f -exec egrep -l $'t' {} ;<\/pre>\n<h6 style=\"color: #333333;\">\u7528\u201c=\u201d\u6253\u5370\u51fa\u6a2a\u7ebf\uff1a<\/h6>\n<pre style=\"color: #666666;\">printf '%100sn' | tr ' ' =<\/pre>\n<div class=\"post_source\" style=\"color: #333333;\">[<span style=\"color: #ff0000;\"><strong>\u82f1\u6587\u539f\u6587<\/strong><\/span>\uff1a<a style=\"color: #018d8e;\" href=\"http:\/\/www.techbar.me\/linux-shell-tips\/\" target=\"_blank\" rel=\"nofollow\">Linux shell tips and tricks<\/a>\u00a0]<\/div>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001\u4e3a man \u624b\u518c\u521b\u5efa pdf \u7248\u672c man -t manpage | ps2pdf &#8211; filename. [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[46,19],"class_list":["post-214","post","type-post","status-publish","format-standard","hentry","category-linux","tag-skills","tag-tips"],"views":5049,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/214","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=214"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/214\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=214"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=214"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=214"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}