{"id":1013,"date":"2022-11-08T11:37:58","date_gmt":"2022-11-08T03:37:58","guid":{"rendered":"https:\/\/blog.frost-s.com\/?p=1013"},"modified":"2022-11-10T13:46:30","modified_gmt":"2022-11-10T05:46:30","slug":"linux-%e5%91%bd%e4%bb%a4%e8%a1%8c%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/blog.frost-s.com\/index.php\/2022\/11\/08\/linux-%e5%91%bd%e4%bb%a4%e8%a1%8c%e8%af%a6%e8%a7%a3\/","title":{"rendered":"Linux \u547d\u4ee4\u884c\u8be6\u89e3"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\"><a href=\"https:\/\/blog.csdn.net\/liuwei0376\/article\/details\/88245472\">Linux\u5e38\u7528\u547d\u4ee4\u5927\u5168\uff08\u975e\u5e38\u5168\u9762\uff09<\/a><\/h1>\n\n\n\n<p>2022-08-15 23:54:00<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>Linux\u548cwindows\u76f8\u6bd4\uff0c\u5f88\u591a\u7ba1\u63a7\u90fd\u9700\u8981\u7528\u547d\u4ee4\u6765\u64cd\u4f5c\u3002windows\u4ee5\u76f4\u89c2\u7684\u53ef\u89c6\u5316\u7684\u65b9\u5f0f\u64cd\u4f5c\uff0c\u7279\u522b\u9002\u5408\u5728\u684c\u9762\u7aefPC\u4e0a\u64cd\u4f5c\u6267\u884c\u76f8\u5e94\u7684\u8f6f\u4ef6\u3002<\/p>\n\n\n\n<p>\u800cLinux<a href=\"https:\/\/so.csdn.net\/so\/search?q=%E5%91%BD%E4%BB%A4%E8%A1%8C&amp;spm=1001.2101.3001.7020\">\u547d\u4ee4\u884c<\/a>\u65b9\u5f0f\u7684\u64cd\u4f5c\uff0c\u7279\u522b\u662f\u5728\u670d\u52a1\u5668\u7aef\u7f16\u7a0b\u3001\u7ba1\u7406\u3001\u8fd0\u7ef4\u65b9\u9762\uff0c\u66f4\u52a0\u7b80\u5355\u3001\u77ed\u5c0f\u3001\u7cbe\u608d\u3002\u77ed\u77ed\u4e00\u884c\u7ec4\u5408\u547d\u4ee4\uff0c\u5373\u53ef\u5b8c\u6210\u5728windows\u9700\u8981\u5404\u79cd\u52a0\u5de5\u3001\u6574\u5408\u7684\u590d\u6742\u9ad8\u6548\u7684\u529f\u80fd\u64cd\u4f5c\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u4e00\u3001\u8fdb\u7a0b\u7ba1\u7406<\/strong><\/h1>\n\n\n\n<p>w \u663e\u793a\u5f53\u524d\u5728\u7ebf\u7528\u6237\u60c5\u51b5<\/p>\n\n\n\n<p>my_adm pts\/0 111.111.111.111 \u4e0915 24:58 2:51 0.02s sshd: my_admin [priv]<\/p>\n\n\n\n<p>root pts\/3 111.111.111.112 13:15 3:47m 0.35s 0.35s -bash<\/p>\n\n\n\n<p>my_adm pts\/5 111.111.111.113 15:14 2.00s 0.54s 0.02s sshd: my_admin [priv]<\/p>\n\n\n\n<p>pkill -kill -t pts\/?? \u6740\u6389\u6307\u5b9a\u540d\u5b57\u7684\u8fdb\u7a0b\uff0c\u5982\u4e0a\u8ff0\u7684pts\/5<\/p>\n\n\n\n<p>\u4f20\u9001\u95e8\uff1a<a href=\"https:\/\/blog.csdn.net\/smarxx\/article\/details\/6664219\">Linux\u4e2dKill\u8fdb\u7a0b\u7684N\u79cd\u65b9\u6cd5<\/a><\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u4e8c\u3001\u7cfb\u7edf\u4fe1\u606f<\/strong><\/h1>\n\n\n\n<p>arch \u663e\u793a\u673a\u5668\u7684\u5904\u7406\u5668\u67b6\u6784(1)<\/p>\n\n\n\n<p>uname -m \u663e\u793a\u673a\u5668\u7684\u5904\u7406\u5668\u67b6\u6784(2)<\/p>\n\n\n\n<p>uname -r \u663e\u793a\u6b63\u5728\u4f7f\u7528\u7684\u5185\u6838\u7248\u672c<\/p>\n\n\n\n<p>dmidecode -q \u663e\u793a\u786c\u4ef6\u7cfb\u7edf\u90e8\u4ef6 - (SMBIOS \/ DMI)<\/p>\n\n\n\n<p>hdparm -i \/dev\/hda \u7f57\u5217\u4e00\u4e2a\u78c1\u76d8\u7684\u67b6\u6784\u7279\u6027<\/p>\n\n\n\n<p>hdparm -tT \/dev\/sda \u5728\u78c1\u76d8\u4e0a\u6267\u884c\u6d4b\u8bd5\u6027\u8bfb\u53d6\u64cd\u4f5c<\/p>\n\n\n\n<p>cat \/proc\/cpuinfo \u663e\u793aCPU info\u7684\u4fe1\u606f<\/p>\n\n\n\n<p>cat \/proc\/interrupts \u663e\u793a\u4e2d\u65ad<\/p>\n\n\n\n<p>cat \/proc\/meminfo \u6821\u9a8c\u5185\u5b58\u4f7f\u7528<\/p>\n\n\n\n<p>cat \/proc\/swaps \u663e\u793a\u54ea\u4e9bswap\u88ab\u4f7f\u7528<\/p>\n\n\n\n<p>cat \/proc\/version \u663e\u793a\u5185\u6838\u7684\u7248\u672c<\/p>\n\n\n\n<p>cat \/proc\/net\/dev \u663e\u793a\u7f51\u7edc\u9002\u914d\u5668\u53ca\u7edf\u8ba1<\/p>\n\n\n\n<p>cat \/proc\/mounts \u663e\u793a\u5df2\u52a0\u8f7d\u7684\u6587\u4ef6\u7cfb\u7edf<\/p>\n\n\n\n<p>lspci -tv \u7f57\u5217 PCI \u8bbe\u5907<\/p>\n\n\n\n<p>lsusb -tv \u663e\u793a USB \u8bbe\u5907<\/p>\n\n\n\n<p>date \u663e\u793a\u7cfb\u7edf\u65e5\u671f<\/p>\n\n\n\n<p>ctime=<code>date +%Y-%m-%dT%k:%M:%S<\/code> #\u683c\u5f0f\u5316\u65f6\u95f4\uff0c\u59822018-01-13T11:09:19\uff0c \u6ce8\u610f%k \u4e0e %H\u7684\u533a\u522b\uff0c\u524d\u8005\u8fd4\u56de9\uff0c\u540e\u8005\u8fd4\u56de09.<\/p>\n\n\n\n<p>YESTERDAY=<code>date +%Y-%m-%d -d \"-1 days\"<\/code> \u83b7\u53d6\u6628\u65e5\u65e5\u671f<\/p>\n\n\n\n<p>cal 2007 \u663e\u793a2007\u5e74\u7684\u65e5\u5386\u8868<\/p>\n\n\n\n<p>date 041217002007.00 \u8bbe\u7f6e\u65e5\u671f\u548c\u65f6\u95f4 - \u6708\u65e5\u65f6\u5206\u5e74.\u79d2<\/p>\n\n\n\n<p>clock -w \u5c06\u65f6\u95f4\u4fee\u6539\u4fdd\u5b58\u5230 BIOS<\/p>\n\n\n\n<p>\u67e5\u8be2\u7f51\u5173\u5730\u5740(\u5982\u5c06centos\u670d\u52a1\u5668\u7f51\u7edc\u83b7\u53d6\u7c7b\u578b\u7531dhcp\u5207\u6362\u4e3astatic\u65f6,\u9700\u8981\u83b7\u53d6\u5230ip\u53ca\u7f51\u5173\u4fe1\u606f\u8fdb\u884c\u56fa\u5316\u914d\u7f6e\u65f6\u4f1a\u7528\u5230,\u5982\u672c\u5730ip\u4e3a10.34.0.123,\u5219\u901a\u8fc7\u5982\u4e0b\u547d\u4ee4\u67e5\u8be2\u5230\u7f51\u5173\u4e3a\u7b2c\u4e00\u4e2a3.254):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@file-server ~]# netstat -rn<br>Kernel IP routing table<br>Destination &nbsp; &nbsp; Gateway &nbsp; &nbsp; &nbsp; &nbsp; Genmask &nbsp; &nbsp; &nbsp; &nbsp; Flags &nbsp; MSS Window  irtt Iface<br>0.0.0.0 &nbsp; &nbsp; &nbsp; &nbsp; 10.34.3.254 &nbsp; &nbsp; 0.0.0.0 &nbsp; &nbsp; &nbsp; &nbsp; UG &nbsp; &nbsp; &nbsp;  0 0 &nbsp; &nbsp; &nbsp; &nbsp;  0 enp3g0<br>10.34.0.0 &nbsp; &nbsp; &nbsp; 0.0.0.0 &nbsp; &nbsp; &nbsp; &nbsp; 255.255.252.0 &nbsp; U &nbsp; &nbsp; &nbsp; &nbsp; 0 0 &nbsp; &nbsp; &nbsp; &nbsp;  0 enp3g0<br>192.168.1.0 &nbsp; &nbsp; 0.0.0.0 &nbsp; &nbsp; &nbsp; &nbsp; 255.255.255.0 &nbsp; U &nbsp; &nbsp; &nbsp; &nbsp; 0 0 &nbsp; &nbsp; &nbsp; &nbsp;  0 virbr0<\/code><\/pre>\n\n\n\n<p>CentOS \/ <a href=\"https:\/\/so.csdn.net\/so\/search?q=RedHat&amp;spm=1001.2101.3001.7020\">RedHat<\/a> \u7cfb\u5217,\u67e5\u770b\u64cd\u4f5c\u7cfb\u7edf\u4fe1\u606f(\u5982\u679c\u6ca1\u6709lsb_release\u547d\u4ee4, \u4f7f\u7528\"yum install redhat-lsb\"\u5b89\u88c5):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@server-test online]# lsb_release -a<br>LSB Version:  :core-4.1-amd64:core-4.1-noarch<br>Distributor ID: CentOS<br>Description:  CentOS Linux release 7.5.1804 (Core) <br>Release:  7.5.1804<br>Codename: Core<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u4e09\u3001\u5173\u673a (\u7cfb\u7edf\u7684\u5173\u673a\u3001\u91cd\u542f\u4ee5\u53ca\u767b\u51fa )<\/strong><\/h1>\n\n\n\n<p>shutdown -h now \u5173\u95ed\u7cfb\u7edf(1)<\/p>\n\n\n\n<p>init 0 \u5173\u95ed\u7cfb\u7edf(2)<\/p>\n\n\n\n<p>telinit 0 \u5173\u95ed\u7cfb\u7edf(3)<\/p>\n\n\n\n<p>shutdown -h hours:minutes &amp; \u6309\u9884\u5b9a\u65f6\u95f4\u5173\u95ed\u7cfb\u7edf<\/p>\n\n\n\n<p>shutdown -c \u53d6\u6d88\u6309\u9884\u5b9a\u65f6\u95f4\u5173\u95ed\u7cfb\u7edf<\/p>\n\n\n\n<p>shutdown -r now \u91cd\u542f(1)<\/p>\n\n\n\n<p>reboot \u91cd\u542f(2)<\/p>\n\n\n\n<p>logout \u6ce8\u9500<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u56db\u3001\u6587\u4ef6\u548c\u76ee\u5f55<\/strong><\/h1>\n\n\n\n<p>cd \/home \u8fdb\u5165 '\/ home' \u76ee\u5f55'<\/p>\n\n\n\n<p>cd .. \u8fd4\u56de\u4e0a\u4e00\u7ea7\u76ee\u5f55<\/p>\n\n\n\n<p>cd ..\/.. \u8fd4\u56de\u4e0a\u4e24\u7ea7\u76ee\u5f55<\/p>\n\n\n\n<p>cd \u8fdb\u5165\u4e2a\u4eba\u7684\u4e3b\u76ee\u5f55<\/p>\n\n\n\n<p>cd ~user1 \u8fdb\u5165\u4e2a\u4eba\u7684\u4e3b\u76ee\u5f55<\/p>\n\n\n\n<p>cd - \u8fd4\u56de\u4e0a\u6b21\u6240\u5728\u7684\u76ee\u5f55<\/p>\n\n\n\n<p>pwd \u663e\u793a\u5de5\u4f5c\u8def\u5f84<\/p>\n\n\n\n<p>ls \u67e5\u770b\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6<\/p>\n\n\n\n<p>ls -F \u67e5\u770b\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6<\/p>\n\n\n\n<p>ls -l \u663e\u793a\u6587\u4ef6\u548c\u76ee\u5f55\u7684\u8be6\u7ec6\u8d44\u6599<\/p>\n\n\n\n<p>ls -a \u663e\u793a\u9690\u85cf\u6587\u4ef6<\/p>\n\n\n\n<p>ls <em>[0-9]<\/em> \u663e\u793a\u5305\u542b\u6570\u5b57\u7684\u6587\u4ef6\u540d\u548c\u76ee\u5f55\u540d<\/p>\n\n\n\n<p>tree \u663e\u793a\u6587\u4ef6\u548c\u76ee\u5f55\u7531\u6839\u76ee\u5f55\u5f00\u59cb\u7684\u6811\u5f62\u7ed3\u6784(1)<\/p>\n\n\n\n<p>lstree \u663e\u793a\u6587\u4ef6\u548c\u76ee\u5f55\u7531\u6839\u76ee\u5f55\u5f00\u59cb\u7684\u6811\u5f62\u7ed3\u6784(2)<\/p>\n\n\n\n<p>mkdir dir1 \u521b\u5efa\u4e00\u4e2a\u53eb\u505a 'dir1' \u7684\u76ee\u5f55'<\/p>\n\n\n\n<p>mkdir dir1 dir2 \u540c\u65f6\u521b\u5efa\u4e24\u4e2a\u76ee\u5f55<\/p>\n\n\n\n<p>mkdir -p \/tmp\/dir1\/dir2 \u521b\u5efa\u4e00\u4e2a\u76ee\u5f55\u6811<\/p>\n\n\n\n<p>rm -f file1 \u5220\u9664\u4e00\u4e2a\u53eb\u505a 'file1' \u7684\u6587\u4ef6'<\/p>\n\n\n\n<p>rmdir dir1 \u5220\u9664\u4e00\u4e2a\u53eb\u505a 'dir1' \u7684\u76ee\u5f55'<\/p>\n\n\n\n<p>rm -rf dir1 \u5220\u9664\u4e00\u4e2a\u53eb\u505a 'dir1' \u7684\u76ee\u5f55\u5e76\u540c\u65f6\u5220\u9664\u5176\u5185\u5bb9<\/p>\n\n\n\n<p>rm -rf dir1 dir2 \u540c\u65f6\u5220\u9664\u4e24\u4e2a\u76ee\u5f55\u53ca\u5b83\u4eec\u7684\u5185\u5bb9<\/p>\n\n\n\n<p>mv dir1 new_dir \u91cd\u547d\u540d\/\u79fb\u52a8 \u4e00\u4e2a\u76ee\u5f55<\/p>\n\n\n\n<p>cp file1 file2 \u590d\u5236\u4e00\u4e2a\u6587\u4ef6<\/p>\n\n\n\n<p>cp dir\/* . \u590d\u5236\u4e00\u4e2a\u76ee\u5f55\u4e0b\u7684\u6240\u6709\u6587\u4ef6\u5230\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55<\/p>\n\n\n\n<p>cp -a \/tmp\/dir1 . \u590d\u5236\u4e00\u4e2a\u76ee\u5f55\u5230\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55<\/p>\n\n\n\n<p>cp -a dir1 dir2 \u590d\u5236\u4e00\u4e2a\u76ee\u5f55<\/p>\n\n\n\n<p>ln -s file1 lnk1 \u521b\u5efa\u4e00\u4e2a\u6307\u5411\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u8f6f\u94fe\u63a5<\/p>\n\n\n\n<p>ln file1 lnk1 \u521b\u5efa\u4e00\u4e2a\u6307\u5411\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u7269\u7406\u94fe\u63a5<\/p>\n\n\n\n<p>touch -t 0712250000 file1 \u4fee\u6539\u4e00\u4e2a\u6587\u4ef6\u6216\u76ee\u5f55\u7684\u65f6\u95f4\u6233 - (YYMMDDhhmm)<\/p>\n\n\n\n<p>file file1 outputs the mime type of the file as text<\/p>\n\n\n\n<p>iconv -l \u5217\u51fa\u5df2\u77e5\u7684\u7f16\u7801<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>iconv -f fromEncoding -t toEncoding inputFile &gt; outputFile creates a new from the given input file by assuming it is encoded in fromEncoding and converting it to toEncoding.<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>find . -maxdepth 1 -name *.jpg -print -exec convert \"{}\" -resize 80x60 \"thumbs\/{}\" \\; batch resize files in the current directory and send them to a thumbnails directory (requires convert from Imagemagick)<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u4e94\u3001\u6587\u4ef6\u641c\u7d22<\/strong><\/h1>\n\n\n\n<p>find \/ -name file1 \u4ece '\/' \u5f00\u59cb\u8fdb\u5165\u6839\u6587\u4ef6\u7cfb\u7edf\u641c\u7d22\u6587\u4ef6\u548c\u76ee\u5f55<\/p>\n\n\n\n<p>find \/ -user user1 \u641c\u7d22\u5c5e\u4e8e\u7528\u6237 'user1' \u7684\u6587\u4ef6\u548c\u76ee\u5f55<\/p>\n\n\n\n<p>find \/home\/user1 -name *.bin \u5728\u76ee\u5f55 '\/ home\/user1' \u4e2d\u641c\u7d22\u5e26\u6709'.bin' \u7ed3\u5c3e\u7684\u6587\u4ef6<\/p>\n\n\n\n<p>find \/usr\/bin -type f -atime +100 \u641c\u7d22\u5728\u8fc7\u53bb100\u5929\u5185\u672a\u88ab\u4f7f\u7528\u8fc7\u7684\u6267\u884c\u6587\u4ef6<\/p>\n\n\n\n<p>find \/usr\/bin -type f -mtime -10 \u641c\u7d22\u572810\u5929\u5185\u88ab\u521b\u5efa\u6216\u8005\u4fee\u6539\u8fc7\u7684\u6587\u4ef6<\/p>\n\n\n\n<p>find \/ -name *.rpm -exec chmod 755 '{}' \\; \u641c\u7d22\u4ee5 '.rpm' \u7ed3\u5c3e\u7684\u6587\u4ef6\u5e76\u5b9a\u4e49\u5176\u6743\u9650 ^ find \/tmp -name *.hprof -exec rm -f {} \\;\u6279\u91cf\u5220\u9664java\u5806\u6808.hprof\u6587\u4ef6<\/p>\n\n\n\n<p>find \/ -xdev -name *.rpm \u641c\u7d22\u4ee5 '.rpm' \u7ed3\u5c3e\u7684\u6587\u4ef6\uff0c\u5ffd\u7565\u5149\u9a71\u3001\u6377\u76d8\u7b49\u53ef\u79fb\u52a8\u8bbe\u5907<\/p>\n\n\n\n<p>locate *.ps \u5bfb\u627e\u4ee5 '.ps' \u7ed3\u5c3e\u7684\u6587\u4ef6 - \u5148\u8fd0\u884c 'updatedb' \u547d\u4ee4<\/p>\n\n\n\n<p>whereis halt \u663e\u793a\u4e00\u4e2a\u4e8c\u8fdb\u5236\u6587\u4ef6\u3001\u6e90\u7801\u6216man\u7684\u4f4d\u7f6e<\/p>\n\n\n\n<p>which halt \u663e\u793a\u4e00\u4e2a\u4e8c\u8fdb\u5236\u6587\u4ef6\u6216\u53ef\u6267\u884c\u6587\u4ef6\u7684\u5b8c\u6574\u8def\u5f84<\/p>\n\n\n\n<p>grep -rn \"query_string\" * Linux\u76ee\u5f55\u4e0b\u5168\u5c40\u67e5\u627e\u6240\u6709\u6587\u4ef6\u4e2d\u662f\u5426\u5305\u542b\u6307\u5b9a\u5b57\u7b26\u4e32\uff08-r\uff1a\u9012\u5f52\uff1b-n\uff1a\u663e\u793a\u884c\u53f7\uff09<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u516d\u3001\u6302\u8f7d\u4e00\u4e2a\u6587\u4ef6\u7cfb\u7edf<\/strong><\/h1>\n\n\n\n<p>mount \/dev\/hda2 \/mnt\/hda2<a href=\"https:\/\/so.csdn.net\/so\/search?q=%E6%8C%82%E8%BD%BD&amp;spm=1001.2101.3001.7020\">\u6302\u8f7d<\/a>\u4e00\u4e2a\u53eb\u505ahda2\u7684\u76d8 - \u786e\u5b9a\u76ee\u5f55 '\/ mnt\/hda2' \u5df2\u7ecf\u5b58\u5728<\/p>\n\n\n\n<p>umount \/dev\/hda2 \u5378\u8f7d\u4e00\u4e2a\u53eb\u505ahda2\u7684\u76d8 - \u5148\u4ece\u6302\u8f7d\u70b9 '\/ mnt\/hda2' \u9000\u51fa<\/p>\n\n\n\n<p>fuser -km \/mnt\/hda2 \u5f53\u8bbe\u5907\u7e41\u5fd9\u65f6\u5f3a\u5236\u5378\u8f7d<\/p>\n\n\n\n<p>umount -n \/mnt\/hda2 \u8fd0\u884c\u5378\u8f7d\u64cd\u4f5c\u800c\u4e0d\u5199\u5165 \/etc\/mtab \u6587\u4ef6- \u5f53\u6587\u4ef6\u4e3a\u53ea\u8bfb\u6216\u5f53\u78c1\u76d8\u5199\u6ee1\u65f6\u975e\u5e38\u6709\u7528<\/p>\n\n\n\n<p>mount \/dev\/fd0 \/mnt\/floppy \u6302\u8f7d\u4e00\u4e2a\u8f6f\u76d8<\/p>\n\n\n\n<p>mount \/dev\/cdrom \/mnt\/cdrom \u6302\u8f7d\u4e00\u4e2acdrom\u6216dvdrom<\/p>\n\n\n\n<p>mount \/dev\/hdc \/mnt\/cdrecorder \u6302\u8f7d\u4e00\u4e2acdrw\u6216dvdrom<\/p>\n\n\n\n<p>mount \/dev\/hdb \/mnt\/cdrecorder \u6302\u8f7d\u4e00\u4e2acdrw\u6216dvdrom<\/p>\n\n\n\n<p>mount -o loop file.iso \/mnt\/cdrom \u6302\u8f7d\u4e00\u4e2a\u6587\u4ef6\u6216ISO\u955c\u50cf\u6587\u4ef6<\/p>\n\n\n\n<p>mount -t vfat \/dev\/hda5 \/mnt\/hda5 \u6302\u8f7d\u4e00\u4e2aWindows FAT32\u6587\u4ef6\u7cfb\u7edf<\/p>\n\n\n\n<p>mount \/dev\/sda1 \/mnt\/usbdisk \u6302\u8f7d\u4e00\u4e2ausb \u6377\u76d8\u6216\u95ea\u5b58\u8bbe\u5907<\/p>\n\n\n\n<p>mount -t smbfs -o username=user,password=pass \/\/WinClient\/share \/mnt\/share \u6302\u8f7d\u4e00\u4e2awindows\u7f51\u7edc\u5171\u4eab<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u4e03\u3001\u78c1\u76d8\u7a7a\u95f4<\/strong><\/h1>\n\n\n\n<p>df -h \u663e\u793a\u5df2\u7ecf\u6302\u8f7d\u7684\u5206\u533a\u5217\u8868<\/p>\n\n\n\n<p>ls -lSr |more \u4ee5\u5c3a\u5bf8\u5927\u5c0f\u6392\u5217\u6587\u4ef6\u548c\u76ee\u5f55<\/p>\n\n\n\n<p>du -sh dir1 \u4f30\u7b97\u76ee\u5f55 'dir1' \u5df2\u7ecf\u4f7f\u7528\u7684\u78c1\u76d8\u7a7a\u95f4'<\/p>\n\n\n\n<p>du -sk * | sort -rn \u4ee5\u5bb9\u91cf\u5927\u5c0f\u4e3a\u4f9d\u636e\u4f9d\u6b21\u663e\u793a\u6587\u4ef6\u548c\u76ee\u5f55\u7684\u5927\u5c0f<\/p>\n\n\n\n<p>rpm -q -a --qf '%10{SIZE}t%{NAME}n' | sort -k1,1n \u4ee5\u5927\u5c0f\u4e3a\u4f9d\u636e\u4f9d\u6b21\u663e\u793a\u5df2\u5b89\u88c5\u7684rpm\u5305\u6240\u4f7f\u7528\u7684\u7a7a\u95f4 (fedora, redhat\u7c7b\u7cfb\u7edf)<\/p>\n\n\n\n<p>dpkg-query -W -f='${Installed-Size;10}t${Package}n' | sort -k1,1n \u4ee5\u5927\u5c0f\u4e3a\u4f9d\u636e\u663e\u793a\u5df2\u5b89\u88c5\u7684deb\u5305\u6240\u4f7f\u7528\u7684\u7a7a\u95f4 (ubuntu, debian\u7c7b\u7cfb\u7edf)<\/p>\n\n\n\n<p>hdfs dfs -du \/dw\/default | sort -rn | head -n 10 | awk '{printf(\"%.2f\\t\\t%.2f\\t\\t%s\\t\\n\",$1\/1024\/1024\/1024,\"\\t\"$2\/1024\/1024\/1024,\"\\t\"$3)}' \u67e5\u8be2hdfs\u6587\u4ef6\u7cfb\u7edf\u4e2d\u8868\u6587\u4ef6\u5927\u5c0f\uff0c\u6309\u4ece\u5927\u5230\u5c0f\u7684\u987a\u5e8f\u6392\u5217(\u53d6\u524d10\u5217)\uff0c\u5355\u4f4dGB<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u516b\u3001\u7cfb\u7edf\u8d1f\u8f7d -- top<\/strong><\/h1>\n\n\n\n<p>top -d 20 -p 1303 \u5c06\u8fdb\u7a0b\u53f71303\u7684\u7cfb\u7edf\u8d1f\u8f7d\uff0c\u6bcf\u969420\u79d2\u5237\u65b0\u4e00\u6b21\u3002\u82f1\u6587\u72b6\u6001\u4e0b\uff0c\u6309\u4f4fc\u952e\uff0c\u5c06\u5c55\u793a\u8fdb\u884c\u7684\u8be6\u7ec6\u73af\u5883\u4fe1\u606f\uff0c\u5bf9\u4e8ejava\u7a0b\u5e8f\u8c03\u8bd5\u6765\u8bf4\uff0c\u975e\u5e38\u53cb\u597d\u3002<\/p>\n\n\n\n<p>top -d 20 -n 3 -b &gt; test.txt \u6bcf\u969420\u79d2\uff0c\u4e00\u5171\u6267\u884c3\u6b21\uff0c \u5c06\u7edf\u8ba1\u7ed3\u679c\u5bfc\u5165\u5230test.txt\u6587\u4ef6\u4e2d\u3002<\/p>\n\n\n\n<p>top\u547d\u4ee4\u663e\u793a\u4e0d\u5168\uff0c\u6dfb\u52a0-w\u53c2\u6570\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u547d\u4ee4\u4e3a\uff1a<br>top -b -n 1<br>-b\u4e3a \u6279\u5904\u7406\u6a21\u5f0f\uff0c-n\u4e3a\u5237\u65b0\u7684\u6b21\u6570<br>\u53d1\u73b0\u4fe1\u606f\u663e\u793a\u4e0d\u5168\uff0c\u6700\u540eman top\uff0c\u52a0\u4e00\u4e2a\u53c2\u6570w\u540e\uff0c\u5b8c\u5168\u663e\u793a<br> <br>top -b -n 1 -w 512<br>\u5982\u679c\u9700\u8981\u663e\u793a\u5b8c\u6574\u7684COMMAND\u547d\u4ee4\uff0c\u4f7f\u7528top -c\u53c2\u6570<br> <br>top -c -bw 500<br>\u67e5\u770b\u5b8c\u6574\u8fdb\u7a0b\u540d\uff0c \u6309500\u4e2a\u5b57\u7b26\u957f\u5ea6\u67e5\u770b\uff08\u8fd9\u6837\u57fa\u672c\u53ef\u4ee5\u67e5\u770b\u5230\u5b8c\u6574\u7684\u547d\u4ee4\uff09<\/code><\/pre>\n\n\n\n<p>\u5176\u4ed6\u53c2\u6570\u5217\u8868\uff0c\u5b98\u65b9\u89e3\u91ca\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>1. COMMAND-LINE Options<br> &nbsp; &nbsp; &nbsp; The command-line syntax for top consists of:<br> <br> &nbsp; &nbsp; &nbsp; &nbsp; -hv|-bcHiOSs -d secs -n max -u|U user -p pid -o fld -w &#91;cols]<br> <br> &nbsp; &nbsp; &nbsp; The typically mandatory switch ('-') and even whitespace are completely optional.<br> <br> &nbsp; &nbsp; &nbsp; -h | -v  :Help\/Version<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Show library version and the usage prompt, then quit.<br> <br> &nbsp; &nbsp; &nbsp; -b  :Batch-mode operation<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Starts top in Batch mode, which could be useful for sending output from top to other programs or to a file.  In this mode, top will not accept input and runs until the iterations limit you've set with the `-n' command-line option or until killed.<br> <br> &nbsp; &nbsp; &nbsp; -c  :Command-line\/Program-name toggle<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Starts top with the last remembered `c' state reversed.  Thus, if top was displaying command lines, now that field will show program names, and visa versa.  See the `c' interactive command for additional information.<br> <br> &nbsp; &nbsp; &nbsp; -d  :Delay-time interval as:  -d ss.t (secs.tenths)<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Specifies the delay between screen updates, and overrides the corresponding value in one's personal configuration file or the startup default.  Later this can be changed with the `d' or `s' interactive commands.<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Fractional  seconds  are honored, but a negative number is not allowed.  In all cases, however, such changes are prohibited if top is running in Secure mode, except for root (unless the `s' command-line option was used).  For additional information on<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Secure mode see topic 6a. SYSTEM Configuration File.<br> <br> &nbsp; &nbsp; &nbsp; -H  :Threads-mode operation<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Instructs top to display individual threads.  Without this command-line option a summation of all threads in each process is shown.  Later this can be changed with the `H' interactive command.<br> &nbsp; &nbsp; &nbsp; -i  :Idle-process toggle<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Starts top with the last remembered `i' state reversed.  When this toggle is Off, tasks that have not used any CPU since the last update will not be displayed.  For additional information regarding this toggle see topic 4c. TASK AREA Commands, SIZE.<br> <br> &nbsp; &nbsp; &nbsp; -n  :Number-of-iterations limit as:  -n number<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Specifies the maximum number of iterations, or frames, top should produce before ending.<br> <br> &nbsp; &nbsp; &nbsp; -o  :Override-sort-field as:  -o fieldname<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Specifies the name of the field on which tasks will be sorted, independent of what is reflected in the configuration file.  You can prepend a `+' or `-' to the field name to also override the sort direction.  A leading `+' will force sorting  high  to<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  low, whereas a `-' will ensure a low to high ordering.<br> <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  This option exists primarily to support automated\/scripted batch mode operation.<br> <br> &nbsp; &nbsp; &nbsp; -O  :Output-field-names<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  This option acts as a form of help for the above -o option.  It will cause top to print each of the available field names on a separate line, then quit.  Such names are subject to nls translation.<br> <br> &nbsp; &nbsp; &nbsp; -p  :Monitor-PIDs mode as:  -pN1 -pN2 ...  or  -pN1,N2,N3 ...<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Monitor only processes with specified process IDs.  This option can be given up to 20 times, or you can provide a comma delimited list with up to 20 pids.  Co-mingling both approaches is permitted.<br> <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  A pid value of zero will be treated as the process id of the top program itself once it is running.<br> <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  This is a command-line option only and should you wish to return to normal operation, it is not necessary to quit and restart top  --  just issue any of these interactive commands: `=', `u' or `U'.<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  The `p', `u' and `U' command-line options are mutually exclusive.<br> <br> &nbsp; &nbsp; &nbsp; -s  :Secure-mode operation<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Starts top with secure mode forced, even for root.  This mode is far better controlled through the system configuration file (see topic 6. FILES).<br> <br> &nbsp; &nbsp; &nbsp; -S  :Cumulative-time toggle<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Starts  top  with  the  last  remembered `S' state reversed.  When Cumulative time mode is On, each process is listed with the cpu time that it and its dead children have used.  See the `S' interactive command for additional information regarding this<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  mode.<br> <br> &nbsp; &nbsp; &nbsp; -u | -U  :User-filter-mode as:  -u | -U number or name<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Display only processes with a user id or user name matching that given.  The `-u' option matches on  effective user whereas the `-U' option matches on any user (real, effective, saved, or filesystem).<br> <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Prepending an exclamation point ('!') to the user id or name instructs top to display only processes with users not matching the one provided.<br> <br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  The `p', `u' and `U' command-line options are mutually exclusive.<br> &nbsp; &nbsp; &nbsp; -w  :Output-width-override as:  -w &#91; number ]<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  In Batch mode, when used without an argument top will format output using the COLUMNS= and LINES= environment variables, if set.  Otherwise, width will be fixed at the maximum 512 columns.  With an argument, output width can be decreased or  increased<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  (up to 512) but the number of rows is considered unlimited.<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  In normal display mode, when used without an argument top will attempt to format output using the COLUMNS= and LINES= environment variables, if set.  With an argument, output width can only be decreased, not increased.  Whether using environment vari\u2010<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ables or an argument with -w, when not in Batch mode actual terminal dimensions can never be exceeded.<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  Note: Without the use of this command-line option, output width is always based on the terminal at which top was invoked whether or not in Batch mode.<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u4e5d\u3001\u7528\u6237\u548c\u7fa4\u7ec4<\/strong><\/h1>\n\n\n\n<p>groupadd group_name \u521b\u5efa\u4e00\u4e2a\u65b0\u7528\u6237\u7ec4<\/p>\n\n\n\n<p>groupdel group_name \u5220\u9664\u4e00\u4e2a\u7528\u6237\u7ec4<\/p>\n\n\n\n<p>groupmod -n new_group_name old_group_name \u91cd\u547d\u540d\u4e00\u4e2a\u7528\u6237\u7ec4<\/p>\n\n\n\n<p>useradd -c \"Name Surname \" -g admin -d \/home\/user1 -s \/bin\/bash user1 \u521b\u5efa\u4e00\u4e2a\u5c5e\u4e8e \"admin\" \u7528\u6237\u7ec4\u7684\u7528\u6237<\/p>\n\n\n\n<p>useradd user1 \u521b\u5efa\u4e00\u4e2a\u65b0\u7528\u6237<\/p>\n\n\n\n<p>userdel -r user1 \u5220\u9664\u4e00\u4e2a\u7528\u6237 ( '-r' \u6392\u9664\u4e3b\u76ee\u5f55)<\/p>\n\n\n\n<p>usermod -c \"User FTP\" -g system -d \/ftp\/user1 -s \/bin\/nologin user1 \u4fee\u6539\u7528\u6237\u5c5e\u6027<\/p>\n\n\n\n<p>passwd \u4fee\u6539\u53e3\u4ee4<\/p>\n\n\n\n<p>passwd user1 \u4fee\u6539\u4e00\u4e2a\u7528\u6237\u7684\u53e3\u4ee4 (\u53ea\u5141\u8bb8root\u6267\u884c)<\/p>\n\n\n\n<p>chage -E 2005-12-31 user1 \u8bbe\u7f6e\u7528\u6237\u53e3\u4ee4\u7684\u5931\u6548\u671f\u9650<\/p>\n\n\n\n<p>pwck \u68c0\u67e5 '\/etc\/passwd' \u7684\u6587\u4ef6\u683c\u5f0f\u548c\u8bed\u6cd5\u4fee\u6b63\u4ee5\u53ca\u5b58\u5728\u7684\u7528\u6237<\/p>\n\n\n\n<p>grpck \u68c0\u67e5 '\/etc\/passwd' \u7684\u6587\u4ef6\u683c\u5f0f\u548c\u8bed\u6cd5\u4fee\u6b63\u4ee5\u53ca\u5b58\u5728\u7684\u7fa4\u7ec4<\/p>\n\n\n\n<p>newgrp group_name \u767b\u9646\u8fdb\u4e00\u4e2a\u65b0\u7684\u7fa4\u7ec4\u4ee5\u6539\u53d8\u65b0\u521b\u5efa\u6587\u4ef6\u7684\u9884\u8bbe\u7fa4\u7ec4<\/p>\n\n\n\n<p>\u6848\u4f8b 1\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#### 1-\u521b\u5efa\u7528\u6237\u30012-\u8ffd\u52a0\u9644\u52a0\u7ec4\u30013-\u5220\u9664\u9644\u52a0\u7ec4<br># 1<br>useradd san_zhang -m<br>passwd san_zhang san_zhang@163.com<br> <br># \u4ece\u7ba1\u9053\u8f93\u51fa\u4e2d\u4fee\u6539\u5bc6\u7801(\u5982\u679c\u975eroot\u4e14\u53ef\u4ee5\u8f6c\u4e3aroot\uff0c\u8bf7\u4f7f\u7528sudo)<br>echo san_zhang@163.com | sudo passwd --stdin san_zhang<br> <br> <br>#-----------------------------------------------------<br># 2<br>usermod -aG hdfs san_zhang (\u5c06san_zhang\u8ffd\u52a0\u5230\u9644\u52a0\u7ec4hdfs\u4e2d(\u53ef\u4ee5\u6dfb\u52a0\u591a\u4e2a\u9644\u52a0\u7ec4\uff0c\u591a\u4e2a\u7ec4\u4e4b\u95f4\u7528\u7a7a\u683c\u9694\u5f00\uff0c\u5982\"hdfs,yarn,spark\")\uff0c\u5176\u9ed8\u8ba4\u5728san_zhang\u4e2d)<br>\u6b64\u65f6\u67e5\u770b\u5176\u6240\u5728\u7684\u7528\u6237\u7ec4\uff0c\u53ef\u4ee5\u53d1\u73b0\u5176\u6240\u5c5e\u7ec4\u4e3asan_zhang\uff0c\u9644\u52a0\u7ec4\u4e3ahdfs\uff0c\u5982\u4e0b\uff1a<br>id san_zhang<br>uid=1001(san_zhang) gid=1001(san_zhang) groups=1001(san_zhang),992(hdfs)<br> <br>\u5f15\u7533\uff1a<br>\u5982\u679c\u4e0a\u4e00\u6b65\u987a\u5e8f\u5199\u9519\uff0c\u8bef\u5c06hdfs\u8ffd\u52a0\u5230san_zhang\u7528\u6237\u7ec4\u4e2d\uff0c\u5982\u4f7f\u7528\u4e86\u5982\u4e0b\u9519\u8bef\u7684\u547d\u4ee4\uff1a<br>usermod -aG san_zhang hdfs<br>\u5219\u6b64\u65f6\u67e5\u770bhdfs\u6240\u5c5e\u7ec4\uff0c\u5c31\u4f1a\u53d1\u73b0\u5176\u4e5f\u5728san_zhang\u7ec4\u4e0b\u4e86<br>id hdfs<br>uid=995(hdfs) gid=992(hdfs) groups=992(hdfs),994(hadoop),1001(san_zhang)<br> <br>\u8fd9\u65f6\u518d\u67e5\u770bsan_zhang\u7ec4\uff0c\u5c31\u4f1a\u770b\u5230\u8bef\u52a0\u5165\u7684hdfs\u7528\u6237\u4e86<br>groups san_zhang<br>san_zhang : san_zhang hdfs<br>#-----------------------------------------------------<br># 3<br>gpasswd -d hdfs san_zhang (\u4ecesan_zhang\u7ec4\u4e2d\u5220\u9664\u8bef\u52a0\u5165\u7684hdfs\u7528\u6237)<br>\u6267\u884c\u540e\u7684\u65e5\u5fd7\uff1aRemoving user hdfs from group san_zhang<br>#-----------------------------------------------------<\/pre>\n\n\n\n<p>\u6848\u4f8b 2\uff1a<\/p>\n\n\n\n<p>\u7edf\u8ba1\u67d0\u4e2a\u5206\u7ec4\u4e0b\u6709\u54ea\u4e9b\u7528\u6237<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@cdh01 ~]# grep hdfs \/etc\/group<br>hdfs:x:993:<br> <br>&#91;root@cdh01 ~]# awk -F : '{print $1,$4}' \/etc\/passwd | grep '993'<br>hdfs 993<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u5341\u3001\u6587\u4ef6\u7684\u6743\u9650 - \u4f7f\u7528 \"+\" \u8bbe\u7f6e\u6743\u9650\uff0c\u4f7f\u7528 \"-\" \u7528\u4e8e\u53d6\u6d88<\/strong><\/h1>\n\n\n\n<p>ls -lh \u663e\u793a\u6743\u9650<\/p>\n\n\n\n<p>ls \/tmp | pr -T5 -W$COLUMNS \u5c06\u7ec8\u7aef\u5212\u5206\u62105\u680f\u663e\u793a<\/p>\n\n\n\n<p>chmod ugo+rwx directory1 \u8bbe\u7f6e\u76ee\u5f55\u7684\u6240\u6709\u4eba(u)\u3001\u7fa4\u7ec4(g)\u4ee5\u53ca\u5176\u4ed6\u4eba(o)\u4ee5\u8bfb\uff08r \uff09\u3001\u5199(w)\u548c\u6267\u884c(x)\u7684\u6743\u9650<\/p>\n\n\n\n<p>chmod go-rwx directory1 \u5220\u9664\u7fa4\u7ec4(g)\u4e0e\u5176\u4ed6\u4eba(o)\u5bf9\u76ee\u5f55\u7684\u8bfb\u5199\u6267\u884c\u6743\u9650<\/p>\n\n\n\n<p>chown user1 file1 \u6539\u53d8\u4e00\u4e2a\u6587\u4ef6\u7684\u6240\u6709\u4eba\u5c5e\u6027<\/p>\n\n\n\n<p>chown -R user1 directory1 \u6539\u53d8\u4e00\u4e2a\u76ee\u5f55\u7684\u6240\u6709\u4eba\u5c5e\u6027\u5e76\u540c\u65f6\u6539\u53d8\u6539\u76ee\u5f55\u4e0b\u6240\u6709\u6587\u4ef6\u7684\u5c5e\u6027<\/p>\n\n\n\n<p>chgrp group1 file1 \u6539\u53d8\u6587\u4ef6\u7684\u7fa4\u7ec4<\/p>\n\n\n\n<p>chown user1:group1 file1 \u6539\u53d8\u4e00\u4e2a\u6587\u4ef6\u7684\u6240\u6709\u4eba\u548c\u7fa4\u7ec4\u5c5e\u6027<\/p>\n\n\n\n<p>find \/ -perm -u+s \u7f57\u5217\u4e00\u4e2a\u7cfb\u7edf\u4e2d\u6240\u6709\u4f7f\u7528\u4e86SUID\u63a7\u5236\u7684\u6587\u4ef6<\/p>\n\n\n\n<p>chmod u+s \/bin\/file1 \u8bbe\u7f6e\u4e00\u4e2a\u4e8c\u8fdb\u5236\u6587\u4ef6\u7684 SUID \u4f4d - \u8fd0\u884c\u8be5\u6587\u4ef6\u7684\u7528\u6237\u4e5f\u88ab\u8d4b\u4e88\u548c\u6240\u6709\u8005\u540c\u6837\u7684\u6743\u9650<\/p>\n\n\n\n<p>chmod u-s \/bin\/file1 \u7981\u7528\u4e00\u4e2a\u4e8c\u8fdb\u5236\u6587\u4ef6\u7684 SUID\u4f4d<\/p>\n\n\n\n<p>chmod g+s \/home\/public \u8bbe\u7f6e\u4e00\u4e2a\u76ee\u5f55\u7684SGID \u4f4d - \u7c7b\u4f3cSUID \uff0c\u4e0d\u8fc7\u8fd9\u662f\u9488\u5bf9\u76ee\u5f55\u7684<\/p>\n\n\n\n<p>chmod g-s \/home\/public \u7981\u7528\u4e00\u4e2a\u76ee\u5f55\u7684 SGID \u4f4d<\/p>\n\n\n\n<p>chmod o+t \/home\/public \u8bbe\u7f6e\u4e00\u4e2a\u6587\u4ef6\u7684 STIKY \u4f4d - \u53ea\u5141\u8bb8\u5408\u6cd5\u6240\u6709\u4eba\u5220\u9664\u6587\u4ef6<\/p>\n\n\n\n<p>chmod o-t \/home\/public \u7981\u7528\u4e00\u4e2a\u76ee\u5f55\u7684 STIKY \u4f4d<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u5341\u4e00\u3001\u6587\u4ef6\u7684\u7279\u6b8a\u5c5e\u6027 - \u4f7f\u7528 \"+\" \u8bbe\u7f6e\u6743\u9650\uff0c\u4f7f\u7528 \"-\" \u7528\u4e8e\u53d6\u6d88<\/strong><\/h1>\n\n\n\n<p>chattr +a file1 \u53ea\u5141\u8bb8\u4ee5\u8ffd\u52a0\u65b9\u5f0f\u8bfb\u5199\u6587\u4ef6<\/p>\n\n\n\n<p>chattr +c file1 \u5141\u8bb8\u8fd9\u4e2a\u6587\u4ef6\u80fd\u88ab\u5185\u6838\u81ea\u52a8\u538b\u7f29\/\u89e3\u538b<\/p>\n\n\n\n<p>chattr +d file1 \u5728\u8fdb\u884c\u6587\u4ef6\u7cfb\u7edf\u5907\u4efd\u65f6\uff0cdump\u7a0b\u5e8f\u5c06\u5ffd\u7565\u8fd9\u4e2a\u6587\u4ef6<\/p>\n\n\n\n<p>chattr +i file1 \u8bbe\u7f6e\u6210\u4e0d\u53ef\u53d8\u7684\u6587\u4ef6\uff0c\u4e0d\u80fd\u88ab\u5220\u9664\u3001\u4fee\u6539\u3001\u91cd\u547d\u540d\u6216\u8005\u94fe\u63a5<\/p>\n\n\n\n<p>chattr +s file1 \u5141\u8bb8\u4e00\u4e2a\u6587\u4ef6\u88ab\u5b89\u5168\u5730\u5220\u9664<\/p>\n\n\n\n<p>chattr +S file1 \u4e00\u65e6\u5e94\u7528\u7a0b\u5e8f\u5bf9\u8fd9\u4e2a\u6587\u4ef6\u6267\u884c\u4e86\u5199\u64cd\u4f5c\uff0c\u4f7f\u7cfb\u7edf\u7acb\u523b\u628a\u4fee\u6539\u7684\u7ed3\u679c\u5199\u5230\u78c1\u76d8<\/p>\n\n\n\n<p>chattr +u file1 \u82e5\u6587\u4ef6\u88ab\u5220\u9664\uff0c\u7cfb\u7edf\u4f1a\u5141\u8bb8\u4f60\u5728\u4ee5\u540e\u6062\u590d\u8fd9\u4e2a\u88ab\u5220\u9664\u7684\u6587\u4ef6<\/p>\n\n\n\n<p>lsattr \u663e\u793a\u7279\u6b8a\u7684\u5c5e\u6027<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u5341\u4e8c\u3001\u6253\u5305\u548c\u538b\u7f29\u6587\u4ef6<\/strong><\/h1>\n\n\n\n<p>bunzip2 file1.bz2 \u89e3\u538b\u4e00\u4e2a\u53eb\u505a 'file1.bz2'\u7684\u6587\u4ef6<\/p>\n\n\n\n<p>bzip2 file1 \u538b\u7f29\u4e00\u4e2a\u53eb\u505a 'file1' \u7684\u6587\u4ef6<\/p>\n\n\n\n<p>gunzip file1.gz \u89e3\u538b\u4e00\u4e2a\u53eb\u505a 'file1.gz'\u7684\u6587\u4ef6<\/p>\n\n\n\n<p>gzip file1 \u538b\u7f29\u4e00\u4e2a\u53eb\u505a 'file1'\u7684\u6587\u4ef6<\/p>\n\n\n\n<p>gzip -9 file1 \u6700\u5927\u7a0b\u5ea6\u538b\u7f29<\/p>\n\n\n\n<p>rar a file1.rar test_file \u521b\u5efa\u4e00\u4e2a\u53eb\u505a 'file1.rar' \u7684\u5305<\/p>\n\n\n\n<p>rar a file1.rar file1 file2 dir1 \u540c\u65f6\u538b\u7f29 'file1', 'file2' \u4ee5\u53ca\u76ee\u5f55 'dir1'<\/p>\n\n\n\n<p>unrar x file1.rar \u89e3\u538brar\u5305 #\u5982\u679c\u65e0unrar\u547d\u4ee4\uff0c\u53c2\u8003\uff1a<a href=\"http:\/\/www.360doc.com\/content\/17\/0426\/21\/41572081_648911802.shtml\">Linux CentOS 7.0 \u4e0b rar unrar\u7684\u5b89\u88c5<\/a><\/p>\n\n\n\n<p>tar -cvf archive.tar file1 \u521b\u5efa\u4e00\u4e2a\u975e\u538b\u7f29\u7684 tarball<\/p>\n\n\n\n<p>tar -cvf archive.tar file1 file2 dir1 \u521b\u5efa\u4e00\u4e2a\u5305\u542b\u4e86 'file1', 'file2' \u4ee5\u53ca 'dir1'\u7684\u6863\u6848\u6587\u4ef6<\/p>\n\n\n\n<p>tar -tf archive.tar \u663e\u793a\u4e00\u4e2a\u5305\u4e2d\u7684\u5185\u5bb9<\/p>\n\n\n\n<p>tar -xvf archive.tar \u91ca\u653e\u4e00\u4e2a\u5305<\/p>\n\n\n\n<p>tar -xvf archive.tar -C \/tmp \u5c06\u538b\u7f29\u5305\u91ca\u653e\u5230 \/tmp\u76ee\u5f55\u4e0b<\/p>\n\n\n\n<p>tar -cvfj archive.tar.bz2 dir1 \u521b\u5efa\u4e00\u4e2abzip2\u683c\u5f0f\u7684\u538b\u7f29\u5305<\/p>\n\n\n\n<p>tar -jxvf archive.tar.bz2 \u89e3\u538b\u4e00\u4e2abzip2\u683c\u5f0f\u7684\u538b\u7f29\u5305<\/p>\n\n\n\n<p>tar -cvfz archive.tar.gz dir1 \u521b\u5efa\u4e00\u4e2agzip\u683c\u5f0f\u7684\u538b\u7f29\u5305<\/p>\n\n\n\n<p>tar -zxvf archive.tar.gz \u89e3\u538b\u4e00\u4e2agzip\u683c\u5f0f\u7684\u538b\u7f29\u5305<\/p>\n\n\n\n<p>zip file1.zip file1 \u521b\u5efa\u4e00\u4e2azip\u683c\u5f0f\u7684\u538b\u7f29\u5305<\/p>\n\n\n\n<p>zip -r file1.zip file1 file2 dir1 \u5c06\u51e0\u4e2a\u6587\u4ef6\u548c\u76ee\u5f55\u540c\u65f6\u538b\u7f29\u6210\u4e00\u4e2azip\u683c\u5f0f\u7684\u538b\u7f29\u5305<\/p>\n\n\n\n<p>unzip file1.zip \u89e3\u538b\u4e00\u4e2azip\u683c\u5f0f\u538b\u7f29\u5305<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u5341\u4e09\u3001OS\u5305\u7ba1\u7406\u5668<\/strong><\/h1>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u2460\u3001RPM \u5305 - \uff08Fedora, Redhat\u53ca\u7c7b\u4f3c\u7cfb\u7edf\uff09<\/strong><\/h2>\n\n\n\n<p>rpm -ivh package.rpm \u5b89\u88c5\u4e00\u4e2arpm\u5305<\/p>\n\n\n\n<p>rpm -ivh --nodeps package.rpm \u5b89\u88c5\u4e00\u4e2arpm\u5305\u800c\u5ffd\u7565\u4f9d\u8d56\u5173\u7cfb\u8b66\u544a<\/p>\n\n\n\n<p>rpm -U package.rpm \u66f4\u65b0\u4e00\u4e2arpm\u5305\u4f46\u4e0d\u6539\u53d8\u5176\u914d\u7f6e\u6587\u4ef6<\/p>\n\n\n\n<p>rpm -F package.rpm \u66f4\u65b0\u4e00\u4e2a\u786e\u5b9a\u5df2\u7ecf\u5b89\u88c5\u7684rpm\u5305<\/p>\n\n\n\n<p>rpm -e [--nodeps] package_name.rpm \u5220\u9664\u4e00\u4e2arpm\u5305[--nodeps\u8868\u793a\u5ffd\u7565\u4f9d\u8d56\u5173\u7cfb]<\/p>\n\n\n\n<p>rpm -qa \u663e\u793a\u7cfb\u7edf\u4e2d\u6240\u6709\u5df2\u7ecf\u5b89\u88c5\u7684rpm\u5305<\/p>\n\n\n\n<p>rpm -qa | grep httpd \u663e\u793a\u6240\u6709\u540d\u79f0\u4e2d\u5305\u542b \"httpd\" \u5b57\u6837\u7684rpm\u5305<\/p>\n\n\n\n<p>rpm -qi package_name \u83b7\u53d6\u4e00\u4e2a\u5df2\u5b89\u88c5\u5305\u7684\u7279\u6b8a\u4fe1\u606f<\/p>\n\n\n\n<p>rpm -qg \"System Environment\/Daemons\" \u663e\u793a\u4e00\u4e2a\u7ec4\u4ef6\u7684rpm\u5305<\/p>\n\n\n\n<p>rpm -ql package_name \u663e\u793a\u4e00\u4e2a\u5df2\u7ecf\u5b89\u88c5\u7684rpm\u5305\u63d0\u4f9b\u7684\u6587\u4ef6\u5217\u8868<\/p>\n\n\n\n<p>rpm -qc package_name \u663e\u793a\u4e00\u4e2a\u5df2\u7ecf\u5b89\u88c5\u7684rpm\u5305\u63d0\u4f9b\u7684\u914d\u7f6e\u6587\u4ef6\u5217\u8868<\/p>\n\n\n\n<p>rpm -q package_name --whatrequires \u663e\u793a\u4e0e\u4e00\u4e2arpm\u5305\u5b58\u5728\u4f9d\u8d56\u5173\u7cfb\u7684\u5217\u8868<\/p>\n\n\n\n<p>rpm -q package_name --whatprovides \u663e\u793a\u4e00\u4e2arpm\u5305\u6240\u5360\u7684\u4f53\u79ef<\/p>\n\n\n\n<p>rpm -q package_name --scripts \u663e\u793a\u5728\u5b89\u88c5\/\u5220\u9664\u671f\u95f4\u6240\u6267\u884c\u7684\u811a\u672cl<\/p>\n\n\n\n<p>rpm -q package_name --changelog \u663e\u793a\u4e00\u4e2arpm\u5305\u7684\u4fee\u6539\u5386\u53f2<\/p>\n\n\n\n<p>rpm -qf \/etc\/httpd\/conf\/httpd.conf \u786e\u8ba4\u6240\u7ed9\u7684\u6587\u4ef6\u7531\u54ea\u4e2arpm\u5305\u6240\u63d0\u4f9b<\/p>\n\n\n\n<p>rpm -qp package.rpm -l \u663e\u793a\u7531\u4e00\u4e2a\u5c1a\u672a\u5b89\u88c5\u7684rpm\u5305\u63d0\u4f9b\u7684\u6587\u4ef6\u5217\u8868<\/p>\n\n\n\n<p>rpm --import \/media\/cdrom\/RPM-GPG-KEY \u5bfc\u5165\u516c\u94a5\u6570\u5b57\u8bc1\u4e66<\/p>\n\n\n\n<p>rpm --checksig package.rpm \u786e\u8ba4\u4e00\u4e2arpm\u5305\u7684\u5b8c\u6574\u6027<\/p>\n\n\n\n<p>rpm -qa gpg-pubkey \u786e\u8ba4\u5df2\u5b89\u88c5\u7684\u6240\u6709rpm\u5305\u7684\u5b8c\u6574\u6027<\/p>\n\n\n\n<p>rpm -V package_name \u68c0\u67e5\u6587\u4ef6\u5c3a\u5bf8\u3001 \u8bb8\u53ef\u3001\u7c7b\u578b\u3001\u6240\u6709\u8005\u3001\u7fa4\u7ec4\u3001MD5\u68c0\u67e5\u4ee5\u53ca\u6700\u540e\u4fee\u6539\u65f6\u95f4<\/p>\n\n\n\n<p>rpm -Va \u68c0\u67e5\u7cfb\u7edf\u4e2d\u6240\u6709\u5df2\u5b89\u88c5\u7684rpm\u5305- \u5c0f\u5fc3\u4f7f\u7528<\/p>\n\n\n\n<p>rpm -Vp package.rpm \u786e\u8ba4\u4e00\u4e2arpm\u5305\u8fd8\u672a\u5b89\u88c5<\/p>\n\n\n\n<p>rpm2cpio package.rpm | cpio --extract --make-directories <em>bin<\/em> \u4ece\u4e00\u4e2arpm\u5305\u8fd0\u884c\u53ef\u6267\u884c\u6587\u4ef6<\/p>\n\n\n\n<p>rpm -ivh \/usr\/src\/redhat\/RPMS\/<code>arch<\/code>\/package.rpm \u4ece\u4e00\u4e2arpm\u6e90\u7801\u5b89\u88c5\u4e00\u4e2a\u6784\u5efa\u597d\u7684\u5305<\/p>\n\n\n\n<p>rpmbuild --rebuild package_name.src.rpm \u4ece\u4e00\u4e2arpm\u6e90\u7801\u6784\u5efa\u4e00\u4e2a rpm \u5305<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u2461\u3001YUM \u8f6f\u4ef6\u5305\u5347\u7ea7\u5668 - \uff08Fedora, RedHat\u53ca\u7c7b\u4f3c\u7cfb\u7edf\uff09<\/strong><\/h2>\n\n\n\n<p><a href=\"https:\/\/so.csdn.net\/so\/search?q=yum&amp;spm=1001.2101.3001.7020\">yum<\/a> install package_name \u4e0b\u8f7d\u5e76\u5b89\u88c5\u4e00\u4e2arpm\u5305 (\u5982: yum -y install zip unzip)<\/p>\n\n\n\n<p>yum localinstall package_name.rpm \u5c06\u5b89\u88c5\u4e00\u4e2arpm\u5305\uff0c\u4f7f\u7528\u4f60\u81ea\u5df1\u7684\u8f6f\u4ef6\u4ed3\u5e93\u4e3a\u4f60\u89e3\u51b3\u6240\u6709\u4f9d\u8d56\u5173\u7cfb<\/p>\n\n\n\n<p>yum update package_name.rpm \u66f4\u65b0\u5f53\u524d\u7cfb\u7edf\u4e2d\u6240\u6709\u5b89\u88c5\u7684rpm\u5305<\/p>\n\n\n\n<p>yum update package_name \u66f4\u65b0\u4e00\u4e2arpm\u5305<\/p>\n\n\n\n<p>yum remove package_name \u5220\u9664\u4e00\u4e2arpm\u5305<\/p>\n\n\n\n<p>yum list | grep tmux \u5217\u51fa\u6240\u6709\u53ef\u5b89\u88dd\u7684\u8f6f\u4ef6\u6e05\u5355\u547d\u4ee4<\/p>\n\n\n\n<p>yum search package_name \u5728rpm\u4ed3\u5e93\u4e2d\u641c\u5bfb\u8f6f\u4ef6\u5305<\/p>\n\n\n\n<p>yum clean packages \u6e05\u7406rpm\u7f13\u5b58\u5220\u9664\u4e0b\u8f7d\u7684\u5305<\/p>\n\n\n\n<p>yum clean headers \u5220\u9664\u6240\u6709\u5934\u6587\u4ef6<\/p>\n\n\n\n<p>yum clean all \u5220\u9664\u6240\u6709\u7f13\u5b58\u7684\u5305\u548c\u5934\u6587\u4ef6<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u2462\u3001DEB \u5305 (Debian, Ubuntu \u4ee5\u53ca\u7c7b\u4f3c\u7cfb\u7edf)<\/strong><\/h2>\n\n\n\n<p>dpkg -i package.deb \u5b89\u88c5\/\u66f4\u65b0\u4e00\u4e2a deb \u5305<\/p>\n\n\n\n<p>dpkg -r package_name \u4ece\u7cfb\u7edf\u5220\u9664\u4e00\u4e2a deb \u5305<\/p>\n\n\n\n<p>dpkg -l \u663e\u793a\u7cfb\u7edf\u4e2d\u6240\u6709\u5df2\u7ecf\u5b89\u88c5\u7684 deb \u5305<\/p>\n\n\n\n<p>dpkg -l | grep httpd \u663e\u793a\u6240\u6709\u540d\u79f0\u4e2d\u5305\u542b \"httpd\" \u5b57\u6837\u7684deb\u5305<\/p>\n\n\n\n<p>dpkg -s package_name \u83b7\u5f97\u5df2\u7ecf\u5b89\u88c5\u5728\u7cfb\u7edf\u4e2d\u4e00\u4e2a\u7279\u6b8a\u5305\u7684\u4fe1\u606f<\/p>\n\n\n\n<p>dpkg -L package_name \u663e\u793a\u7cfb\u7edf\u4e2d\u5df2\u7ecf\u5b89\u88c5\u7684\u4e00\u4e2adeb\u5305\u6240\u63d0\u4f9b\u7684\u6587\u4ef6\u5217\u8868<\/p>\n\n\n\n<p>dpkg --contents package.deb \u663e\u793a\u5c1a\u672a\u5b89\u88c5\u7684\u4e00\u4e2a\u5305\u6240\u63d0\u4f9b\u7684\u6587\u4ef6\u5217\u8868<\/p>\n\n\n\n<p>dpkg -S \/bin\/ping \u786e\u8ba4\u6240\u7ed9\u7684\u6587\u4ef6\u7531\u54ea\u4e2adeb\u5305\u63d0\u4f9b<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u2463\u3001APT \u8f6f\u4ef6\u5de5\u5177 (Debian, Ubuntu \u4ee5\u53ca\u7c7b\u4f3c\u7cfb\u7edf)<\/strong><\/h2>\n\n\n\n<p>apt-get install package_name \u5b89\u88c5\/\u66f4\u65b0\u4e00\u4e2a deb \u5305<\/p>\n\n\n\n<p>apt-cdrom install package_name \u4ece\u5149\u76d8\u5b89\u88c5\/\u66f4\u65b0\u4e00\u4e2a deb \u5305<\/p>\n\n\n\n<p>apt-get update \u5347\u7ea7\u5217\u8868\u4e2d\u7684\u8f6f\u4ef6\u5305<\/p>\n\n\n\n<p>apt-get upgrade \u5347\u7ea7\u6240\u6709\u5df2\u5b89\u88c5\u7684\u8f6f\u4ef6<\/p>\n\n\n\n<p>apt-get remove package_name \u4ece\u7cfb\u7edf\u5220\u9664\u4e00\u4e2adeb\u5305<\/p>\n\n\n\n<p>apt-get check \u786e\u8ba4\u4f9d\u8d56\u7684\u8f6f\u4ef6\u4ed3\u5e93\u6b63\u786e<\/p>\n\n\n\n<p>apt-get clean \u4ece\u4e0b\u8f7d\u7684\u8f6f\u4ef6\u5305\u4e2d\u6e05\u7406\u7f13\u5b58<\/p>\n\n\n\n<p>apt-cache search searched-package \u8fd4\u56de\u5305\u542b\u6240\u8981\u641c\u7d22\u5b57\u7b26\u4e32\u7684\u8f6f\u4ef6\u5305\u540d\u79f0<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u5341\u56db\u3001\u6587\u672c\u67e5\u770b\u3001\u5904\u7406<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u2460\u3001\u67e5\u770b\u6587\u4ef6\u5185\u5bb9<\/strong><\/h2>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<p>cat file1 \u4ece\u7b2c\u4e00\u4e2a\u5b57\u8282\u5f00\u59cb\u6b63\u5411\u67e5\u770b\u6587\u4ef6\u7684\u5185\u5bb9<\/p>\n\n\n\n<p>tac file1 \u4ece\u6700\u540e\u4e00\u884c\u5f00\u59cb\u53cd\u5411\u67e5\u770b\u4e00\u4e2a\u6587\u4ef6\u7684\u5185\u5bb9<\/p>\n\n\n\n<p>more file1 \u67e5\u770b\u4e00\u4e2a\u957f\u6587\u4ef6\u7684\u5185\u5bb9<\/p>\n\n\n\n<p>less file1 \u7c7b\u4f3c\u4e8e 'more' \u547d\u4ee4\uff0c\u4f46\u662f\u5b83\u5141\u8bb8\u5728\u6587\u4ef6\u4e2d\u548c\u6b63\u5411\u64cd\u4f5c\u4e00\u6837\u7684\u53cd\u5411\u64cd\u4f5c<\/p>\n\n\n\n<p>head -2 file1 \u67e5\u770b\u4e00\u4e2a\u6587\u4ef6\u7684\u524d\u4e24\u884c<\/p>\n\n\n\n<p>tail -2 file1 \u67e5\u770b\u4e00\u4e2a\u6587\u4ef6\u7684\u6700\u540e\u4e24\u884c<\/p>\n\n\n\n<p>tail -f \/var\/log\/messages \u5b9e\u65f6\u67e5\u770b\u88ab\u6dfb\u52a0\u5230\u4e00\u4e2a\u6587\u4ef6\u4e2d\u7684\u5185\u5bb9<\/p>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u2461\u3001\u6587\u672c\u5904\u7406<\/strong><\/h2>\n\n\n\n<p>cat file1 file2 ... | command &lt;&gt; file1_in.txt_or_file1_out.txt general syntax for text manipulation using PIPE, STDIN and STDOUT<\/p>\n\n\n\n<p>cat file1 | command( sed, grep, awk, grep, etc...) &gt; result.txt \u5408\u5e76\u4e00\u4e2a\u6587\u4ef6\u7684\u8be6\u7ec6\u8bf4\u660e\u6587\u672c\uff0c\u5e76\u5c06\u7b80\u4ecb\u5199\u5165\u4e00\u4e2a\u65b0\u6587\u4ef6\u4e2d<\/p>\n\n\n\n<p>cat file1 | command( sed, grep, awk, grep, etc...) &gt;&gt; result.txt \u5408\u5e76\u4e00\u4e2a\u6587\u4ef6\u7684\u8be6\u7ec6\u8bf4\u660e\u6587\u672c\uff0c\u5e76\u5c06\u7b80\u4ecb\u5199\u5165\u4e00\u4e2a\u5df2\u6709\u7684\u6587\u4ef6\u4e2d<\/p>\n\n\n\n<p>grep Aug \/var\/log\/messages \u5728\u6587\u4ef6 '\/var\/log\/messages'\u4e2d\u67e5\u627e\u5173\u952e\u8bcd\"Aug\"<\/p>\n\n\n\n<p>grep ^Aug \/var\/log\/messages \u5728\u6587\u4ef6 '\/var\/log\/messages'\u4e2d\u67e5\u627e\u4ee5\"Aug\"\u5f00\u59cb\u7684\u8bcd\u6c47<\/p>\n\n\n\n<p>grep [0-9] \/var\/log\/messages \u9009\u62e9 '\/var\/log\/messages' \u6587\u4ef6\u4e2d\u6240\u6709\u5305\u542b\u6570\u5b57\u7684\u884c<\/p>\n\n\n\n<p>grep Aug -R \/var\/log\/* \u5728\u76ee\u5f55 '\/var\/log' \u53ca\u968f\u540e\u7684\u76ee\u5f55\u4e2d\u641c\u7d22\u5b57\u7b26\u4e32\"Aug\"<\/p>\n\n\n\n<p>grep -E 'string_1|string_2' \/var\/log\/test.log \u5728\u65e5\u5fd7\u4e2d\u540c\u65f6\u67e5\u8be2\u5305\u542b string_1\u6216\u5305\u542bstring_2\u7684\u8bb0\u5f55<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u5339\u914dredis\u4e2d, field \u4e2d\u5305\u542b\u4ee51\u52304\u4f4d\u6570\u5b57\u5f00\u5934,\u4ee5\"_\u5df2\u4e0b\u5355\"\u7ed3\u5c3e\u7684\u5b57\u7b26, \u5e76\u5c06\u5176 value \u503c\u5e26\u51fa\u6765(-A1)<br>redis-cli -h 111.111.111.111 -p 7001 -c -a ${PASSWORD} --raw hgetall 2022-03-24_ORDER_STAT | grep -E \"^[[:digit:]]{1,4}_\u5df2\u4e0b\u5355\" -A1<\/pre>\n\n\n\n<p>grep -Hnr docker * \u5728\u672c\u5c42\u6216\u5b50\u6587\u4ef6\u5939\u91cc\u9012\u5f52\u67e5\u627e\u5305\u542b\u6307\u5b9a\u5b57\u7b26\u201cdocker\u201d\u7684\u6587\u4ef6\uff0c\u5e76\u663e\u793a\u6587\u4ef6\u540d+\u884c\u53f7\uff0c\u5982\u679c\u7cbe\u786e\u5339\u914d\u6587\u672c\uff0c\u52a0o\u53c2\u6570\u3002\u53c2\u6570\u542b\u4e49\uff1a\uff08H\uff1a\u6bcf\u6b21\u5339\u914d\u65f6\u5c06\u6587\u4ef6\u540d\u6253\u5370\u51fa\u6765\uff1bn\uff1a\u6253\u5370\u5b57\u7b26\u4e32\u6240\u5728\u7684\u884c\u53f7\uff1br\uff1a\u9012\u5f52\u67e5\u627e\uff1bo\uff1a\u7cbe\u786e\u5339\u914d\u5230\u5355\u8bcd\uff0c\u591a\u4e00\u4e2a\u5b57\u7b26\u90fd\u4e0d\u884c\uff09<\/p>\n\n\n\n<p>\u201cgrep\u663e\u793a\u5339\u914d\u884c\u7684\u4e0a\u4e0b\u884c\u5185\u5bb9\u201d\u4e13\u9898\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">grep -A2 2 test.txt  \u8fd4\u56de\u5339\u914d\u884c\u548c\u5339\u914d\u884c\u7684\u540e\u4e24\u884c<br> <br>grep -B2 2 test.txt  \u8fd4\u56de\u5339\u914d\u884c\u548c\u5339\u914d\u884c\u7684\u524d\u4e24\u884c<br> <br>grep -C2 2 text.txt \u6216\u8005 grep -A2 -B2 2 test.txt \u8fd4\u56de\u5339\u914d\u884c\u548c\u5339\u914d\u884c\u7684\u524d\u540e\u4e24\u884c<br> <br>-A -B -C \u540e\u9762\u8ddf\u963f\u62c9\u4f2f\u6570\u5b57<br>-A \u8fd4\u56de\u5339\u914d\u540e\u548c\u5b83\u540e\u9762\u7684n\u884c,(After\uff0c\u4e4b\u540e)\u3002<br>-B \u8fd4\u56de\u5339\u914d\u884c\u548c\u5b83\u524d\u9762\u7684n\u884c,(Before\uff0c\u4e4b\u524d)\u3002<br>-C \u8fd4\u56de\u5339\u914d\u884c\u548c\u5b83\u524d\u540e\u5404n\u884c\uff0c\u901a-A\u548c-B\u8054\u7528,(Context\uff0c\u4e0a\u4e0b\u6587\u5373\u524d\u540e)\u3002<\/pre>\n\n\n\n<p>sed -i 's\/string1\/string2\/g' example.txt \u5c06example.txt\u6587\u4ef6\u4e2d\u7684 \"string1\" \u66ff\u6362\u6210 \"string2\"(\u5982\u679c\u4e0d\u52a0-i\u53c2\u6570,\u5219\u5728\u5185\u5b58\u4e2d\u66ff\u6362; \u6dfb\u52a0-i\u53c2\u6570,\u5219\u5728\u6587\u4ef6\u4e2d\u76f4\u63a5\u66ff\u6362)<\/p>\n\n\n\n<p>sed '\/^$\/d' example.txt \u4eceexample.txt\u6587\u4ef6\u4e2d\u5220\u9664\u6240\u6709\u7a7a\u767d\u884c<\/p>\n\n\n\n<p>sed '\/ *#\/d; \/^$\/d' example.txt \u4eceexample.txt\u6587\u4ef6\u4e2d\u5220\u9664\u6240\u6709\u6ce8\u91ca\u548c\u7a7a\u767d\u884c<\/p>\n\n\n\n<p>echo 'hElloWorld' | tr '[:lower:]' '[:upper:]' \u627e\u51fa\u6240\u6709\u7684\u5c0f\u5199\u5b57\u6bcd\u5e76\u5168\u90e8\u66ff\u6362\u4e3a\u5927\u5199\u5b57\u6bcd<\/p>\n\n\n\n<p>sed -e '1d' result.txt \u4ece\u6587\u4ef6example.txt \u4e2d\u6392\u9664\u7b2c\u4e00\u884c<\/p>\n\n\n\n<p>sed -n '\/string1\/p' \u67e5\u770b\u53ea\u5305\u542b\u8bcd\u6c47 \"string1\"\u7684\u884c<\/p>\n\n\n\n<p>sed -e 's\/ *$\/\/' example.txt \u5220\u9664\u6bcf\u4e00\u884c\u6700\u540e\u7684\u7a7a\u767d\u5b57\u7b26<\/p>\n\n\n\n<p>sed -e 's\/string1\/\/g' example.txt \u4ece\u6587\u6863\u4e2d\u53ea\u5220\u9664\u8bcd\u6c47 \"string1\" \u5e76\u4fdd\u7559\u5269\u4f59\u5168\u90e8<\/p>\n\n\n\n<p>sed -n '1,5p;5q' example.txt \u67e5\u770b\u4ece\u7b2c\u4e00\u884c\u5230\u7b2c5\u884c\u5185\u5bb9<\/p>\n\n\n\n<p>sed -n '5p;5q' example.txt \u67e5\u770b\u7b2c5\u884c<\/p>\n\n\n\n<p>sed -e 's\/00*\/0\/g' example.txt \u7528\u5355\u4e2a\u96f6\u66ff\u6362\u591a\u4e2a\u96f6<\/p>\n\n\n\n<p>sed -i '3i helloword' test.txt \u5728test.txt\u6587\u4ef6\u7684\u7b2c\u4e09\u884c\u63d2\u5165\u2018helloword\u2019\u5b57\u7b26\u4e32<\/p>\n\n\n\n<p>\u201csed\u6309\u6307\u5b9a\u5b57\u7b26\u4e32\u5220\u9664\u201d\u4e13\u9898\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u7528sed\u5220\u9664\u5339\u914d\u5230\u5b57\u7b26\u4e32\u7684\u884c\uff1a<\/p>\n\n\n\n<p>\u8bed\u6cd5\uff1ased-i'\/\u5173\u952e\u5b57\u7b26\/d'\u6587\u4ef6\u540d<\/p>\n\n\n\n<p>\u4e3e\u4f8b1\uff1a\u5339\u914d\"\\etc\\install.sh\"<\/p>\n\n\n\n<p>set -i '\/\\\/etc\\\/install.sh\/d' 1.txt<\/p>\n\n\n\n<p>\/ \u641c\u7d22<\/p>\n\n\n\n<p>\u5339\u914d\\\/etc\\\/install.sh\uff0c\u5c31\u662f\u201c\/etc\/install.sh\u201d<\/p>\n\n\n\n<p>-i \u8868\u793a\u64cd\u4f5c\u5728\u6e90\u6587\u4ef6\u4e0a\u751f\u6548.\u5426\u5219\u64cd\u4f5c\u5185\u5b58\u4e2d\u6570\u636e,\u5e76\u4e0d\u5199\u5165\u6587\u4ef6\u4e2d.<\/p>\n\n\n\n<p>\u5728\u5206\u53f7\u5185\u7684\/d\u8868\u793a\u5220\u9664\u5339\u914d\u7684\u884c\u3002<\/p>\n\n\n\n<p>\u4e3e\u4f8b2\uff1a<\/p>\n\n\n\n<p>\u5220\u9664\u4ee5a\u5f00\u5934\u7684\u884c<\/p>\n\n\n\n<p>sed -i '\/^a.*\/d' tmp.txt<\/p>\n\n\n\n<p>^a\u8868\u793a\u5f00\u5934\u662fa, .*\u8868\u793a\u540e\u8ddf\u4efb\u610f\u5b57\u7b26\u4e32<\/p>\n<\/blockquote>\n\n\n\n<p>Example-1: \u4f7f\u7528sed\u8fdb\u884c\u6587\u672c\u6279\u91cf\u66ff\u6362<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash<br> <br>ddl_file_path=\/c\/Users\/user\/Downloads\/sqoop_data\/hive_2_mysql<br> <br> <br>ls $ddl_file_path | while read f;<br>do<br>echo \"---------&gt;\"$ddl_file_path\/$f<br> <br>## Template<br>#sed -i 's\/\/\/g' $ddl_file_path\/$f<br>#sed -i \"s\/\/\/g\" $ddl_file_path\/$f<br> <br>sed -i 's\/111.111.111.111:3306\/222.222.222.222:3307\/g' $ddl_file_path\/$f<br>sed -i \"s\/'password_1'\/'password_2'\/g\" $ddl_file_path\/$f<br> <br>done<br> <br># echo -e \"=========&gt;\\n\\t Files contains keyword \"\/WARN:\" in path $ddl_file_path are deleted!!!\"<br>#!\/bin\/bash<br> <br>set -x<br> <br>## Template<br>#sed -i 's\/\/\/g' $ddl_file_path\/$f<br>#sed -i \"s\/\/\/g\" $ddl_file_path\/$f<br> <br>## Func 1 - \u5b9e\u73b0\u5728\u6240\u6709\u6587\u4ef6\u7684\u7b2c\u56db\u884c\u3001\u7b2c\u4e94\u884c\u63d2\u5165\u6307\u5b9a\u6587\u672c<br> <br>ddl_file_path=\/e\/\u8fc5\u96f7\u4e0b\u8f7d\/user_data_after<br> <br>ls $ddl_file_path | while read f;<br>do &nbsp; &nbsp;<br> &nbsp; &nbsp;# \u5982\u679c\u6587\u4ef6\u4e0d\u662f\u6587\u4ef6\u5939\u7c7b\u578b\uff0c\u624d\u5141\u8bb8\u63d2\u5165\u64cd\u4f5c<br> &nbsp; &nbsp;if &#91; ! -d $f ];then<br> &nbsp; &nbsp; &nbsp; &nbsp;echo \"---------&gt;\"$ddl_file_path\/$f<br> <br> &nbsp; &nbsp; &nbsp; &nbsp;sed -i '4i retries=10' $ddl_file_path\/$f<br> &nbsp; &nbsp; &nbsp; &nbsp;sed -i '5i retry.backoff=3' $ddl_file_path\/$f<br> &nbsp; &nbsp;fi<br>done<br> <br> <br>## Func 2 - \u5982\u679c\u6587\u4ef6\u5939\u4e0d\u5b58\u5728\uff0c\u5219\u521b\u5efa\uff1b\u53cd\u4e4b\u63d0\u793a\u6587\u4ef6\u5df2\u5b58\u5728<br> <br>if &#91; ! -d \"beijing\" ];then<br> &nbsp; &nbsp;mkdir beijing<br>else<br> &nbsp; &nbsp;echo \"File already exists\"<br>fi<\/code><\/pre>\n\n\n\n<p>\u6587\u4ef6\u7c7b\u578b\u7684\u53c2\u6570\u5224\u522b\u5927\u5168\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>shell\u811a\u672c\u5224\u65ad\u6587\u4ef6\u7c7b\u578b<br> <br>shell\u5224\u65ad\u6587\u4ef6,\u76ee\u5f55\u662f\u5426\u5b58\u5728\u6216\u8005\u5177\u6709\u6743\u9650 <br>#!\/bin\/sh <br> <br>myPath=\"\/var\/log\/httpd\/\" <br>myFile=\"\/var\/log\/httpd\/access.log\" <br> <br># \u8fd9\u91cc\u7684-x \u53c2\u6570\u5224\u65ad$myPath\u662f\u5426\u5b58\u5728\u5e76\u4e14\u662f\u5426\u5177\u6709\u53ef\u6267\u884c\u6743\u9650 <br>if &#91; ! -x \"$myPath\"]; then <br>mkdir \"$myPath\" <br> fi <br> <br> # \u8fd9\u91cc\u7684-d \u53c2\u6570\u5224\u65ad$myPath\u662f\u5426\u5b58\u5728 <br> if &#91; ! -d \"$myPath\"]; then <br> mkdir \"$myPath\" <br> fi <br> <br> # \u8fd9\u91cc\u7684-f\u53c2\u6570\u5224\u65ad$myFile\u662f\u5426\u5b58\u5728 <br> if &#91; ! -f \"$myFile\" ]; then <br> touch \"$myFile\" <br> fi <br> <br> # \u5176\u4ed6\u53c2\u6570\u8fd8\u6709-n,-n\u662f\u5224\u65ad\u4e00\u4e2a\u53d8\u91cf\u662f\u5426\u662f\u5426\u6709\u503c <br> if &#91; ! -n \"$myVar\" ]; then <br> echo \"$myVar is empty\" <br> exit 0 <br> fi <br> <br> # \u4e24\u4e2a\u53d8\u91cf\u5224\u65ad\u662f\u5426\u76f8\u7b49 <br> if &#91; \"$var1\" = \"$var2\" ]; then <br> echo '$var1 eq $var2' <br> else <br> echo '$var1 not eq $var2' <br> fi <br> <br>\u6587\u4ef6\u7684\u5224\u522b\u903b\u8f91\u5927\u5168\uff1a<br>--------------------------------------------------------------------<br>-a file exists. <br>-b file exists and is a block special file. <br>-c file exists and is a character special file. <br>-d file exists and is a directory. <br>-e file exists (just the same as -a). <br>-f file exists and is a regular file. <br>-g file exists and has its setgid(2) bit set. <br>-G file exists and has the same group ID as this process. <br>-k file exists and has its sticky bit set. <br>-L file exists and is a symbolic link. <br>-n string length is not zero. <br>-o Named option is set on. <br>-O file exists and is owned by the user ID of this process. <br>-p file exists and is a first in, first out (FIFO) special file or <br>named pipe. <br>-r file exists and is readable by the current process. <br>-s file exists and has a size greater than zero. <br>-S file exists and is a socket. <br>-t file descriptor number fildes is open and associated with a <br>terminal device. <br>-u file exists and has its setuid(2) bit set. <br>-w file exists and is writable by the current process. <br>-x file exists and is executable by the current process. <br>-z string length is zero. <br> <br>\u6ce8\u610f-s \u548c -f \u53c2\u6570\u7684\u533a\u522b<\/code><\/pre>\n\n\n\n<p>cat -n file1 \u6807\u793a\u6587\u4ef6\u7684\u884c\u6570<\/p>\n\n\n\n<p>cat example.txt | awk 'NR%2==1' \u5220\u9664example.txt\u6587\u4ef6\u4e2d\u7684\u6240\u6709\u5076\u6570\u884c<\/p>\n\n\n\n<p>echo a b c | awk '{print $1}' \u67e5\u770b\u4e00\u884c\u7b2c\u4e00\u680f<\/p>\n\n\n\n<p>echo a b c | awk '{print $1,$3}' \u67e5\u770b\u4e00\u884c\u7684\u7b2c\u4e00\u548c\u7b2c\u4e09\u680f<\/p>\n\n\n\n<p>paste file1 file2 \u5408\u5e76\u4e24\u4e2a\u6587\u4ef6\u6216\u4e24\u680f\u7684\u5185\u5bb9<\/p>\n\n\n\n<p>paste -d '+' file1 file2 \u5408\u5e76\u4e24\u4e2a\u6587\u4ef6\u6216\u4e24\u680f\u7684\u5185\u5bb9\uff0c\u4e2d\u95f4\u7528\"+\"\u533a\u5206<\/p>\n\n\n\n<p>sort file1 file2 \u6392\u5e8f\u4e24\u4e2a\u6587\u4ef6\u7684\u5185\u5bb9<\/p>\n\n\n\n<p>sort file1 file2 | uniq \u53d6\u51fa\u4e24\u4e2a\u6587\u4ef6\u7684\u5e76\u96c6(\u91cd\u590d\u7684\u884c\u53ea\u4fdd\u7559\u4e00\u4efd)<\/p>\n\n\n\n<p>sort file1 file2 | uniq -u \u5220\u9664\u4ea4\u96c6\uff0c\u7559\u4e0b\u5176\u4ed6\u7684\u884c<\/p>\n\n\n\n<p>sort file1 file2 | uniq -d \u53d6\u51fa\u4e24\u4e2a\u6587\u4ef6\u7684\u4ea4\u96c6(\u53ea\u7559\u4e0b\u540c\u65f6\u5b58\u5728\u4e8e\u4e24\u4e2a\u6587\u4ef6\u4e2d\u7684\u6587\u4ef6)<\/p>\n\n\n\n<p>comm -1 file1 file2 \u6bd4\u8f83\u4e24\u4e2a\u6587\u4ef6\u7684\u5185\u5bb9\u53ea\u5220\u9664 'file1' \u6240\u5305\u542b\u7684\u5185\u5bb9<\/p>\n\n\n\n<p>comm -2 file1 file2 \u6bd4\u8f83\u4e24\u4e2a\u6587\u4ef6\u7684\u5185\u5bb9\u53ea\u5220\u9664 'file2' \u6240\u5305\u542b\u7684\u5185\u5bb9<\/p>\n\n\n\n<p>comm -3 file1 file2 \u6bd4\u8f83\u4e24\u4e2a\u6587\u4ef6\u7684\u5185\u5bb9\u53ea\u5220\u9664\u4e24\u4e2a\u6587\u4ef6\u5171\u6709\u7684\u90e8\u5206<\/p>\n\n\n\n<p>\u7efc\u5408\u6848\u4f8b:<\/p>\n\n\n\n<p>\u2460\uff1a\u672c\u673atcp\u5404\u79cd\u72b6\u6001\u6570\u7edf\u8ba1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>netstat -n | awk '\/^tcp\/ {++S&#91;$NF]} END {for(a in S) print a, S&#91;a]}'<br>CLOSE_WAIT 2<br>ESTABLISHED 276<br>SYN_SENT 2<br>TIME_WAIT 63270<br> <br> <br>awk 'BEGIN {<br> &nbsp; sum = 0; for (i = 0; i &lt; 20; ++i) {<br> &nbsp; &nbsp;  sum += i; if (sum &gt; 50) exit(10); else print \"Sum =\", sum <br> &nbsp; } <br>}'<\/code><\/pre>\n\n\n\n<p>\u2461\uff1a\u4f7f\u7528cut\u63d0\u53d6\u6587\u672c\u5b57\u7b26\u4e32\uff1a<\/p>\n\n\n\n<p>\u6309\u201c:\u201d\u5206\u5272\uff0c\u63d0\u53d6\/etc\/passwd\u4e2d\u7b2c1,3,4,5\u5217\u6570\u636e\uff0c\u6309\u539f\u5206\u9694\u7b26\":\"\u8fdb\u884c\u62fc\u63a5\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;hdfs@cdh01 test]$ head -n 5 \/etc\/passwd | cut -d : -f 1,3-5<br>root:0:0:root<br>bin:1:1:bin<br>daemon:2:2:daemon<br>adm:3:4:adm<br>xixi:4:7:xixi<\/code><\/pre>\n\n\n\n<p>\u2462\uff1a\u4f7f\u7528uniq\u8fdb\u884c\u6ee4\u91cd<\/p>\n\n\n\n<p>cut\u7684\u5177\u4f53\u7528\u6cd5\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>A).\u53bb\u9664\u91cd\u590d\u884c sort target_file | uniq<\/p>\n\n\n\n<p>B).\u67e5\u627e\u975e\u91cd\u590d\u884c sort target_file | uniq -u<\/p>\n\n\n\n<p>C).\u67e5\u627e\u91cd\u590d\u884c sort target_file | uniq -d<\/p>\n\n\n\n<p>D).\u7edf\u8ba1\u6bcf\u4e00\u4e2a\u6587\u4ef6\u51fa\u73b0\u7684\u6b21\u6570 sort target_file | uniq -c<\/p>\n<\/blockquote>\n\n\n\n<p>\u2463\uff1a\u6392\u5e8f<\/p>\n\n\n\n<p>sort linux\u4e0b\u7684\u6392\u5e8f\u5de5\u5177<\/p>\n\n\n\n<p>\u53c2\u6570\u8bf4\u660e:<\/p>\n\n\n\n<ul>\n<li>-r\u3000\u3000\u964d\u5e8f\u6392\u5217<\/li>\n\n\n\n<li>-u\u3000\u3000\u53bb\u91cd<\/li>\n\n\n\n<li>-n\u3000\u3000\u4ee5\u6570\u5b57\u5927\u5c0f\u6392\u5e8f(\u9ed8\u8ba4\u662f\u9996\u5b57\u6bcd\u6392\u5e8f)<\/li>\n\n\n\n<li>-t\u3000\u3000\u6307\u5b9a\u5206\u9694\u7b26 \u8fd9\u91cc\u6211\u4eec\u6307\u5b9a'|'\u4e3a\u5206\u9694\u7b26<\/li>\n\n\n\n<li>-k\u3000\u3000\u6307\u5b9a\u5206\u9694\u540e\u7684\u7b2c\u51e0\u4f4d\u8fdb\u884c\u6392\u5e8f \u8fd9\u91cc\u6211\u4eec\u6307\u5b9a\u7b2c2\u4f4d<\/li>\n<\/ul>\n\n\n\n<p>\u4efb\u52a1:report.txt\u6587\u4ef6\u91cc\u6709\u4ee5\u4e0b\u5185\u5bb9\uff1a\u8bb0\u5f55\u4e86\u4e00\u4e9b\u65b9\u6cd5\u7684\u6267\u884c\u65f6\u95f4\uff0c\u8981\u6c42\u6309\u6267\u884c\u65f6\u95f4\u964d\u5e8f\u6392\u5217.<\/p>\n\n\n\n<p>\u547d\u4ee4\uff1asort -run -k 2 -t '|' report.txt<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> 1 void com.dustpan.zeus.core.service.MergeService.startService(int)|2<br> 2 void com.dustpan.zeus.core.service.InitShopDateService.startService(int)|1<br> 3 boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|475<br> 4 boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|96<br> 5 boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|1013<br> 6 boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|184<br> 7 boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|729<br> 8 boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|14<br> 9 boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|394<br>10 boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|90<br>11 boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|569<br>12 boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|796<br>13 boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|1648<br>14 boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|82<br>15 boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|1018<br>16 boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|14<br>17 boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|937<br>18 boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|17<br>19 boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|601<br>20 boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|52<br>21 boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|5081<br>22 boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|388<br>23 boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|198<br>24 boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|11<br>25 boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|203<br>26 boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|11<br>27 boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|241<br>28 boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|13<br>29 boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|176<br>30 boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|12<br>31 boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|206<br>32 boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|33<br>33 boolean com.dustpan.zeus.core.service.MergeService.executeGePrintSyncTask()|242<br>34 boolean com.dustpan.zeus.core.service.InitShopDateService.executeInitShopTask()|19<\/code><\/pre>\n\n\n\n<p>\u6848\u4f8b\u4e00\u3001\u627e\u51fa\u672c\u6587\u4ef6\u5939\u4e2d\u5305\u542bmy_test_calendar\u5173\u952e\u5b57\u7684\u6240\u6709\u6587\u4ef6(\u542b\u5168\u8def\u5f84+\u6587\u4ef6\u540d)\uff0c\u5e76\u6ee4\u91cd\u3002<\/p>\n\n\n\n<p>\u67e5\u8be2hive_sh\u76ee\u5f55\u4e0b\uff0c\u5305\u542b\u641c\u7d22\u5173\u952e\u5b57'my_test_calendar'\u7684\u6587\u672c\u51fa\u73b0\u7684\u6587\u4ef6\u53ca\u5173\u952e\u5b57\u6240\u5728\u7684\u884c\uff0c\u5c06\u6587\u4ef6(\u6587\u4ef6\u8def\u5f84+\u6587\u4ef6\u540d) \u5b57\u6bb5\u63d0\u53d6\u51fa\u6765\uff0c\u5e76\u505a\u6ee4\u91cd\u5904\u7406\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;hdfs@nn1 hive_sh]$ find . -type f | xargs grep -rn 'my_test_calendar' | cut -d : -f 1 | uniq<\/code><\/pre>\n\n\n\n<p>\u6848\u4f8b\u4e8c\u3001\u67e5\u627e\u6240\u6709\u51fa\u73b0\u6307\u5b9a\u6587\u672c\u7684\u6587\u4ef6\u5e76\u6ee4\u91cd\uff08\u8fdb\u9636\u7248\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#### # \u811a\u672c\u8bf4\u660e\n####\n#### \u904d\u5386 hive_tables.txt \u6587\u4ef6\u4e2d\u7684\u6240\u6709\u8868\uff08\u5982 hive_table_1\uff09,\u67e5\u627e\u5176\u5728\u6307\u5b9a\u76ee\u5f55\/data\/program\/hive_sh\/\u4e0b\u7684\u6587\u4ef6\u4e2d\uff0c\u662f\u5426\u4f7f\u7528\u5230\u3002\u5982\u679c\u67e5\u5230\u91cd\u590d\u51fa\u73b0\u8be5\u6587\u672c\u7684\u6587\u4ef6\uff0c\u505a\u6ee4\u91cd\u5904\u7406\u3002\n \n####\n#### cat query_table_usage_in_hive.sh \n#### -----------------------------------------------\n \n#!\/bin\/bash\n \nwhile read tbl\ndo\n \necho ------------------Handle table: $tbl--------------\nfind \/data\/program\/hive_sh\/ -type f | xargs grep -rn $tbl | cut -d : -f 1 | uniq > .\/output\/${tbl}_result.txt\n \ndone &lt; hive_tables.txt<\/code><\/pre>\n\n\n\n<p>\u6848\u4f8b\u4e09\u3001\u67e5\u627e\u5185\u5b58\u8017\u7528top3\u7684app<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ps auxw | head -1;ps auxw|sort -rn -k4|head -5<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u5341\u4e94\u3001vim\u4e13\u9898<\/strong><\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">\u2460\u3001\u5927\u5c0f\u5199\u8f6c\u6362<\/h2>\n\n\n\n<p>\uff1a <a href=\"https:\/\/blog.csdn.net\/guowake\/article\/details\/2217086\">vim\u5927\u5c0f\u5199\u8f6c\u6362<em>\u90ed\u8000\u4eca -- \u84dd\u5929\u767d\u4e91-CSDN\u535a\u5ba2<\/em>vim\u5927\u5199\u8f6c\u5c0f\u5199<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u2461\u3001\u5b57\u7b26\u4e32\u5904\u7406\u4e13\u9898<\/h2>\n\n\n\n<p>\u603b\u7ed3:<\/p>\n\n\n\n<p><strong>\u6390\u5934<\/strong>(\u5220\u5de6\u4fa7: \u2460#:\u5220\u5de6\u4fa7;\u2461##:\u8d2a\u5a6a\u5220\u5de6\u4fa7)<strong>\u53bb\u5c3e<\/strong>(\u5220\u53f3\u4fa7: \u2460%:\u5220\u53f3\u8fb9;\u2461%%:\u8d2a\u5a6a\u5220\u53f3\u4fa7)<\/p>\n\n\n\n<p>1\u3001<a href=\"https:\/\/www.cnblogs.com\/gaochsh\/p\/6901809.html\">linux shell \u5b57\u7b26\u4e32\u64cd\u4f5c\u8be6\u89e3 \uff08\u957f\u5ea6\uff0c\u8bfb\u53d6\uff0c\u66ff\u6362\uff0c\u622a\u53d6\uff0c\u8fde\u63a5\uff0c\u5bf9\u6bd4\uff0c\u5220\u9664\uff0c\u4f4d\u7f6e \uff09<\/a><\/p>\n\n\n\n<p>2\u3001<a href=\"https:\/\/www.cnblogs.com\/Bighua\/archive\/2017\/09\/18\/7542328.html\">Linux Bash Shell\u5b57\u7b26\u4e32\u622a\u53d6<\/a><\/p>\n\n\n\n<p>3\u3001<a href=\"https:\/\/www.cnblogs.com\/liuyihua1992\/p\/10989522.html\">Shell \u622a\u53d6\u5b57\u7b26\u4e32<\/a><\/p>\n\n\n\n<p>4\u3001<a href=\"https:\/\/www.cnblogs.com\/zwgblog\/p\/6031256.html\">shell\u811a\u672c\u5b57\u7b26\u4e32\u622a\u53d6\u76848\u79cd\u65b9\u6cd5<\/a><\/p>\n\n\n\n<p>\\5. <a href=\"https:\/\/baijiahao.baidu.com\/s?id=1606425493933114713&amp;wfr=spider&amp;for=pc\">Linux-shell\u811a\u672c\u5b57\u7b26\u4e32\u622a\u53d6<\/a><\/p>\n\n\n\n<p>\\6. <a href=\"https:\/\/blog.csdn.net\/wangzhaotongalex\/article\/details\/73321766\">linux\u4e2dshell\u53d8\u91cf$#,$@,$0,$1,$2\u7684\u542b\u4e49\u89e3\u91ca\/Shell\u4e2d\u7684${}\u3001##\u548c%%\u4f7f\u7528\u8303\u4f8b\/export<\/a><\/p>\n\n\n\n<p>7.<a href=\"https:\/\/blog.csdn.net\/zhan570556752\/article\/details\/80515376?depth_1-utm_source=distribute.pc_relevant.none-task&amp;utm_source=distribute.pc_relevant.none-task\">Shell \u547d\u4ee4\u4e2d\u7684\u7279\u6b8a\u66ff\u6362\u3001\u6a21\u5f0f\u5339\u914d\u66ff\u6362\u3001\u5b57\u7b26\u4e32\u63d0\u53d6\u548c\u66ff\u6362<\/a><\/p>\n\n\n\n<p>8.<a href=\"https:\/\/blog.csdn.net\/ytffhew\/article\/details\/83536636\">shell\u53d8\u91cf\u91cc\u7684\u5b57\u7b26\u66ff\u6362<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u2462\u3001vi\u4e2d\u6587\u672c\u64cd\u4f5c<\/h2>\n\n\n\n<p><strong>vi\/vim \u4e2d\u5728\u6bcf\u884c\u884c\u9996\u6216\u884c\u5c3e\u63d2\u5165\u6307\u5b9a\u5b57\u7b26\u4e32<\/strong><\/p>\n\n\n\n<p>\u884c\u9996 :%s\/^\/your_word\/ \u884c\u5c3e :%s\/$\/your_word\/<\/p>\n\n\n\n<p>\u6309\u952e\u64cd\u4f5c\uff1a<\/p>\n\n\n\n<p>\u6ce8\u91ca(<strong>\u5217\u6a21\u5f0f<\/strong>\u65b9\u5f0f)\uff1actrl+v \u8fdb\u5165\u5217\u7f16\u8f91\u6a21\u5f0f,\u5411\u4e0b\u6216\u5411\u4e0a\u79fb\u52a8\u5149\u6807,\u628a\u9700\u8981\u6ce8\u91ca\u7684\u884c\u7684\u5f00\u5934\u6807\u8bb0\u8d77\u6765,\u7136\u540e\u6309\u5927\u5199\u7684I,\u518d\u63d2\u5165\u6ce8\u91ca\u7b26,\u6bd4\u5982\u201d#\u201d,\u518d\u6309Esc,\u5c31\u4f1a\u5168\u90e8\u6ce8\u91ca\u4e86\u3002<\/p>\n\n\n\n<p>\u5220\u9664\uff1a\u5148\u6309v,\u8fdb\u5165visual\u6a21\u5f0f,\u6a2a\u5411\u9009\u4e2d\u5217\u7684\u4e2a\u6570(\u5982\u201d#\u201d\u6ce8\u91ca\u7b26\u53f7,\u9700\u8981\u9009\u4e2d\u4e24\u5217),\u518d\u6309Esc,\u518d\u6309ctrl+v \u8fdb\u5165\u5217\u7f16\u8f91\u6a21\u5f0f,\u5411\u4e0b\u6216\u5411\u4e0a\u79fb\u52a8\u5149\u6807,\u9009\u4e2d\u6ce8\u91ca\u90e8\u5206,\u7136\u540e\u6309d, \u5c31\u4f1a\u5220\u9664\u6ce8\u91ca\u7b26\u53f7\uff08#\uff09\u3002<\/p>\n\n\n\n<p>PS\uff1a\u5f53\u7136\u4e0d\u4e00\u5b9a\u662fshell\u7684\u6ce8\u91ca\u7b26\u201d#\u201d\uff0c\u4e5f\u53ef\u4ee5\u662f\u201d\/\/\u201d\uff0c\u6216\u8005\u5176\u4ed6\u4efb\u610f\u7684\u5b57\u7b26\uff1bvim\u624d\u4e0d\u77e5\u9053\u4ec0\u4e48\u662f\u6ce8\u91ca\u7b26\u5462\uff0c\u90fd\u662f\u5b57\u7b26\u800c\u5df2\u3002<\/p>\n\n\n\n<p>\u6848\u4f8b:<\/p>\n\n\n\n<p><a href=\"https:\/\/www.cnblogs.com\/wangiqngpei557\/p\/11105846.html\">vim \u5217\u7f16\u8f91\u6a21\u5f0f<\/a><\/p>\n\n\n\n<p>\u4f7f\u7528\u66ff\u6362\u547d\u4ee4\uff1a<\/p>\n\n\n\n<p>\u66ff\u6362\u547d\u4ee4\u8bed\u6cd5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">:[addr]s\/\u6e90\u5b57\u7b26\u4e32\/\u76ee\u6807\u5b57\u7b26\u4e32\/[option]<\/pre>\n\n\n\n<p>\u5168\u5c40\u66ff\u6362\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">:%s\/\u6e90\u5b57\u7b26\u4e32\/\u76ee\u6807\u5b57\u7b26\u4e32\/g<\/pre>\n\n\n\n<p>\u53c2\u6570\u8bf4\u660e\uff1a<\/p>\n\n\n\n<ul>\n<li>[addr]\u2014\u2014\u8868\u793a\u68c0\u7d22\u8303\u56f4\uff0c\u7701\u7565\u65f6\u8868\u793a\u5f53\u524d\u884c\u3002\n<ul>\n<li>\"%\"\uff1a\u8868\u793a\u6574\u4e2a\u6587\u4ef6\uff0c\u540c\"1,$\"\uff1b<\/li>\n\n\n\n<li>\".,$\"\uff1a\u4ece\u5f53\u524d\u884c\u5230\u6587\u4ef6\u5c3e\uff1b<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>s\uff1a\u8868\u793a\u66ff\u6362\u64cd\u4f5c<\/li>\n\n\n\n<li>[option]\uff1a\u8868\u793a\u64cd\u4f5c\u7c7b\u578b\n<ul>\n<li>g\uff1a\u5168\u5c40\u66ff\u6362<\/li>\n\n\n\n<li>c\uff1a\u8868\u793a\u8fdb\u884c\u786e\u8ba4<\/li>\n\n\n\n<li>p\uff1a\u8868\u793a\u66ff\u6362\u7ed3\u679c\u9010\u884c\u663e\u793a\uff08Ctrl+L\u6062\u590d\u5c4f\u5e55\uff09<\/li>\n\n\n\n<li>\u7701\u7565option\uff1a\u9ed8\u8ba4\u4ec5\u5bf9\u6bcf\u884c\u7b2c\u4e00\u4e2a\u5339\u914d\u4e32\u8fdb\u884c\u66ff\u6362<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u5982\u679c\u5728\u6e90\u5b57\u7b26\u4e32\u548c\u76ee\u6807\u5b57\u7b26\u4e32\u4e2d\u6709\u7279\u6b8a\u5b57\u7b26\uff0c\u9700\u8981\u4f7f\u7528\u201c\\\u201d\u8f6c\u4e49<\/li>\n<\/ul>\n\n\n\n<p>\u4e3e\u4f8b\uff1a<\/p>\n\n\n\n<p>\u5728\u5168\u90e8\u5185\u5bb9\u7684\u884c\u9996\u6dfb\u52a0\/\/\u53f7\u6ce8\u91ca :% s\/^\/\\\/\\\/\/g<\/p>\n\n\n\n<p>\u57282~50\u884c\u9996\u6dfb\u52a0\/\/\u53f7\u6ce8\u91ca :2,50 s\/^\/\\\/\\\/\/g<\/p>\n\n\n\n<p>\u57282~50\u884c\u9996\u5220\u9664\/\/\u53f7 :2,50 s\/^\\\/\\\/\/\/g<\/p>\n\n\n\n<p>\u5168\u5c40\u66ff\u6362\uff08\u5168\u6587\u66ff\u6362\u3001\u5168\u90e8\u66ff\u6362\uff09\uff1a<\/p>\n\n\n\n<p>:%s\/\u539f\u5b57\u7b26\/\u5e0c\u671b\u66ff\u6362\u7684\u5b57\u7b26\/g<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u2463\u3001vim\u57fa\u7840\u64cd\u4f5c<\/h2>\n\n\n\n<p>\u5728\u547d\u4ee4\u6a21\u5f0f\u4e0b\uff1a<\/p>\n\n\n\n<p><strong>1\u3001\u586b\u5230\u6307\u5b9a\u884c\uff0c\u59825<\/strong><\/p>\n\n\n\n<p>:5<\/p>\n\n\n\n<p><strong>2\u3001\u8df3\u5230\u6700\u540e\u4e00\u884c<\/strong><\/p>\n\n\n\n<p>G\uff08shift + g\uff09<\/p>\n\n\n\n<p><strong>3\u3001\u8df3\u5230\u884c\u9996<\/strong><\/p>\n\n\n\n<p>gg<\/p>\n\n\n\n<p><strong>4\u3001\u8f6c\u5230\u7b2cN\u884c\uff0c\u5982\u7b2c7\u884c<\/strong><\/p>\n\n\n\n<p>7G<\/p>\n\n\n\n<p><strong>5\u3001\u5220\u9664\u6240\u6709\u5185\u5bb9<\/strong><\/p>\n\n\n\n<p><strong>A).\u4f7f\u7528shift+g\u8f6c\u5230\u6700\u540e\u4e00\u884c<\/strong><\/p>\n\n\n\n<p><strong>B).\u547d\u4ee4\u6a21\u5f0f\u4e0b\u8f93\u5165:1,.d<\/strong><\/p>\n\n\n\n<p>\u5f15\u7533\uff1a\u6df1\u5904\u7b2c3\u884c\u5230\u6700\u540e\u4e00\u884c<\/p>\n\n\n\n<p><strong>A).\u4f7f\u7528shift+g\u8f6c\u5230\u6700\u540e\u4e00\u884c<\/strong><\/p>\n\n\n\n<p><strong>B).\u547d\u4ee4\u6a21\u5f0f\u4e0b\u8f93\u5165:3,.d<\/strong><\/p>\n\n\n\n<p><strong>6\u3001\u5220\u9664\u5149\u6807\u6240\u5728\u5b57\u7b26<\/strong><\/p>\n\n\n\n<p>x<\/p>\n\n\n\n<p><strong>7\u3001\u5220\u9664\u8868\u8fc7\u6240\u5728\u524d\u7684\u5b57\u7b26\uff08\u5927\u5199X\uff09<\/strong><\/p>\n\n\n\n<p>X<\/p>\n\n\n\n<p><strong>8\u3001\u5220\u9664\u5230\u4e0b\u4e00\u4e2a\u5355\u8bcd\u5f00\u5934<\/strong><\/p>\n\n\n\n<p>dw<\/p>\n\n\n\n<p><strong>9\u3001\u5220\u9664\u5230\u672c\u5355\u8bcd\u672b\u5c3e<\/strong><\/p>\n\n\n\n<p>de<\/p>\n\n\n\n<p><strong>10\u3001\u5220\u9664\u5230\u672c\u5355\u8bcd\u672b\u5c3e\u5305\u62ec\u6807\u70b9\u5728\u5185<\/strong><\/p>\n\n\n\n<p>dE<\/p>\n\n\n\n<p><strong>11\u3001\u5220\u9664\u5230\u524d\u4e00\u4e2a\u5355\u8bcd<\/strong><\/p>\n\n\n\n<p>db<\/p>\n\n\n\n<p><strong>12\u3001\u5220\u9664\u5230\u524d\u4e00\u4e2a\u5355\u8bcd\u5305\u62ec\u6807\u70b9\u5728\u5185<\/strong><\/p>\n\n\n\n<p>dB<\/p>\n\n\n\n<p><strong>13\u3001\u5220\u9664\u4e00\u6574\u884c<\/strong><\/p>\n\n\n\n<p>dd<\/p>\n\n\n\n<p><strong>14\u3001\u5220\u9664\u5149\u6807\u4f4d\u7f6e\u5230\u672c\u884c\u7ed3\u5c3e<\/strong><\/p>\n\n\n\n<p>ud$<\/p>\n\n\n\n<p><strong>15\u3001\u5220\u9664\u5149\u6807\u4f4d\u7f6e\u5230\u672c\u884c\u5f00\u5934<\/strong><\/p>\n\n\n\n<p>d0<\/p>\n\n\n\n<p>\u5728vim\u4e2d \uff0c\u201c.\u201d\u5f53\u524d\u884c \uff0c\u201c1,.\u201d\u8868\u793a\u4ece\u7b2c\u4e00\u884c\u5230\u5f53\u524d\u884c \uff0c\u201cd\u201d\u5220\u9664\uff0c3dd\u4ee3\u8868\u5220\u9664\u4e09\u884c\u3002<\/p>\n\n\n\n<p><strong>16\u3001vim \u7edf\u8ba1<\/strong>\u5355\u8bcd\u5339\u914d\u6570\u91cf<\/p>\n\n\n\n<p>:%s\/hello world\/&amp;\/gn<\/p>\n\n\n\n<p>\u4e0a\u53e5\u7edf\u8ba1hello world \u5728\u5168\u6587\u51fa\u73b0\u7684\u6b21\u6570<\/p>\n\n\n\n<p>\u5982\u679c\u8981\u7edf\u8ba1\u4ece50\u884c\u5230100\u884c\uff0c\u51fa\u73b0\u7684\u6b21\u6570\uff0c\u5219\u4f7f\u7528\uff1a :50,100s\/hello world\/\/gn<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u2464\u3001shell\u811a\u672c\u4e2d\u7684\u6ce8\u91ca(\u5355\u884c\u6ce8\u91ca\/\u591a\u884c\u6ce8\u91ca)<\/h2>\n\n\n\n<p>1\u3001\u5355\u884c\u6ce8\u91ca<\/p>\n\n\n\n<p>\"#\" \u7f6e\u4e8e\u884c\u9996\u4f4d\u7f6e<\/p>\n\n\n\n<p>2\u3001\u591a\u884c\u6ce8\u91ca<\/p>\n\n\n\n<p>A) \u65b9\u5f0f\u4e00<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">:&lt;&lt;!<br># \u9700\u8981\u6ce8\u91ca\u7684\u5185\u5bb9<br>! <\/pre>\n\n\n\n<p>B) \u65b9\u5f0f\u4e8c<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">if false; then<br># \u5f85\u6ce8\u91ca\u7684\u4ee3\u7801\u5757<br>fi<\/pre>\n\n\n\n<p>C) \u65b9\u5f0f\u4e09<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">((0)) &amp;&amp; {<br># \u5f85\u6ce8\u91ca\u7684\u4ee3\u7801\u5757<br>}<\/pre>\n\n\n\n<h1 class=\"wp-block-heading\"><\/h1>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u5341\u4e94\u3001\u5b57\u7b26\u8bbe\u7f6e\u548c\u6587\u4ef6\u683c\u5f0f\u8f6c\u6362<\/strong><\/h1>\n\n\n\n<p>dos2unix filedos.txt fileunix.txt \u5c06\u4e00\u4e2a\u6587\u672c\u6587\u4ef6\u7684\u683c\u5f0f\u4eceMSDOS\u8f6c\u6362\u6210UNIX<\/p>\n\n\n\n<p>unix2dos fileunix.txt filedos.txt \u5c06\u4e00\u4e2a\u6587\u672c\u6587\u4ef6\u7684\u683c\u5f0f\u4eceUNIX\u8f6c\u6362\u6210MSDOS<\/p>\n\n\n\n<p>recode ..HTML &lt; page.txt &gt; page.html \u5c06\u4e00\u4e2a\u6587\u672c\u6587\u4ef6\u8f6c\u6362\u6210html<\/p>\n\n\n\n<p>recode -l | more \u663e\u793a\u6240\u6709\u5141\u8bb8\u7684\u8f6c\u6362\u683c\u5f0f<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u5341\u516d\u3001\u6587\u4ef6\u7cfb\u7edf\u5206\u6790<\/strong><\/h1>\n\n\n\n<p>badblocks -v \/dev\/hda1 \u68c0\u67e5\u78c1\u76d8hda1\u4e0a\u7684\u574f\u78c1\u5757<\/p>\n\n\n\n<p>fsck \/dev\/hda1 \u4fee\u590d\/\u68c0\u67e5hda1\u78c1\u76d8\u4e0alinux\u6587\u4ef6\u7cfb\u7edf\u7684\u5b8c\u6574\u6027<\/p>\n\n\n\n<p>fsck.ext2 \/dev\/hda1 \u4fee\u590d\/\u68c0\u67e5hda1\u78c1\u76d8\u4e0aext2\u6587\u4ef6\u7cfb\u7edf\u7684\u5b8c\u6574\u6027<\/p>\n\n\n\n<p>e2fsck \/dev\/hda1 \u4fee\u590d\/\u68c0\u67e5hda1\u78c1\u76d8\u4e0aext2\u6587\u4ef6\u7cfb\u7edf\u7684\u5b8c\u6574\u6027<\/p>\n\n\n\n<p>e2fsck -j \/dev\/hda1 \u4fee\u590d\/\u68c0\u67e5hda1\u78c1\u76d8\u4e0aext3\u6587\u4ef6\u7cfb\u7edf\u7684\u5b8c\u6574\u6027<\/p>\n\n\n\n<p>fsck.ext3 \/dev\/hda1 \u4fee\u590d\/\u68c0\u67e5hda1\u78c1\u76d8\u4e0aext3\u6587\u4ef6\u7cfb\u7edf\u7684\u5b8c\u6574\u6027<\/p>\n\n\n\n<p>fsck.vfat \/dev\/hda1 \u4fee\u590d\/\u68c0\u67e5hda1\u78c1\u76d8\u4e0afat\u6587\u4ef6\u7cfb\u7edf\u7684\u5b8c\u6574\u6027<\/p>\n\n\n\n<p>fsck.msdos \/dev\/hda1 \u4fee\u590d\/\u68c0\u67e5hda1\u78c1\u76d8\u4e0ados\u6587\u4ef6\u7cfb\u7edf\u7684\u5b8c\u6574\u6027<\/p>\n\n\n\n<p>dosfsck \/dev\/hda1 \u4fee\u590d\/\u68c0\u67e5hda1\u78c1\u76d8\u4e0ados\u6587\u4ef6\u7cfb\u7edf\u7684\u5b8c\u6574\u6027<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u5341\u4e03\u3001\u521d\u59cb\u5316\u4e00\u4e2a\u6587\u4ef6\u7cfb\u7edf<\/strong><\/h1>\n\n\n\n<p>mkfs \/dev\/hda1 \u5728hda1\u5206\u533a\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\u7cfb\u7edf<\/p>\n\n\n\n<p>mke2fs \/dev\/hda1 \u5728hda1\u5206\u533a\u521b\u5efa\u4e00\u4e2alinux ext2\u7684\u6587\u4ef6\u7cfb\u7edf<\/p>\n\n\n\n<p>mke2fs -j \/dev\/hda1 \u5728hda1\u5206\u533a\u521b\u5efa\u4e00\u4e2alinux ext3(\u65e5\u5fd7\u578b)\u7684\u6587\u4ef6\u7cfb\u7edf<\/p>\n\n\n\n<p>mkfs -t vfat 32 -F \/dev\/hda1 \u521b\u5efa\u4e00\u4e2a FAT32 \u6587\u4ef6\u7cfb\u7edf<\/p>\n\n\n\n<p>fdformat -n \/dev\/fd0 \u683c\u5f0f\u5316\u4e00\u4e2a\u8f6f\u76d8<\/p>\n\n\n\n<p>mkswap \/dev\/hda3 \u521b\u5efa\u4e00\u4e2aswap\u6587\u4ef6\u7cfb\u7edf<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u5341\u516b\u3001SWAP\u6587\u4ef6\u7cfb\u7edf<\/strong><\/h1>\n\n\n\n<p>mkswap \/dev\/hda3 \u521b\u5efa\u4e00\u4e2aswap\u6587\u4ef6\u7cfb\u7edf<\/p>\n\n\n\n<p>swapon \/dev\/hda3 \u542f\u7528\u4e00\u4e2a\u65b0\u7684swap\u6587\u4ef6\u7cfb\u7edf<\/p>\n\n\n\n<p>swapon \/dev\/hda2 \/dev\/hdb3 \u542f\u7528\u4e24\u4e2aswap\u5206\u533a<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u5341\u4e5d\u3001\u5907\u4efd<\/strong><\/h1>\n\n\n\n<p>dump -0aj -f \/tmp\/home0.bak \/home \u5236\u4f5c\u4e00\u4e2a '\/home' \u76ee\u5f55\u7684\u5b8c\u6574\u5907\u4efd<\/p>\n\n\n\n<p>dump -1aj -f \/tmp\/home0.bak \/home \u5236\u4f5c\u4e00\u4e2a '\/home' \u76ee\u5f55\u7684\u4ea4\u4e92\u5f0f\u5907\u4efd<\/p>\n\n\n\n<p>restore -if \/tmp\/home0.bak \u8fd8\u539f\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u5907\u4efd<\/p>\n\n\n\n<p>rsync -rogpav --delete \/home \/tmp \u540c\u6b65\u4e24\u8fb9\u7684\u76ee\u5f55<\/p>\n\n\n\n<p>rsync -rogpav -e ssh --delete \/home ip_address:\/tmp \u901a\u8fc7SSH\u901a\u9053rsync<\/p>\n\n\n\n<p>rsync -az -e ssh --delete ip_addr:\/home\/public \/home\/local \u901a\u8fc7ssh\u548c\u538b\u7f29\u5c06\u4e00\u4e2a\u8fdc\u7a0b\u76ee\u5f55\u540c\u6b65\u5230\u672c\u5730\u76ee\u5f55<\/p>\n\n\n\n<p>rsync -az -e ssh --delete \/home\/local ip_addr:\/home\/public \u901a\u8fc7ssh\u548c\u538b\u7f29\u5c06\u672c\u5730\u76ee\u5f55\u540c\u6b65\u5230\u8fdc\u7a0b\u76ee\u5f55<\/p>\n\n\n\n<p>dd bs=1M if=\/dev\/hda | gzip | ssh user@ip_addr 'dd of=hda.gz' \u901a\u8fc7ssh\u5728\u8fdc\u7a0b\u4e3b\u673a\u4e0a\u6267\u884c\u4e00\u6b21\u5907\u4efd\u672c\u5730\u78c1\u76d8\u7684\u64cd\u4f5c<\/p>\n\n\n\n<p>dd if=\/dev\/sda of=\/tmp\/file1 \u5907\u4efd\u78c1\u76d8\u5185\u5bb9\u5230\u4e00\u4e2a\u6587\u4ef6<\/p>\n\n\n\n<p>tar -Puf backup.tar \/home\/user \u6267\u884c\u4e00\u6b21\u5bf9 '\/home\/user' \u76ee\u5f55\u7684\u4ea4\u4e92\u5f0f\u5907\u4efd\u64cd\u4f5c<\/p>\n\n\n\n<p>( cd \/tmp\/local\/ &amp;&amp; tar c . ) | ssh -C user@ip_addr 'cd \/home\/share\/ &amp;&amp; tar x -p' \u901a\u8fc7ssh\u5728\u8fdc\u7a0b\u76ee\u5f55\u4e2d\u590d\u5236\u4e00\u4e2a\u76ee\u5f55\u5185\u5bb9<\/p>\n\n\n\n<p>( tar c \/home ) | ssh -C user@ip_addr 'cd \/home\/backup-home &amp;&amp; tar x -p' \u901a\u8fc7ssh\u5728\u8fdc\u7a0b\u76ee\u5f55\u4e2d\u590d\u5236\u4e00\u4e2a\u672c\u5730\u76ee\u5f55<\/p>\n\n\n\n<p>tar cf - . | (cd \/tmp\/backup ; tar xf - ) \u672c\u5730\u5c06\u4e00\u4e2a\u76ee\u5f55\u590d\u5236\u5230\u53e6\u4e00\u4e2a\u5730\u65b9\uff0c\u4fdd\u7559\u539f\u6709\u6743\u9650\u53ca\u94fe\u63a5<\/p>\n\n\n\n<p>find \/home\/user1 -name '*.txt' | xargs cp -av --target-directory=\/home\/backup\/ --parents \u4ece\u4e00\u4e2a\u76ee\u5f55\u67e5\u627e\u5e76\u590d\u5236\u6240\u6709\u4ee5 '.txt' \u7ed3\u5c3e\u7684\u6587\u4ef6\u5230\u53e6\u4e00\u4e2a\u76ee\u5f55<\/p>\n\n\n\n<p>find \/var\/log -name '*.log' | tar cv --files-from=- | bzip2 &gt; log.tar.bz2 \u67e5\u627e\u6240\u6709\u4ee5 '.log' \u7ed3\u5c3e\u7684\u6587\u4ef6\u5e76\u505a\u6210\u4e00\u4e2abzip\u5305<\/p>\n\n\n\n<p>dd if=\/dev\/hda of=\/dev\/fd0 bs=512 count=1 \u505a\u4e00\u4e2a\u5c06 MBR (Master Boot Record)\u5185\u5bb9\u590d\u5236\u5230\u8f6f\u76d8\u7684\u52a8\u4f5c<\/p>\n\n\n\n<p>dd if=\/dev\/fd0 of=\/dev\/hda bs=512 count=1 \u4ece\u5df2\u7ecf\u4fdd\u5b58\u5230\u8f6f\u76d8\u7684\u5907\u4efd\u4e2d\u6062\u590dMBR\u5185\u5bb9<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u4e8c\u5341\u3001\u5149\u76d8\u64cd\u4f5c<\/strong><\/h1>\n\n\n\n<p>cdrecord -v gracetime=2 dev=\/dev\/cdrom -eject blank=fast -force \u6e05\u7a7a\u4e00\u4e2a\u53ef\u590d\u5199\u7684\u5149\u76d8\u5185\u5bb9<\/p>\n\n\n\n<p>mkisofs \/dev\/cdrom &gt; cd.iso \u5728\u78c1\u76d8\u4e0a\u521b\u5efa\u4e00\u4e2a\u5149\u76d8\u7684iso\u955c\u50cf\u6587\u4ef6<\/p>\n\n\n\n<p>mkisofs \/dev\/cdrom | gzip &gt; cd_iso.gz \u5728\u78c1\u76d8\u4e0a\u521b\u5efa\u4e00\u4e2a\u538b\u7f29\u4e86\u7684\u5149\u76d8iso\u955c\u50cf\u6587\u4ef6<\/p>\n\n\n\n<p>mkisofs -J -allow-leading-dots -R -V \"Label CD\" -iso-level 4 -o .\/cd.iso data_cd \u521b\u5efa\u4e00\u4e2a\u76ee\u5f55\u7684iso\u955c\u50cf\u6587\u4ef6<\/p>\n\n\n\n<p>cdrecord -v dev=\/dev\/cdrom cd.iso \u523b\u5f55\u4e00\u4e2aISO\u955c\u50cf\u6587\u4ef6<\/p>\n\n\n\n<p>gzip -dc cd_iso.gz | cdrecord dev=\/dev\/cdrom - \u523b\u5f55\u4e00\u4e2a\u538b\u7f29\u4e86\u7684ISO\u955c\u50cf\u6587\u4ef6<\/p>\n\n\n\n<p>mount -o loop cd.iso \/mnt\/iso \u6302\u8f7d\u4e00\u4e2aISO\u955c\u50cf\u6587\u4ef6<\/p>\n\n\n\n<p>cd-paranoia -B \u4ece\u4e00\u4e2aCD\u5149\u76d8\u8f6c\u5f55\u97f3\u8f68\u5230 wav \u6587\u4ef6\u4e2d<\/p>\n\n\n\n<p>cd-paranoia -- \"-3\" \u4ece\u4e00\u4e2aCD\u5149\u76d8\u8f6c\u5f55\u97f3\u8f68\u5230 wav \u6587\u4ef6\u4e2d\uff08\u53c2\u6570-3\uff09<\/p>\n\n\n\n<p>cdrecord --scanbus \u626b\u63cf\u603b\u7ebf\u4ee5\u8bc6\u522bscsi\u901a\u9053<\/p>\n\n\n\n<p>dd if=\/dev\/hdc | md5sum \u6821\u9a8c\u4e00\u4e2a\u8bbe\u5907\u7684md5sum\u7f16\u7801\uff0c\u4f8b\u5982\u4e00\u5f20 CD<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u4e8c\u4e00\u3001\u7f51\u7edc - \uff08\u4ee5\u592a\u7f51\u548cWIFI\u65e0\u7ebf<\/strong>\uff09<\/h1>\n\n\n\n<p>ifconfig eth0 \u663e\u793a\u4e00\u4e2a\u4ee5\u592a\u7f51\u5361\u7684\u914d\u7f6e<\/p>\n\n\n\n<p>ifup eth0 \u542f\u7528\u4e00\u4e2a 'eth0' \u7f51\u7edc\u8bbe\u5907<\/p>\n\n\n\n<p>ifdown eth0 \u7981\u7528\u4e00\u4e2a 'eth0' \u7f51\u7edc\u8bbe\u5907<\/p>\n\n\n\n<p>ifconfig eth0 192.168.1.1 netmask 255.255.255.0 \u63a7\u5236IP\u5730\u5740<\/p>\n\n\n\n<p>ifconfig eth0 promisc \u8bbe\u7f6e 'eth0' \u6210\u6df7\u6742\u6a21\u5f0f\u4ee5\u55c5\u63a2\u6570\u636e\u5305 (sniffing)<\/p>\n\n\n\n<p>dhclient eth0 \u4ee5dhcp\u6a21\u5f0f\u542f\u7528 'eth0'<\/p>\n\n\n\n<p>route -n show routing table<\/p>\n\n\n\n<p>route add -net 0\/0 gw IP_Gateway configura default gateway<\/p>\n\n\n\n<p>route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1 configure static route to reach network '192.168.0.0\/16'<\/p>\n\n\n\n<p>route del 0\/0 gw IP_gateway remove static route<\/p>\n\n\n\n<p>echo \"1\" &gt; \/proc\/sys\/net\/ipv4\/ip_forward activate ip routing<\/p>\n\n\n\n<p>hostname show hostname of system<\/p>\n\n\n\n<p>host <a href=\"www.example.com\">www.example.com<\/a> lookup hostname to resolve name to ip address and viceversa(1)<\/p>\n\n\n\n<p>nslookup <a href=\"www.example.com\">www.example.com<\/a> lookup hostname to resolve name to ip address and viceversa(2)<\/p>\n\n\n\n<p>ip link show show link status of all interfaces<\/p>\n\n\n\n<p>mii-tool eth0 show link status of 'eth0'<\/p>\n\n\n\n<p>ethtool eth0 show statistics of network card 'eth0'<\/p>\n\n\n\n<p>netstat -tup show all active network connections and their PID<\/p>\n\n\n\n<p>netstat -tupl show all network services listening on the system and their PID<\/p>\n\n\n\n<p>tcpdump tcp port 80 show all HTTP traffic<\/p>\n\n\n\n<p>iwlist scan show wireless networks<\/p>\n\n\n\n<p>iwconfig eth1 show configuration of a wireless network card<\/p>\n\n\n\n<p>hostname show hostname<\/p>\n\n\n\n<p>host <a href=\"www.example.com\">www.example.com<\/a> lookup hostname to resolve name to ip address and viceversa<\/p>\n\n\n\n<p>nslookup <a href=\"www.example.com\">www.example.com<\/a> lookup hostname to resolve name to ip address and viceversa<\/p>\n\n\n\n<p>whois <a href=\"www.example.com\">www.example.com<\/a> lookup on Whois database<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u4e8c\u4e8c\u3001JPS\u5de5\u5177<\/strong><\/h1>\n\n\n\n<p>jps(Java Virtual Machine Process Status Tool)\u662fJDK 1.5\u63d0\u4f9b\u7684\u4e00\u4e2a\u663e\u793a\u5f53\u524d\u6240\u6709java\u8fdb\u7a0bpid\u7684\u547d\u4ee4\uff0c\u7b80\u5355\u5b9e\u7528\uff0c\u975e\u5e38\u9002\u5408\u5728linux\/unix\u5e73\u53f0\u4e0a\u7b80\u5355\u5bdf\u770b\u5f53\u524djava\u8fdb\u7a0b\u7684\u4e00\u4e9b\u7b80\u5355\u60c5\u51b5\u3002<\/p>\n\n\n\n<p>\u6211\u60f3\u5f88\u591a\u4eba\u90fd\u662f\u7528\u8fc7unix\u7cfb\u7edf\u91cc\u7684ps\u547d\u4ee4\uff0c\u8fd9\u4e2a\u547d\u4ee4\u4e3b\u8981\u662f\u7528\u6765\u663e\u793a\u5f53\u524d\u7cfb\u7edf\u7684\u8fdb\u7a0b\u60c5\u51b5\uff0c\u6709\u54ea\u4e9b\u8fdb\u7a0b\uff0c\u53ca\u5176 id\u3002 jps \u4e5f\u662f\u4e00\u6837\uff0c\u5b83\u7684\u4f5c\u7528\u662f\u663e\u793a\u5f53\u524d\u7cfb\u7edf\u7684java\u8fdb\u7a0b\u60c5\u51b5\uff0c\u53ca\u5176id\u53f7\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5b83\u6765\u67e5\u770b\u6211\u4eec\u5230\u5e95\u542f\u52a8\u4e86\u51e0\u4e2ajava\u8fdb\u7a0b\uff08\u56e0\u4e3a\u6bcf\u4e00\u4e2ajava\u7a0b\u5e8f\u90fd\u4f1a\u72ec\u5360\u4e00\u4e2ajava\u865a\u62df\u673a\u5b9e\u4f8b\uff09\uff0c\u548c\u4ed6\u4eec\u7684\u8fdb\u7a0b\u53f7\uff08\u4e3a\u4e0b\u9762\u51e0\u4e2a\u7a0b\u5e8f\u505a\u51c6\u5907\uff09\uff0c\u5e76\u53ef\u901a\u8fc7opt\u6765\u67e5\u770b\u8fd9\u4e9b\u8fdb\u7a0b\u7684\u8be6\u7ec6\u542f\u52a8\u53c2\u6570\u3002<\/p>\n\n\n\n<p><strong>\u4f7f\u7528\u65b9\u6cd5\uff1a\u5728\u5f53\u524d\u547d\u4ee4\u884c\u4e0b\u6253 jps(\u9700\u8981JAVA_HOME\uff0c\u6ca1\u6709\u7684\u8bdd\uff0c\u5230\u6539\u7a0b\u5e8f\u7684\u76ee\u5f55\u4e0b\u6253) \u3002<\/strong><\/p>\n\n\n\n<p><strong>jps\u5b58\u653e\u5728JAVA_HOME\/bin\/jps\uff0c\u4f7f\u7528\u65f6\u4e3a\u4e86\u65b9\u4fbf\u8bf7\u5c06JAVA_HOME\/bin\/\u52a0\u5165\u5230Path.<\/strong><\/p>\n\n\n\n<p>$&gt; <strong>jps<\/strong><\/p>\n\n\n\n<p>23991 Jps<\/p>\n\n\n\n<p>23789 BossMain<\/p>\n\n\n\n<p>23651 Resin<\/p>\n\n\n\n<p>\u6bd4\u8f83\u5e38\u7528\u7684\u53c2\u6570\uff1a<\/p>\n\n\n\n<p><strong>-q \u53ea\u663e\u793apid\uff0c\u4e0d\u663e\u793aclass\u540d\u79f0,jar\u6587\u4ef6\u540d\u548c\u4f20\u9012\u7ed9main \u65b9\u6cd5\u7684\u53c2\u6570<\/strong><\/p>\n\n\n\n<p>$&gt;<strong>jps -q<\/strong><\/p>\n\n\n\n<p>28680<\/p>\n\n\n\n<p>23789<\/p>\n\n\n\n<p>23651<\/p>\n\n\n\n<p><strong>-m \u8f93\u51fa\u4f20\u9012\u7ed9main \u65b9\u6cd5\u7684\u53c2\u6570\uff0c\u5728\u5d4c\u5165\u5f0fjvm\u4e0a\u53ef\u80fd\u662fnull<\/strong><\/p>\n\n\n\n<p>$&gt; <strong>jps -m<\/strong><\/p>\n\n\n\n<p>28715 Jps -m<\/p>\n\n\n\n<p>23789 BossMain<\/p>\n\n\n\n<p>23651 Resin -socketwait 32768 -stdout \/data\/aoxj\/resin\/log\/stdout.log -stderr \/data\/aoxj\/resin\/log\/stderr.log<\/p>\n\n\n\n<p><strong>-l \u8f93\u51fa\u5e94\u7528\u7a0b\u5e8fmain class\u7684\u5b8c\u6574package\u540d \u6216\u8005 \u5e94\u7528\u7a0b\u5e8f\u7684jar\u6587\u4ef6\u5b8c\u6574\u8def\u5f84\u540d<\/strong><\/p>\n\n\n\n<p>$&gt; <strong>jps -l<\/strong><\/p>\n\n\n\n<p>28729 sun.tools.jps.Jps<\/p>\n\n\n\n<p>23789 com.asiainfo.aimc.bossbi.BossMain<\/p>\n\n\n\n<p>23651 com.caucho.server.resin.Resin<\/p>\n\n\n\n<p><strong>-v \u8f93\u51fa\u4f20\u9012\u7ed9JVM\u7684\u53c2\u6570<\/strong><\/p>\n\n\n\n<p>$&gt; <strong>jps -v<\/strong><\/p>\n\n\n\n<p>23789 BossMain<\/p>\n\n\n\n<p>28802 Jps -Denv.class.path=\/data\/aoxj\/bossbi\/twsecurity\/java\/trustwork140.jar:\/data\/aoxj\/bossbi\/twsecurity\/java\/:\/data\/aoxj\/bossbi\/twsecurity\/java\/twcmcc.jar:\/data\/aoxj\/jdk15\/lib\/rt.jar:\/data\/aoxj\/jd<\/p>\n\n\n\n<p>k15\/lib\/tools.jar -Dapplication.home=\/data\/aoxj\/jdk15 -Xms8m 23651 Resin -Xss1m -Dresin.home=\/data\/aoxj\/resin -Dserver.root=\/data\/aoxj\/resin -Djava.util.logging.manager=com.caucho.log.LogManagerImpl -<\/p>\n\n\n\n<p>Djavax.management.builder.initial=com.caucho.jmx.MBeanServerBuilderImpl<\/p>\n\n\n\n<p><strong>sudo jps\u770b\u5230\u7684\u8fdb\u7a0b\u6570\u91cf\u6700\u5168<\/strong><\/p>\n\n\n\n<p><strong>jps 192.168.0.77<\/strong><\/p>\n\n\n\n<p><strong>\u5217\u51fa\u8fdc\u7a0b\u670d\u52a1\u5668192.168.0.77\u673a\u5668\u6240\u6709\u7684jvm\u5b9e\u4f8b\uff0c\u91c7\u7528rmi\u534f\u8bae\uff0c\u9ed8\u8ba4\u8fde\u63a5\u7aef\u53e3\u4e3a1099<\/strong><\/p>\n\n\n\n<p><strong>\uff08\u524d\u63d0\u662f\u8fdc\u7a0b\u670d\u52a1\u5668\u63d0\u4f9bjstatd\u670d\u52a1\uff09<\/strong><\/p>\n\n\n\n<p><strong>\u6ce8\uff1ajps\u547d\u4ee4\u6709\u4e2a\u5730\u65b9\u5f88\u4e0d\u597d\uff0c\u4f3c\u4e4e\u53ea\u80fd\u663e\u793a\u5f53\u524d\u7528\u6237\u7684java\u8fdb\u7a0b\uff0c\u8981\u663e\u793a\u5176\u4ed6\u7528\u6237\u7684\u8fd8\u662f\u53ea\u80fd\u7528unix\/linux\u7684ps\u547d\u4ee4\u3002<\/strong><\/p>\n\n\n\n<p>\u8be6\u7ec6\u60c5\u51b5\u8bf7\u53c2\u8003sun\u5b98\u65b9\u6587\u6863\u3002 <a href=\"http:\/\/java.sun.com\/j2se\/1.5.0\/docs\/tooldocs\/share\/jps.html\">http:\/\/java.sun.com\/j2se\/1.7.0\/docs\/tooldocs\/share\/jps.html<\/a><\/p>\n\n\n\n<p>GO TOP INDEX ^<\/p>\n\n\n\n<p>Microsoft Windows networks (SAMBA)<\/p>\n\n\n\n<p>nbtscan ip_addr netbios name resolution<\/p>\n\n\n\n<p>nmblookup -A ip_addr netbios name resolution<\/p>\n\n\n\n<p>smbclient -L ip_addr\/hostname show remote shares of a windows host<\/p>\n\n\n\n<p>smbget -Rr smb:\/\/ip_addr\/share like wget can download files from a host windows via smb<\/p>\n\n\n\n<p>mount -t smbfs -o username=user,password=pass \/\/WinClient\/share \/mnt\/share mount a windows network share<\/p>\n\n\n\n<p>-b file \u82e5\u6587\u4ef6\u5b58\u5728\u4e14\u662f\u4e00\u4e2a\u5757\u7279\u6b8a\u6587\u4ef6\uff0c\u5219\u4e3a\u771f<\/p>\n\n\n\n<p>-c file \u82e5\u6587\u4ef6\u5b58\u5728\u4e14\u662f\u4e00\u4e2a\u5b57\u7b26\u7279\u6b8a\u6587\u4ef6\uff0c\u5219\u4e3a\u771f<\/p>\n\n\n\n<p>-d file \u82e5\u6587\u4ef6\u5b58\u5728\u4e14\u662f\u4e00\u4e2a\u76ee\u5f55\uff0c\u5219\u4e3a\u771f<\/p>\n\n\n\n<p>-e file \u82e5\u6587\u4ef6\u5b58\u5728\uff0c\u5219\u4e3a\u771f<\/p>\n\n\n\n<p>-f file \u82e5\u6587\u4ef6\u5b58\u5728\u4e14\u662f\u4e00\u4e2a\u89c4\u5219\u6587\u4ef6\uff0c\u5219\u4e3a\u771f<\/p>\n\n\n\n<p>-g file \u82e5\u6587\u4ef6\u5b58\u5728\u4e14\u8bbe\u7f6e\u4e86SGID\u4f4d\u7684\u503c\uff0c\u5219\u4e3a\u771f<\/p>\n\n\n\n<p>-h file \u82e5\u6587\u4ef6\u5b58\u5728\u4e14\u4e3a\u4e00\u4e2a\u7b26\u5408\u94fe\u63a5\uff0c\u5219\u4e3a\u771f<\/p>\n\n\n\n<p>-k file \u82e5\u6587\u4ef6\u5b58\u5728\u4e14\u8bbe\u7f6e\u4e86\"sticky\"\u4f4d\u7684\u503c<\/p>\n\n\n\n<p>-p file \u82e5\u6587\u4ef6\u5b58\u5728\u4e14\u4e3a\u4e00\u5df2\u547d\u540d\u7ba1\u9053\uff0c\u5219\u4e3a\u771f<\/p>\n\n\n\n<p>-r file \u82e5\u6587\u4ef6\u5b58\u5728\u4e14\u53ef\u8bfb\uff0c\u5219\u4e3a\u771f<\/p>\n\n\n\n<p>-s file \u82e5\u6587\u4ef6\u5b58\u5728\u4e14\u5176\u5927\u5c0f\u5927\u4e8e\u96f6\uff0c\u5219\u4e3a\u771f<\/p>\n\n\n\n<p>-u file \u82e5\u6587\u4ef6\u5b58\u5728\u4e14\u8bbe\u7f6e\u4e86SUID\u4f4d\uff0c\u5219\u4e3a\u771f<\/p>\n\n\n\n<p>-w file \u82e5\u6587\u4ef6\u5b58\u5728\u4e14\u53ef\u5199\uff0c\u5219\u4e3a\u771f<\/p>\n\n\n\n<p>-x file \u82e5\u6587\u4ef6\u5b58\u5728\u4e14\u53ef\u6267\u884c\uff0c\u5219\u4e3a\u771f<\/p>\n\n\n\n<p>-o file \u82e5\u6587\u4ef6\u5b58\u5728\u4e14\u88ab\u6709\u6548\u7528\u6237ID\u6240\u62e5\u6709\uff0c\u5219\u4e3a\u771f<\/p>\n\n\n\n<p>-z string \u82e5string\u957f\u5ea6\u4e3a0\uff0c\u5219\u4e3a\u771f<\/p>\n\n\n\n<p>-n string \u82e5string\u957f\u5ea6\u4e0d\u4e3a0\uff0c\u5219\u4e3a\u771f<\/p>\n\n\n\n<p>string1 = string2 \u82e5\u4e24\u4e2a\u5b57\u7b26\u4e32\u76f8\u7b49\uff0c\u5219\u4e3a\u771f<\/p>\n\n\n\n<p>string1 != string2 \u82e5\u4e24\u4e2a\u5b57\u7b26\u4e32\u4e0d\u76f8\u7b49\uff0c\u5219\u4e3a\u771f<\/p>\n\n\n\n<p>int1 -eq int2 \u82e5int1\u7b49\u4e8eint2\uff0c\u5219\u4e3a\u771f<\/p>\n\n\n\n<p>int1 -ne int2 \u82e5int1\u4e0d\u7b49\u4e8eint2\uff0c\u5219\u4e3a\u771f<\/p>\n\n\n\n<p>int1 -lt int2 \u82e5int1\u5c0f\u4e8eint2\uff0c\u5219\u4e3a\u771f<\/p>\n\n\n\n<p>int1 -le int2 \u82e5int1\u5c0f\u4e8e\u7b49\u4e8eint2\uff0c\u5219\u4e3a\u771f<\/p>\n\n\n\n<p>int1 -gt int2 \u82e5int1\u5927\u4e8eint2\uff0c\u5219\u4e3a\u771f<\/p>\n\n\n\n<p>int1 -ge int2 \u82e5int1\u5927\u4e8e\u7b49\u4e8eint2\uff0c\u5219\u4e3a\u771f<\/p>\n\n\n\n<p>!expr \u82e5expr\u4e3a\u5047\u5219\u590d\u5408\u8868\u8fbe\u5f0f\u4e3a\u771f\u3002expr\u53ef\u4ee5\u662f\u4efb\u4f55\u6709\u6548\u7684\u6d4b\u8bd5\u8868\u8fbe\u5f0f<\/p>\n\n\n\n<p>expr1 -a expr2 \u82e5expr1\u548cexpr2\u90fd\u4e3a\u771f\u5219\u6574\u5f0f\u4e3a\u771f<\/p>\n\n\n\n<p>expr1 -o expr2 \u82e5expr1\u548cexpr2\u6709\u4e00\u4e2a\u4e3a\u771f\u5219\u6574\u5f0f\u4e3a\u771f<\/p>\n\n\n\n<p>\u7279\u6b8a\u53d8\u91cf<\/p>\n\n\n\n<p>$0 \u6b63\u5728\u88ab\u6267\u884c\u547d\u4ee4\u7684\u540d\u5b57\u3002\u5bf9\u4e8eshell\u811a\u672c\u800c\u8a00\uff0c\u8fd9\u662f\u88ab\u6fc0\u6d3b\u547d\u4ee4\u7684\u8def\u5f84<\/p>\n\n\n\n<p>$n \u8be5\u53d8\u91cf\u4e0e\u811a\u672c\u88ab\u6fc0\u6d3b\u65f6\u6240\u5e26\u7684\u53c2\u6570\u76f8\u5bf9\u5e94\u3002n\u662f\u6b63\u6574\u6570\uff0c\u4e0e\u53c2\u6570\u4f4d\u7f6e\u76f8\u5bf9\u5e94($1,$2\u2026)<\/p>\n\n\n\n<p>$# \u63d0\u4f9b\u811a\u672c\u7684\u53c2\u6570\u53f7<\/p>\n\n\n\n<p>$* \u6240\u6709\u8fd9\u4e9b\u53c2\u6570\u90fd\u88ab\u53cc\u5f15\u53f7\u5f15\u4f4f\u3002\u82e5\u4e00\u4e2a\u811a\u672c\u63a5\u6536\u4e24\u4e2a\u53c2\u6570\uff0c$*\u7b49\u4e8e$1$2<\/p>\n\n\n\n<p>$@ \u6240\u6709\u8fd9\u4e9b\u53c2\u6570\u90fd\u5206\u522b\u88ab\u53cc\u5f15\u53f7\u5f15\u4f4f\u3002\u82e5\u4e00\u4e2a\u811a\u672c\u63a5\u6536\u5230\u4e24\u4e2a\u53c2\u6570\uff0c$@\u7b49\u4ef7\u4e8e$1$2<\/p>\n\n\n\n<p>$? \u524d\u4e00\u4e2a\u547d\u4ee4\u6267\u884c\u540e\u7684\u9000\u51fa\u72b6\u6001, \u5e38\u7528\u4e8e\u5224\u65ad\u4e0a\u4e00\u4e2a\u547d\u4ee4\u7684\u6267\u884c\u7ed3\u679c, \u4ee5\u8f85\u52a9\u5224\u65ad\u4e0b\u6e38\u5206\u652f\u903b\u8f91\u7684\u6267\u884c<\/p>\n\n\n\n<p>$$ \u5f53\u524dshell\u7684\u8fdb\u7a0b\u53f7\u3002\u5bf9\u4e8eshell\u811a\u672c\uff0c\u8fd9\u662f\u5176\u6b63\u5728\u6267\u884c\u65f6\u7684\u8fdb\u7a0bID<\/p>\n\n\n\n<p>$! \u524d\u4e00\u4e2a\u540e\u53f0\u547d\u4ee4\u7684\u8fdb\u7a0b\u53f7<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u4e8c\u4e09\u3001crontab\u8c03\u5ea6\u5668<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u2460\u3001\u8bed\u6cd5<\/strong><\/h2>\n\n\n\n<p>Linux\u4e0b\u7684\u4efb\u52a1\u8c03\u5ea6\u5206\u4e3a\u4e24\u7c7b\uff1a\u7cfb\u7edf\u4efb\u52a1\u8c03\u5ea6\u548c\u7528\u6237\u4efb\u52a1\u8c03\u5ea6\u3002Linux\u7cfb\u7edf\u4efb\u52a1\u662f\u7531 cron (crond) \u8fd9\u4e2a\u7cfb\u7edf\u670d\u52a1\u6765\u63a7\u5236\u7684\uff0c\u8fd9\u4e2a\u7cfb\u7edf\u670d\u52a1\u662f\u9ed8\u8ba4\u542f\u52a8\u7684\u3002\u7528\u6237\u81ea\u5df1\u8bbe\u7f6e\u7684\u8ba1\u5212\u4efb\u52a1\u5219\u4f7f\u7528crontab \u547d\u4ee4\u3002\u5728CentOS\u7cfb\u7edf\u4e2d\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/etc\/crontab<br> <br>SHELL=\/bin\/bash<br>PATH=\/sbin:\/bin:\/usr\/sbin:\/usr\/bin<br>MAILTO=root<br>HOME=\/<br># For details see man 4 crontabs<br># Example of job definition:<br># .---------------- minute (0 - 59)<br># | .------------- hour (0 - 23)<br># | | .---------- day of month (1 - 31)<br># | | | .------- month (1 - 12) OR jan,feb,mar,apr ...<br># | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat<br># | | | | |<br># * * * * * user-name command to be executed<br> <br>\u524d\u56db\u884c\u662f\u7528\u6765\u914d\u7f6ecrond\u4efb\u52a1\u8fd0\u884c\u7684\u73af\u5883\u53d8\u91cf:<br>\u300b\u7b2c\u4e00\u884cSHELL\u53d8\u91cf\u6307\u5b9a\u4e86\u7cfb\u7edf\u8981\u4f7f\u7528\u54ea\u4e2ashell\uff0c\u8fd9\u91cc\u662fbash\uff1b<br>\u300b\u7b2c\u4e8c\u884cPATH\u53d8\u91cf\u6307\u5b9a\u4e86\u7cfb\u7edf\u6267\u884c\u547d\u4ee4\u7684\u8def\u5f84\uff1b<br>\u300b\u7b2c\u4e09\u884cMAILTO\u53d8\u91cf\u6307\u5b9a\u4e86crond\u7684\u4efb\u52a1\u6267\u884c\u4fe1\u606f\u5c06\u901a\u8fc7\u7535\u5b50\u90ae\u4ef6\u53d1\u9001\u7ed9root\u7528\u6237\uff0c\u5982\u679cMAILTO\u53d8\u91cf\u7684\u503c\u4e3a\u7a7a\uff0c\u5219\u8868\u793a\u4e0d\u53d1\u9001\u4efb\u52a1\u6267\u884c\u4fe1\u606f\u7ed9\u7528\u6237\uff1b<br>\u300b\u7b2c\u56db\u884c\u7684HOME\u53d8\u91cf\u6307\u5b9a\u4e86\u5728\u6267\u884c\u547d\u4ee4\u6216\u8005\u811a\u672c\u65f6\u4f7f\u7528\u7684\u4e3b\u76ee\u5f55\u3002<br> <br>\u7528\u6237\u5b9a\u671f\u8981\u6267\u884c\u7684\u5de5\u4f5c\uff0c\u6bd4\u5982\u7528\u6237\u6570\u636e\u5907\u4efd\u3001\u5b9a\u65f6\u90ae\u4ef6\u63d0\u9192\u7b49\u3002\u7528\u6237\u53ef\u4ee5\u4f7f\u7528 crontab \u5de5\u5177\u6765\u5b9a\u5236\u81ea\u5df1\u7684\u8ba1\u5212\u4efb\u52a1\u3002\u6240\u6709\u7528\u6237\u5b9a\u4e49\u7684crontab \u6587\u4ef6\u90fd\u88ab\u4fdd\u5b58\u5728 \/var\/spool\/cron\u76ee\u5f55\u4e2d\u3002\u5176\u6587\u4ef6\u540d\u4e0e\u7528\u6237\u540d\u4e00\u81f4\u3002<\/code><\/pre>\n\n\n\n<p>\u7528\u6237\u6240\u5efa\u7acb\u7684crontab\u6587\u4ef6\u4e2d\uff0c\u6bcf\u4e00\u884c\u90fd\u4ee3\u8868\u4e00\u9879\u4efb\u52a1\uff0c\u6bcf\u884c\u7684\u6bcf\u4e2a\u5b57\u6bb5\u4ee3\u8868\u4e00\u9879\u8bbe\u7f6e\uff0c\u5b83\u7684\u683c\u5f0f\u5171\u5206\u4e3a\u516d\u4e2a\u5b57\u6bb5\uff1a<\/p>\n\n\n\n<p>\u300b\u524d\u4e94\u6bb5\u662f\u65f6\u95f4\u8bbe\u5b9a\u6bb5\uff1b<\/p>\n\n\n\n<p>\u300b\u7b2c\u516d\u6bb5\u662f\u8981\u6267\u884c\u7684\u547d\u4ee4\u6bb5<\/p>\n\n\n\n<p>crontab\u8868\u8fbe\u5f0f \u683c\u5f0f\u5982\u4e0b\uff1a minute hour day month week command<\/p>\n\n\n\n<figure class=\"wp-block-image\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/img-blog.csdnimg.cn\/img_convert\/848c0c63326aa7d1f9c22f78f8e8ad23.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"https:\/\/img-blog.csdnimg.cn\/img_convert\/848c0c63326aa7d1f9c22f78f8e8ad23.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"crontab\u7528\u6cd5\u4e0e\u5b9e\u4f8bcrontab\u7528\u6cd5\u4e0e\u5b9e\u4f8b\"\/><\/div><\/figure>\n\n\n\n<p>\u5728\u4ee5\u4e0a\u5404\u4e2a\u5b57\u6bb5\u4e2d\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u7279\u6b8a\u5b57\u7b26\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\"<em>\"\u4ee3\u8868\u6240\u6709\u7684\u53d6\u503c\u8303\u56f4\u5185\u7684\u6570\u5b57\uff0c\u5982\u6708\u4efd\u5b57\u6bb5\u4e3a<\/em>\uff0c\u5219\u8868\u793a1\u523012\u4e2a\u6708\uff1b<\/p>\n\n\n\n<p>\"\/\"\u4ee3\u8868\u6bcf\u4e00\u5b9a\u65f6\u95f4\u95f4\u9694\u7684\u610f\u601d\uff0c\u5982\u5206\u949f\u5b57\u6bb5\u4e3a*\/10\uff0c\u8868\u793a\u6bcf10\u5206\u949f\u6267\u884c1\u6b21\u3002<\/p>\n\n\n\n<p>\"-\"\u4ee3\u8868\u4ece\u67d0\u4e2a\u533a\u95f4\u8303\u56f4\uff0c\u662f\u95ed\u533a\u95f4\u3002\u5982\u201c2-5\u201d\u8868\u793a\u201c2,3,4,5\u201d\uff0c\u5c0f\u65f6\u5b57\u6bb5\u4e2d0-23\/2\u8868\u793a\u57280~23\u70b9\u8303\u56f4\u5185\u6bcf2\u4e2a\u5c0f\u65f6\u6267\u884c\u4e00\u6b21\u3002<\/p>\n\n\n\n<p>\",\"\u5206\u6563\u7684\u6570\u5b57\uff08\u4e0d\u4e00\u5b9a\u8fde\u7eed\uff09\uff0c\u59821,2,3,4,7,9\u3002<\/p>\n\n\n\n<p>\u6ce8\uff1a\u7531\u4e8e\u5404\u4e2a\u5730\u65b9\u6bcf\u5468\u7b2c\u4e00\u5929\u4e0d\u4e00\u6837\uff0c\u56e0\u6b64Sunday=0\uff08\u7b2c\u4e00\u5929\uff09\u6216Sunday=7\uff08\u6700\u540e1\u5929\uff09\u3002<\/p>\n<\/blockquote>\n\n\n\n<p>case: \u6bcf\u96942\u5206\u949f,\u5220\u9664\u6307\u5b9a\u76ee\u5f55\u4e0b,\u521b\u5efa\u65f6\u95f4\u8d85\u8fc710\u4e2a\u5c0f\u65f6\u7684\u6587\u4ef6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>*\/2 * * * * \/bin\/sh -c \"find \/tmp\/hadoop-hdfs\/mapred\/local -cmin +600 -type d -exec rm -rf {} \\;\" &gt;&gt; \/var\/lib\/hadoop-hdfs\/auto_remove_mr_output.out<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">\u4e8c\u56db\u3001Shell\u7f16\u7a0b\u76f8\u5173<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u2460\u3001\u5185\u7f6e\u53d8\u91cf<\/strong><\/h2>\n\n\n\n<p>1\u3001declare<\/p>\n\n\n\n<p>declare\u58f0\u660e\u53d8\u91cf\u7684\u4f7f\u7528\uff0c\u603b\u7ed3\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p>declare <a href=\"#\">+\/-<\/a> \u53d8\u91cf\u540d<\/p>\n\n\n\n<p>\u9009\u9879\uff1a<\/p>\n\n\n\n<p>-\uff1a\u7ed9\u53d8\u91cf\u6dfb\u52a0\u7c7b\u578b\u5c5e\u6027<\/p>\n\n\n\n<p>+\uff1a\u53d6\u6d88\u53d8\u91cf\u7684\u7c7b\u578b\u5c5e\u6027<\/p>\n\n\n\n<p>-a\uff1a\u5c06\u53d8\u91cf\u58f0\u660e\u4e3a\u6570\u7ec4\u578b\uff0c-A\u5c06\u58f0\u660e\u4e00\u4e2a\u5173\u8054\u6570\u7ec4\uff0c\u4fd7\u79f0\u5b57\u5178\u3002 \u5173\u8054\u77e5\u8bc6\uff1aShell \u6570\u7ec4\u4e0e\u5173\u8054\u6570\u7ec4\u8be6\u89e3\u53ca\u5b9e\u4f8b\u4ee3\u7801\uff08<a href=\"https:\/\/www.jb51.net\/article\/103915.htm\">https:\/\/www.jb51.net\/article\/103915.htm<\/a>\uff09<\/p>\n\n\n\n<p>-i\uff1a\u5c06\u53d8\u91cf\u58f0\u660e\u4e3a\u6574\u578b<\/p>\n\n\n\n<p>-x\uff1a\u5c06\u53d8\u91cf\u58f0\u660e\u4e3a\u73af\u5883\u53d8\u91cf<\/p>\n\n\n\n<p>-r\uff1a\u5c06\u53d8\u91cf\u58f0\u660e\u4e3a\u53ea\u8bfb\u53d8\u91cf<\/p>\n\n\n\n<p>-p\uff1a\u67e5\u770b\u53d8\u91cf\u7684\u88ab\u58f0\u660e\u7684\u7c7b\u578b<\/p>\n\n\n\n<p>declare -i \u8bf4\u660e\uff1a<\/p>\n\n\n\n<p>\u548c (())\u3001let\u3001$[] \u4e0d\u540c\uff0c<code>declare -i<\/code>\u7684\u529f\u80fd\u975e\u5e38\u6709\u9650\uff0c\u4ec5\u652f\u6301\u6700\u57fa\u672c\u7684\u6570\u5b66\u8fd0\u7b97\uff08\u52a0\u51cf\u4e58\u9664\u548c\u53d6\u4f59\uff09\uff0c\u4e0d\u652f\u6301\u903b\u8f91\u8fd0\u7b97\uff08\u6bd4\u8f83\u8fd0\u7b97\u3001\u4e0e\u8fd0\u7b97\u3001\u6216\u8fd0\u7b97\u3001\u975e\u8fd0\u7b97\uff09\uff0c\u6240\u4ee5\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\u5f88\u5c11\u4f7f\u7528\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>declare -i m n ret<br>m=10<br>n=30<br> <br>ret=$m+$n<br>echo $ret<br> <br>ret=$n\/$m<br>echo $ret<\/code><\/pre>\n\n\n\n<p>declare\u7684\u4f5c\u7528\u57df\uff0c\u53ea\u5728\u51fd\u6570\u5185\uff0c\u51fa\u6765\u540e\u5c31\u5931\u6548\u4e86\uff0c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash<br> <br>foo()<br>{<br>declare FOO=\"bar\"<br>}<br> <br>bar()<br>{<br>foo<br>echo $FOO<br>}<br> <br>bar<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u2461\u3001\u6570\u636e\u7ed3\u6784<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1\u3001\u6570\u7ec4<\/h3>\n\n\n\n<p><a href=\"https:\/\/www.cnblogs.com\/Joke-Shi\/p\/5705856.html\">Linux shell\u4e2d\u6570\u7ec4\u7684\u4f7f\u7528<\/a><\/p>\n\n\n\n<p>\u6570\u7ec4\u6709\u4e24\u79cd\u6570\u636e\u7c7b\u578b\uff1a<\/p>\n\n\n\n<p>A). \u4e00\u662f\u6570\u503c\u7c7b\u578b;<\/p>\n\n\n\n<p>B). \u4e8c\u662f\u5b57\u7b26\u4e32\u7c7b\u578b.<\/p>\n\n\n\n<p>\u867d\u7136shell\u672c\u8eab\u662f\u5f31\u7c7b\u578b\u7684\uff0c\u4f46\u4e5f\u53ef\u4ee5\u8fd9\u4e48\u533a\u5206\u3002<\/p>\n\n\n\n<p><strong>\u6570\u503c\u7c7b\u578b\u7684\u6570\u7ec4\uff1a<\/strong>\u4e00\u5bf9\u62ec\u53f7\u8868\u793a\u6570\u7ec4\uff0c\u6570\u7ec4\u4e2d\u5143\u7d20\u4e4b\u95f4\u4f7f\u7528\u201c\u7a7a\u683c\u201d\u6765\u9694\u5f00\u3002<\/p>\n\n\n\n<p>\u4e3e\u4e2a\u5217\u5b50:<\/p>\n\n\n\n<p>arr_number=(1 2 3 4 5);<\/p>\n\n\n\n<p><strong>\u5b57\u7b26\u4e32\u7c7b\u578b\u6570\u7ec4\uff1a<\/strong>\u540c\u6837\uff0c\u4f7f\u7528\u4e00\u5bf9\u62ec\u53f7\u8868\u793a\u6570\u7ec4\uff0c\u5176\u4e2d\u6570\u7ec4\u4e2d\u7684\u5143\u7d20\u4f7f\u7528\u53cc\u5f15\u53f7\u6216\u8005\u5355\u5f15\u53f7\u5305\u542b\uff0c\u540c\u6837\u4f7f\u7528\u201c\u7a7a\u683c\u201d\u6765\u9694\u5f00\u3002<\/p>\n\n\n\n<p>arr_string=(\"abc\" \"edf\" \"sss\"); \u6216\u8005 arr_string=('abc' 'edf' 'sss');<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash<br>arr_number=(1 2 3 4 5)<br> <br># \u2460\u3001\u83b7\u53d6\u6570\u7ec4\u957f\u5ea6<br># \u8bed\u6cd5\uff1a ${#ARRAY_NAME&#91;@|*]}<br>echo 'arr_number length ='${#arr_number&#91;@]}<br>echo 'arr_number length ='${#arr_number&#91;*]}<br> <br># \u2461\u3001\u6839\u636e\u4e0b\u6807\u8bbf\u95ee\u6570\u7ec4\u5143\u7d20\uff08\u6ce8\u610f\uff1a\u4e0b\u6807\u4e0ejava\u8bed\u6cd5\u7c7b\u4f3c\uff0c\u4ece0\u5f00\u59cb\uff09<br># 2nd key's value<br>echo \"2nd key's value =\"${arr_number&#91;1]}<br> <br># \u2462\u3001\u5206\u7247\u8bbf\u95ee<br>echo ${arr_number&#91;@]:0:6}<br> <br># \u2463\u3001\u6a21\u5f0f\u66ff\u6362<br>echo ${arr_number&#91;@]\/3\/33}<br> <br># \u2464\u3001\u6570\u7ec4\u7684\u904d\u5386<br>for e in ${arr_number&#91;@]}<br>do<br> &nbsp; &nbsp; &nbsp; &nbsp;echo $e<br>done<br> <br># \u2465\u3001\u7efc\u5408\u6848\u4f8b<br># \u7f16\u6ce8\uff1a\u6570\u7ec4\u9ed8\u8ba4\u5206\u5272\u7b26\u4e3a\u7a7a\u683c\uff0c\u5982\u679c\u6570\u7ec4\u5143\u7d20\u4e2d\u672c\u8eab\u5305\u542b\u7a7a\u683c\uff0c\u4e5f\u4f1a\u88ab\u622a\u65ad\uff0c\u8fd9\u91cc\u901a\u8fc7\u6539\u53d8IFS\uff08\u7cfb\u7edf\u5b57\u6bb5\u5206\u5272# \u7b26\u9ed8\u8ba4\u4e3a\u7a7a\u683c\uff09\u4e3a\u6362\u884c\uff0c\u8fbe\u5230\u5206\u5272\u6570\u7ec4\u7684\u76ee\u7684\u3002<br>greet=('hello world' \"hi,john\")<br>OLD_IFS=$IFS<br>IFS='\\n'<br>for e in ${greet&#91;@]}<br>do<br> &nbsp; &nbsp; &nbsp; &nbsp;echo $e<br>done<br>IFS=$OLD_IFS<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><\/h3>\n\n\n\n<p>\u300b\u2460\u3001\u6279\u91cf\u5220\u9664\u65e5\u5fd7\uff1a<\/p>\n\n\n\n<p>for i in in {1..10}; do rm -f hadoop-cmf-hive-HIVEMETASTORE-nn1.testhdp.com.log.out.$i;done<\/p>\n\n\n\n<p>\u300b\u2461\u3001\u6279\u91cf\u5c06\u65e5\u5fd7\u7f6e\u7a7a\uff1a<\/p>\n\n\n\n<p>for i in in {1..10}; do cat \/dev\/null &gt; hadoop-cmf-yarn-NODEMANAGER-dn8.hadoop.com.log.out.$i;done<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2\u3001\u5b57\u5178dict \u6216 Map<\/h3>\n\n\n\n<p><strong>1). \u58f0\u660e\u5b57\u5178\u7c7b\u578b\uff1a<\/strong> declare -A dic<\/p>\n\n\n\n<p>\u8fd9\u91cc\u4e00\u5b9a\u8981-A\u6765\u58f0\u660e\uff0c-a\u53ea\u80fd\u7528\u6765\u58f0\u660e\u6570\u7ec4\u7c7b\u578b\u3002<\/p>\n\n\n\n<p><strong>2). \u5b57\u5178\u8d4b\u521d\u503c<\/strong> dic=([key1]=\"value1\" [key2]=\"value2\" [key3]=\"value3\")<\/p>\n\n\n\n<p><strong>3). \u5b57\u5178\u52a8\u6001\u8d4b\u503c<\/strong> dic['key']=value<\/p>\n\n\n\n<p><strong>4). \u6253\u5370\u6307\u5b9akey\u7684value<\/strong> echo ${dic['key']}<\/p>\n\n\n\n<p><strong>5). \u6253\u5370\u6240\u6709key\u503c<\/strong> echo ${!dic[*]}<\/p>\n\n\n\n<p><strong>6). \u6253\u5370\u6240\u6709value<\/strong> echo ${dic[*]}<\/p>\n\n\n\n<p><strong>7). \u904d\u5386key\u503c<\/strong><\/p>\n\n\n\n<p>for key in $(echo ${!dic[*]})<\/p>\n\n\n\n<p>do<\/p>\n\n\n\n<p>echo \"$key : ${dic[$key]}\"<\/p>\n\n\n\n<p>done<\/p>\n\n\n\n<p><strong>8). \u7efc\u5408\u6848\u4f8b<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#! \/bin\/sh<br>#\u8f93\u5165\u683c\u5f0f\u4e3a\u4e00\u884c\u4e00\u4e2a\u5355\u8bcd<br> <br>declare -A dict<br>dict=(&#91;k1]=\"v1\" &#91;k2]=\"v2\")<br>echo ${dict&#91;\"k1\"]}<br>echo ${!dict&#91;*]}<br>echo ${dict&#91;*]}<br> <br>for key in ${!dict&#91;*]}<br>do<br> &nbsp; &nbsp; &nbsp; &nbsp;echo \"$key : ${dict&#91;$key]}\"<br>done<br>set -x<br>aa=\"null\"<br>bb=<br>cc=''<br> <br># &nbsp;  -z \u5b57\u7b26\u4e32\u4e3a\"null\".\u5c31\u662f\u957f\u5ea6\u4e3a0.<br>#<br># &nbsp;  -n \u5b57\u7b26\u4e32\u4e0d\u4e3a\"null\"<br>#<br># &nbsp; &nbsp; \u6ce8\u610f:<br>#<br># &nbsp; &nbsp; \u4f7f\u7528-n\u5728&#91;]\u7ed3\u6784\u4e2d\u6d4b\u8bd5\u5fc5\u987b\u8981\u7528\"\"\u628a\u53d8\u91cf\u5f15\u8d77\u6765.\u4f7f\u7528\u4e00\u4e2a\u672a\u88ab\"\"\u7684\u5b57\u7b26\u4e32\u6765\u4f7f\u7528! -z<br>#<br># &nbsp; &nbsp; \u6216\u8005\u5c31\u662f\u672a\u7528\"\"\u5f15\u7528\u7684\u5b57\u7b26\u4e32\u672c\u8eab,\u653e\u5230&#91;]\u7ed3\u6784\u4e2d\u3002\u867d\u7136\u4e00\u822c\u60c5\u51b5\u4e0b\u53ef<br>#<br># &nbsp; &nbsp; \u4ee5\u5de5\u4f5c,\u4f46\u8fd9\u662f\u4e0d\u5b89\u5168\u7684.\u4e60\u60ef\u4e8e\u4f7f\u7528\"\"\u6765\u6d4b\u8bd5\u5b57\u7b26\u4e32\u662f\u4e00\u79cd\u597d\u4e60\u60ef.<br>if &#91; -n \"$cc\" ];then<br> &nbsp; &nbsp; &nbsp; &nbsp;echo \"aa is not null\"<br>fi<br>set +x<br> <br> <br>#\u5b9a\u4e49\u5b57\u5178\u7c7b\u578b\u53d8\u91cf<br>declare -A dict<br> <br>#\u4ece\u6807\u51c6\u8f93\u5165\u8bfb\u53d6<br>while read word<br>do<br> &nbsp; &nbsp;#\u82e5key\u4e3aword\u7684\u53d8\u91cf\u4e0d\u5b58\u5728\uff0c\u5219\u4e3a\u672a\u5b9a\u4e49\uff0c\u5373\u7b2c\u4e00\u6b21\u9047\u5230\u6b64word\uff0c\u5219\u5c06\u6b64word\u52a0\u5165\u5b57\u5178\u5e76\u8bbe\u7f6e\u5176value\u4e3a1\u3002\uff0c\u5426\u5219\u81ea\u589evalue\u503c<br> &nbsp; &nbsp;if &#91; ! -n dict&#91;${word}] ];then<br> &nbsp; &nbsp; &nbsp;  dict&#91;${word}]=1<br> &nbsp; &nbsp;else<br> &nbsp; &nbsp; &nbsp;  ((dict&#91;${word}]++))<br> &nbsp; &nbsp;fi<br>done<br>#\u6253\u5370\u7edf\u8ba1\u7ed3\u679c<br>echo -e \"word\\t\\tcount\"<br>for key in $(echo ${!dict&#91;*]})<br>do<br> &nbsp; &nbsp;echo -e \"$key\\t\\t${dict&#91;$key]}\"<br>done<\/code><\/pre>\n\n\n\n<p>\u7efc\u5408\u6848\u4f8b\u4e8c: <a href=\"https:\/\/blog.csdn.net\/weixin_42651205\/article\/details\/83624574\">shell\u7684map\u7b80\u5355\u7684\u6dfb\u52a0\u3001\u67e5\u627e\u3001\u5220\u9664\u3001\u904d\u5386<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3\u3001\u7ba1\u9053\u8f93\u51fa\u4e2d\u6267\u884c\u4e0b\u4e00\u6761\u6307\u4ee4<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>ps -ef | grep 'new-consumer' | awk '{print $2}' |xargs kill -9 &nbsp; &nbsp; &nbsp; #\u5220\u9664kafka consumer\u8fdb\u7a0b<br> <br>ps -ef|grep java|grep -v grep|awk '{print $2}'|xargs kill -9 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#\u5220\u9664java\u8fdb\u7a0b &nbsp; <br> <br>find \/opt\/flume-custom\/ -name *.conf|xargs grep -re \"127.0.0.1:9092\" #\u67e5\u627e\u5230\u7684\u6587\u4ef6\u4e2d\u67e5\u627e\u6307\u5b9a\u5b57\u7b26\u4e32<br> <br>find \/opt\/ -type f -name '*.log' |xargs grep 'db.hostname'<br> <br>cat ~\/.ssh\/id_rsa.pub | ssh my_admin@111.111.111.111 \"cat - &gt;&gt; ~\/.ssh\/authorized_keys\"<br> <br>kill -9 $(ps -ef|grep \"sh\\ *start_new.sh\\ *main\"|grep -v grep|awk '{print $2}') #\\ *\u8868\u4efb\u610f\u591a\u7a7a\u683c<br> <br>kill -9 `ps -ef|grep data-integration|awk '{print $2}'`<br> <br>ls|while read f;do zip -r ${f}.zip $f;done &nbsp;#\u538b\u7f29\u6240\u6709ls\u51fa\u6765\u7684\u6587\u4ef6\u5939<br> <br>ls|grep 'hadoop-cmf-yarn-RESOURCEMANAGER-nn1.hadoop.com.log.out.&#91;0-9]\\{1,\\}'|while read f;do cat \/dev\/null &gt; $f;done #\u5c06\u6240\u6709RESOURCEMANAGER\u65e5\u5fd7\u6587\u4ef6\u5185\u5bb9\u7f6e\u4e3a\u7a7a\uff0c\u6587\u4ef6\u5c3e\u7f00\u4e3a1\u4e2a\u4ee5\u4e0a\u4ece0\u52309\u7684\u6570\u5b57\uff0c\u59821\u30012\u30019\u300112\u5747\u80fd\u5339\u914d\u67e5\u627e\u5230,\u5728nn1\u4e0a\u78c1\u76d8\uff08\/var\/log\/{hadoop-hdfs,hadoop-yarn}\uff09\u4e0a\u65e5\u5fd7\u4e00\u822c\u90fd\u6bd4\u8f83\u5927<br> <br># \u67e5\u627e10\u65e5\u524d\u521b\u5efa\u7684\u6587\u4ef6\uff0c\u5e76\u60c5\u51b5\u5176\u5185\u5bb9<br>find . -type f -name '*oozie-instrumentation.log.*' -atime +10 | while read f;do cat \/dev\/null &gt; $f;done<br> <br>#\u67e5\u770b\u6240\u6709\u7528\u6237\u7684crontab\u4efb\u52a1\uff0c\u5176\u4e2d\"-I {}\"\u53c2\u6570\uff0c\u53ef\u4ee5\u4f7f\u7528-i\u6765\u7b49\u91cf\u5b9e\u73b0<br>cat \/etc\/passwd | cut -f 1 -d : |xargs -I {} crontab -l -u {}<br>cat \/etc\/passwd | cut -f 1 -d : |xargs -i crontab -l -u {}<br> <br># \u67e5\u8be2\u5f53\u524d\u76ee\u5f55\u4e0b\u6240\u6709\u6587\u4ef6(\u542b\u76ee\u5f55\u4e0b\u6587\u4ef6)\u4e2d\u5305\u542b\u5173\u952e\u5b57(sku)\u7684\u6587\u4ef6\u8def\u5f84, \u6ee4\u91cd, \u5e76\u8fc7\u6ee4\u6389\u8def\u5f84\u4e2d\u542b\u6307\u5b9a\u5b57\u7b26(000)<br>grep -rn 'sku' * | awk -F ':' '{print $1}' | uniq | grep -v 000<\/code><\/pre>\n\n\n\n<p><a href=\"https:\/\/www.cnblogs.com\/liaojiafa\/p\/11537636.html\">\u4f20\u9001\u95e8\uff1aShell\u57fa\u7840\u77e5\u8bc6\u300bxargs\u8be6\u89e3<\/a><\/p>\n\n\n\n<p>\u8bfb\u53d6\u6587\u4ef6\u6bcf\u4e00\u884c\uff0c\u5e76\u5faa\u73af\u505a\u5904\u7406\uff1a<\/p>\n\n\n\n<p>\u2460\u3001while read line<\/p>\n\n\n\n<p>do<\/p>\n\n\n\n<p>\u2026<\/p>\n\n\n\n<p>done &lt; file<\/p>\n\n\n\n<p>\u2461\u3001cat file | ${BIZ_LOGICAL}<\/p>\n\n\n\n<p>\u7efc\u5408\u5b9e\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh &nbsp; 127.0.0.1 &lt;&lt;EOF<br>sudo su<br>sed -i 's\/^Hostname=.*\/Hostname=127.0.0.1\/' \/etc\/zabbix\/zabbix_agentd.conf<br>cat \/etc\/zabbix\/zabbix_agentd.conf | grep Hostname<br>ps -ef | grep zabbix | awk  '{print \\$2}' | xargs kill -9 <br>\/usr\/sbin\/zabbix_agentd -c \/etc\/zabbix\/zabbix_agentd.conf<br>sleep 2<br>ps -ef  | grep zabbix<br>exit<br>exit<br>EOF<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4\u3001\u5faa\u73af\u3001\u8fed\u4ee3\u903b\u8f91\u63a7\u5236<\/h3>\n\n\n\n<p><strong>4.1 while\u5faa\u73af\u8bed\u6cd5\uff08while...do...done\uff09<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#hdfs\u6587\u4ef6\u7edf\u8ba1<br> <br>hdfs dfs -ls \/  | hdfs dfs -ls `awk '{print $8}'`\/ | &nbsp;echo -e \"`awk '{print $8}'`\/ \\n\"  | while read line ; do echo -e \"$line \\t\\t\\t\\t\\t `sudo -u hdfs hdfs dfs -ls -R $line | wc -l `\" &nbsp;  ;done<br> <br>hdfs dfs -ls \/  | hdfs dfs -ls `awk '{print $8}'`\/ | &nbsp;awk '{ cmd=\"echo -e  \"$8\"\\\\\\t\\\\\\t\\\\\\t\\\\\\t`sudo -u hdfs  hdfs dfs -ls -R  \"$8\"| wc -l`\" ;cmd|getline ; print $0}'<br> <br>#jar\u5305\u91cc\u7edf\u8ba1\u5305\u542b\u6307\u5b9a\u5b57\u7b26\u7684\u6587\u4ef6\u540d<br> <br>ls;while read line;do cat \/dev\/null&gt;$line; done<br> <br>ls lib\/* |while read line;do jar -tf $line|grep LogAnalysis; echo $line;done<br> <br>#hdfs\u6587\u4ef6\u5927\u5c0f\u7edf\u8ba1\u6392\u5e8f<br> <br>hdfs dfs -du ${HDFS_PATH} | sort -rn | head -n 10 | awk '{printf(\"%.2f\\t\\t%.2f\\t\\t%s\\t\\n\",$1\/1024\/1024\/1024,\"\\t\"$2\/1024\/1024\/1024,\"\\t\"$3)}'<br> <br>#\u83b7\u53d6\u6240\u6709java\u7a0b\u5e8f\u7684\u8fdb\u7a0b\u53f7<br> <br>ps -ef | while read line ; do if &#91;&#91; $line =~ \"java\" ]] ;then echo $line | &nbsp;awk -F ' ' '{print $2}' ; fi ;done<br> <br>\/\/\u5faa\u73af\u6240\u6709\u6587\u4ef6\uff0c\u5e76\u6dfb\u52a0header<br>#!\/bin\/bash<br>ls OrderDetail_sysdate_* |while read file;do<br>sed -i \"1i\\\\$(cat header.csv)\" $file<br>done<br> <\/code><\/pre>\n\n\n\n<p>\u7efc\u5408\u6848\u4f8b\uff1a<\/p>\n\n\n\n<p>\u6e05\u7406\u65e5\u5fd7\u6587\u4ef6\u5939\u4e2d\u7684\u65e5\u5fd7\u6587\u4ef6\uff0c\u5c06\u5176\u7f6e\u4e3a\u9ed1\u6d1e\u6587\u4ef6\u5185\u5bb9\uff08\u5373\u60c5\u51b5\u8be5\u6587\u4ef6\uff09\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#!\/bin\/bash<br> <br>#\u5148\u904d\u5386\u672c\u6587\u4ef6\u5939\u91cc\u6587\u4ef6\u5939<br>dir_list=`ls`<br> <br>#\u5bf9\u67e5\u8be2\u5230\u7684\u6587\u4ef6\u5939\u6267\u884c\u6e05\u7a7a\u5176\u5185\u6587\u4ef6\u7684\u64cd\u4f5c<br>for dir in $dir_list;do<br> &nbsp; &nbsp;echo $dir<br> &nbsp; &nbsp;ls $dir\/* | while read line;do echo $line; cat \/dev\/null &gt; $line; done<br>done<\/pre>\n\n\n\n<p>for i in <code>seq 1 $(cat \/proc\/cpuinfo |grep \"physical id\" |wc -l)<\/code>; do dd if=\/dev\/zero of=\/dev\/null &amp; done<\/p>\n\n\n\n<p>pkill -9 dd<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5\u3001break \u4e0e contine\u533a\u522b<\/h3>\n\n\n\n<p>\u5982\u4e0b\u4ee3\u7801\u6240\u793a\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th><strong>\u4e0d\u5e26\u53c2\u6570 N\uff1a<\/strong><\/th><th><\/th><\/tr><\/thead><tbody><tr><td>break<\/td><td>\u5faa\u73af\u53ea\u80fd\u9000\u51fa\u6700\u5185\u5c42\u7684\u5faa\u73af\uff1b<\/td><\/tr><tr><td>continue<\/td><td>\u53ea\u80fd\u53bb\u6389\u672c\u6b21\u5faa\u73af\u7684\u5269\u4f59\u4ee3\u7801\uff1b<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th><strong>\u5e26\u53c2\u6570 N\uff1a<\/strong><\/th><th><\/th><\/tr><\/thead><tbody><tr><td>break N<\/td><td>\u53ef\u4ee5\u9000\u51faN\u5c42\u5faa\u73af\uff1b<\/td><\/tr><tr><td>continue N<\/td><td>\u5c06\u4f1a\u628aN\u5c42\u5faa\u73af\u5269\u4f59\u4ee3\u7801\u90fd\u53bb\u6389\uff0c\u5355\u5faa\u73af\u6b21\u6570\u4e0d\u53d8\uff1b<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash<br> <br>for i in a b c d<br>do<br> &nbsp;  echo -n $i<br> <br> &nbsp;  for j in `seq 10`<br> &nbsp;  do<br> &nbsp; &nbsp; &nbsp;  if test $j -eq 5;then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  #break<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # continue<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  #break 2<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  continue 2<br> &nbsp; &nbsp; &nbsp;  fi<br> &nbsp; &nbsp; &nbsp;  echo -n $j<br> &nbsp;  done<br> <br> &nbsp;  #\u6362\u884c<br> &nbsp;  echo <br>done<br> <br>##########################################<br>###<br>### Program result:<br>###<br>##########################################<br>#<br>#&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; 1. break &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br># a1234<br># b1234<br># c1234<br># d1234<br> <br>#&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; 2. continue &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br># a1234678910<br># b1234678910<br># c1234678910<br># d1234678910<br> <br>#&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; 3. \"break 2\",\"break 3\" has same effect &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br># a1234<br> <br>#&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; 4. \"continue 2\" &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;<br># a1234<br># b1234<br># c1234<br># d1234<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">6\u3001\u5927\u6587\u4ef6\u62c6\u5206\u5904\u7406<\/h3>\n\n\n\n<p>\u6587\u4ef6\u62c6\u5206\uff1a<\/p>\n\n\n\n<p>split -d -a 8 -l 10000 PayOrderDetail.csv PayOrderDetail_sysdate_.csv<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u7528\u6cd5\uff1a<\/p>\n\n\n\n<p>Usage: split [OPTION]... [INPUT [PREFIX]]<\/p>\n\n\n\n<p>Output fixed-size pieces of INPUT to PREFIXaa, PREFIXab, ...; default<\/p>\n\n\n\n<p>size is 1000 lines, and default PREFIX is 'x'. With no INPUT, or when INPUT<\/p>\n\n\n\n<p>is -, read standard input.<\/p>\n\n\n\n<p>Mandatory arguments to long options are mandatory for short options too.<\/p>\n\n\n\n<p>-a, --suffix-length=N generate suffixes of length N (default 2)<\/p>\n\n\n\n<p>--additional-suffix=SUFFIX append an additional SUFFIX to file names<\/p>\n\n\n\n<p>-b, --bytes=SIZE put SIZE bytes per output file<\/p>\n\n\n\n<p>-C, --line-bytes=SIZE put at most SIZE bytes of lines per output file<\/p>\n\n\n\n<p>-d, --numeric-suffixes[=FROM] use numeric suffixes instead of alphabetic;<\/p>\n\n\n\n<p>FROM changes the start value (default 0)<\/p>\n\n\n\n<p>-e, --elide-empty-files do not generate empty output files with '-n'<\/p>\n\n\n\n<p>--filter=COMMAND write to shell COMMAND; file name is $FILE<\/p>\n\n\n\n<p>-l, --lines=NUMBER put NUMBER lines per output file<\/p>\n\n\n\n<p>-n, --number=CHUNKS generate CHUNKS output files; see explanation below<\/p>\n\n\n\n<p>-u, --unbuffered immediately copy input to output with '-n r\/...'<\/p>\n\n\n\n<p>--verbose print a diagnostic just before each<\/p>\n\n\n\n<p>output file is opened<\/p>\n\n\n\n<p>--help display this help and exit<\/p>\n\n\n\n<p>--version output version information and exit<\/p>\n\n\n\n<p>SIZE is an integer and optional unit (example: 10M is 10<em>1024<\/em>1024). Units are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (powers of 1000).<\/p>\n\n\n\n<p>CHUNKS may be:<\/p>\n\n\n\n<p>N split into N files based on size of input<\/p>\n\n\n\n<p>K\/N output Kth of N to stdout<\/p>\n\n\n\n<p>l\/N split into N files without splitting lines<\/p>\n\n\n\n<p>l\/K\/N output Kth of N to stdout without splitting lines<\/p>\n\n\n\n<p>r\/N like 'l' but use round robin distribution<\/p>\n\n\n\n<p>r\/K\/N likewise but only output Kth of N to stdout<\/p>\n\n\n\n<p>GNU coreutils online help: <a href=\"http:\/\/www.gnu.org\/software\/coreutils\/\">http:\/\/www.gnu.org\/software\/coreutils\/<\/a> For complete documentation, run: info coreutils 'split invocation'<\/p>\n<\/blockquote>\n\n\n\n<p>\u8be6\u7ec6\u6848\u4f8b\uff0c\u8be6\u89c1\uff1a<a href=\"http:\/\/c.biancheng.net\/linux\/split.html\">split\u547d\u4ee4_Linux split\u547d\u4ee4\uff1a\u5207\u5272\uff08\u62c6\u5206\uff09\u6587\u4ef6<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">7\u3001awk<\/h3>\n\n\n\n<p>#\u6279\u91cf\u5220\u9664hdfs\u4e0bods\u5c42\u4e0b\u6240\u6709\u6570\u636e<\/p>\n\n\n\n<p>hdfs dfs -lsr \/user\/hive\/warehouse\/ods|awk '{print \"hdfs dfs -rm -R\" $8}'<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">8\u3001\u5b9e\u73b0\u811a\u672c\u4e2d\u5207\u6362\u7528\u6237\u5e76\u6267\u884c\u8be5\u7528\u6237\u76f8\u5173\u7684\u547d\u4ee4\u64cd\u4f5c<\/h3>\n\n\n\n<p>\u5047\u5982\u5f53\u524d\u7528\u6237\u4e3aroot\u8d26\u6237\uff0c\u5e0c\u671b\u5207\u6362\u5230\u5176\u4ed6\u7528\u6237\u4e0b\u6267\u884c\u76f8\u5173\u7684\u64cd\u4f5c\uff0c\u5982\u6709\u4ee5\u4e0b\u4e1a\u52a1\u573a\u666f\uff1a<\/p>\n\n\n\n<p>\u60f3\u4ee5yarn\u7528\u6237\u8eab\u4efd\uff0c\u53d6\u5220\u9664yarn\u8fd0\u884c\u76f8\u5173\u7684\u65e9\u671f\u7528\u5904\u4e0d\u5927\u7684\u65e5\u5fd7\u3002<\/p>\n\n\n\n<p>\u65b9\u5f0f\u2460\u3001<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash<br>su - yarn &lt;&lt;EOF<br> &nbsp;  pwd;<br> &nbsp; &nbsp;exit;<br>EOF<\/code><\/pre>\n\n\n\n<p>\u65b9\u5f0f\u2461\u3001<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>su - ${USER} -c ${COMMAND} &gt; \/dev\/null 2&gt;&amp;1 &amp;<\/code><\/pre>\n\n\n\n<p>\u6ce8\u610f\uff1a<\/p>\n\n\n\n<p>\u8be5\u547d\u4ee4\u7684\u6267\u884c\u6743\u9650\u662f\u4e34\u65f6\u7684\uff0c\u53ea\u5728\u672c\u6761\u8bed\u53e5\u8d77\u4f5c\u7528\u3002\u5373\u5728COMMAND\u547d\u4ee4\u884c\u5185\u90e8\uff0c\u662f\u4ee5$USER\u8eab\u4efd\u6267\u884c\u547d\u4ee4\uff1b\u6267\u884c\u7ed3\u675f\u540e\uff0c\u56de\u5230\u521d\u59cb\u72b6\u6001\u7528\u6237\uff0c\u8fd9\u91cc\u4e3aroot\u3002<\/p>\n\n\n\n<p>\u6848\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>## 01-Handle logic of clean HDFS NAMENODE &amp; DATANODE &amp; audit logs.<br>########################################################<br>su - hdfs -c '<br> &nbsp; &nbsp; &nbsp;  HDFS_PATH=\/var\/log\/hadoop-hdfs;<br> &nbsp; &nbsp; &nbsp;  ls $HDFS_PATH | grep \"hadoop-cmf-hdfs-NAMENODE-nn1.hadoop.com.log.out.&#91;0-9]\\{1,\\}$\" | while read f; &nbsp; &nbsp; do `cat \/dev\/null &gt; $HDFS_PATH\/$f`; done &nbsp; ;<br> &nbsp; &nbsp; &nbsp;  ls $HDFS_PATH | grep \"hadoop-cmf-hdfs-DATANODE-nn1.hadoop.com.log.out.&#91;0-9]\\{1,\\}$\" | while read f; &nbsp; &nbsp; do `cat \/dev\/null &gt; $HDFS_PATH\/$f`; done &nbsp; ;<br> &nbsp; &nbsp; &nbsp;  ls $HDFS_PATH | grep \"hdfs-audit.log.&#91;0-9]\\{1,\\}$\" | while read f; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  do `cat \/dev\/null &gt; $HDFS_PATH\/$f`; done<br>'<\/code><\/pre>\n\n\n\n<p>\u6ce8\u610f\uff1a<\/p>\n\n\n\n<p>\u2460 ls\u8fd9\u6bb5\u8bed\u53e5\u5728\u547d\u4ee4\u884c\u4e0b\u6267\u884c\u6ca1\u4efb\u4f55\u95ee\u9898\uff0c\u63d0\u53d6\u5230\u201csu - hdfs -c\u201d\u4e2d\u65f6\uff0c<code>cat \/dev\/null &gt; $HDFS_PATH\/$f<\/code>\u8fd9\u6bb5\u5fc5\u987b\u8981\u5305\u88f9\u4e0a``\u7b26\u53f7\uff0c\u624d\u80fd\u6b63\u5e38\u6267\u884c\u3002<\/p>\n\n\n\n<p>\u2461 -c \u53c2\u6570\u4e2d\uff0c\u53ef\u4ee5\u6267\u884c\u591a\u884c\u547d\u4ee4\uff0c\u4f46\u662f\u9700\u8981\u51e0\u4e2a\u6761\u4ef6\uff1aA). \u6240\u7528\u547d\u4ee4\u4f7f\u7528''\u5305\u88f9\uff0c\u6bcf\u4e00\u884c\u547d\u4ee4\u95f4\uff0c\u4f7f\u7528\"\uff1b\"\u6765\u8fdb\u884c\u5206\u9694\u3002<\/p>\n\n\n\n<p>\u8865\u5145su\u7684\u7528\u6cd5\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;root@cdh-nn1 ~]# su --help<br> <br>Usage:<br> su &#91;options] &#91;-] &#91;USER &#91;arg]...]<br> <br>Change the effective user id and group id to that of USER.<br>A mere - implies -l. &nbsp; If USER not given, assume root.<br> <br>Options:<br> -m, -p, --preserve-environment  do not reset environment variables<br> -g, --group &lt;group&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; specify the primary group<br> -G, --supp-group &lt;group&gt; &nbsp; &nbsp; &nbsp;  specify a supplemental group<br> <br> -, -l, --login &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  make the shell a login shell<br> -c, --command &lt;command&gt; &nbsp; &nbsp; &nbsp; &nbsp; pass a single command to the shell with -c<br> --session-command &lt;command&gt; &nbsp; &nbsp; pass a single command to the shell with -c<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; and do not create a new session<br> -f, --fast &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  pass -f to the shell (for csh or tcsh)<br> -s, --shell &lt;shell&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; run shell if \/etc\/shells allows it<br> <br> -h, --help &nbsp; &nbsp; display this help and exit<br> -V, --version  output version information and exit<br> <br>For more details see su(1).<\/code><\/pre>\n\n\n\n<p>su \u548c \u201csu - ${USER}\u201d\u7684\u533a\u522b\uff1a<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\u2460\u3001su\u53ea\u662f\u5207\u6362\u7528\u6237\u3002 \u2461\u3001su - \u5207\u6362\u7528\u6237\u5e76\u5207\u6362shell\u73af\u5883\u3002<\/p>\n\n\n\n<p>\u2462\u3001su another pwd\u540e\u4e3a\/home\/current<\/p>\n\n\n\n<p>\u2463\u3001su - another pwd\u540e\u4e3a\/home\/another<\/p>\n<\/blockquote>\n\n\n\n<h1 class=\"wp-block-heading\"><\/h1>\n\n\n\n<h3 class=\"wp-block-heading\">9\u3001awk\u5b9e\u73b0\u67e5\u627e\u5947\u6570\u884c\u3001\u5076\u6570\u884c\uff1a<\/h3>\n\n\n\n<p>seq 20 &gt; test.txt<\/p>\n\n\n\n<p>[root@server1 tmp]# awk 'NR%2 != 0' test.txt<\/p>\n\n\n\n<p>[root@server1 tmp]# awk 'NR%2 == 0' test.txt<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>10\u3001IFS\u4e13\u9898<\/strong><\/h3>\n\n\n\n<p>IFS, \u5168\u79f0 \u5185\u90e8\u5b57\u6bb5\u5206\u9694\u7b26(Internal Field Separator, IFS) , \u4f5c\u7528\u662f\u5728Linux\u4e2d\u5b9a\u4e49\u4e00\u4e2a\u5b9a\u754c\u7b26\uff0c\u9ed8\u8ba4\u662f\u7a7a\u683c\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u5b57\u7b26\u4e32\u4e2d\u7684\u5206\u9694\u7b26,\u9ed8\u8ba4\u4e0d\u662f\u7a7a\u683c,\u800c\u662f\u9017\u53f7(\u5982csv\u6587\u4ef6), \u5219\u53ef\u4ee5\u8003\u8651\u4e34\u65f6\u66ff\u6362IFS\u4e3a\u9017\u53f7,\u5904\u7406\u5b8c\u6587\u672c\u5904\u7406\u4efb\u52a1\u540e, \u518d\u5c06\u9ed8\u8ba4\u7684\u4fee\u6539\u56de\u6765.<\/p>\n\n\n\n<p>\u5982\u679c\u811a\u672c\u5b9e\u73b0, \u6309\",\"\u63d0\u53d6\u8868\u540dlist:<\/p>\n\n\n\n<p>batch_upsert_table_process.sh<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash<br> <br>include_tables=\"activity_info,activity_rule,activity_sku,base_category1,base_category2,base_category3,base_province,base_region,base_trademark,coupon_info,coupon_range,coupon_use,financial_sku_cost,sku_info,spu_info,user_info\"<br> <br>function get_element_by_split_comma(){<br> &nbsp; &nbsp;ifs_old=$IFS<br> &nbsp; &nbsp;IFS=\",\"<br> <br> &nbsp; &nbsp;for tbl in $(echo \"${include_tables}\");do<br> &nbsp; &nbsp; &nbsp; &nbsp;echo 'Now is handle table &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; '$tbl<br> &nbsp; &nbsp; &nbsp;  \/data\/maxwell\/bin\/maxwell-bootstrap --database gmall --table $tbl --config \/data\/maxwell\/tf_custom_config\/gmall_rtdw_test.properties<br> &nbsp; &nbsp;done<br> <br> &nbsp; &nbsp;#Recovery IFS to default<br> &nbsp; &nbsp;IFS=$ifs_old<br>}<br> <br>get_element_by_split_comma<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u2462*<\/strong>*\u3001echo\u5728shell\u4e2d\u63a7\u5236\u989c\u8272&amp;\u95ea\u70c1\u663e\u793a**<\/h1>\n\n\n\n<h3 class=\"wp-block-heading\">1\u3001\u5728shell\u4e2d\u663e\u793a\u8272\u5f69<\/h3>\n\n\n\n<p>\u8bed\u6cd5\u683c\u5f0f\uff1a<\/p>\n\n\n\n<p>echo -e \"\\033[\u989c\u82721:\u989c\u82722m \u8981\u5c55\u793a\u7684\u6587\u5b57 \\033[0m\"<\/p>\n\n\n\n<p>\u53c2\u6570\u8bf4\u660e\uff1a<\/p>\n\n\n\n<p>-----------------------------------------------------------------------------------------------------------------------<\/p>\n\n\n\n<p>-e\u9009\u9879\uff1a\u8868\u793a\u5141\u8bb8\u53cd\u659c\u6760\uff08\u5bf9\u5b57\u7b26\uff09\u8f6c\u4e49\u3002<\/p>\n\n\n\n<p>\\033[\u989c\u82721\uff1b\u989c\u82722m\uff1a\u79f0\u4e3a\u8f6c\u4e49\u5e8f\u5217\uff0c\u5b83\u672c\u8eab\u662f\u4e00\u4e2a\u6574\u4f53\uff0c\u4e2d\u95f4\u4e0d\u8981\u6709\u7a7a\u683c\u3002<\/p>\n\n\n\n<p>\\033[\uff1a\u8f6c\u4e49\u5e8f\u5217\u7684\u5f00\u59cb\u3002\u5176\u4e2d\\033\u4ee3\u8868Esc\u7b26\u53f7\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\\E\u6216\\e\u6765\u4ee3\u66ff\u3002<\/p>\n\n\n\n<p>\u989c\u82721\u548c\u989c\u82722\uff1a\u8868\u793a\u5b57\u4f53\u7684\u524d\u666f\u8272\u6216\u80cc\u666f\u8272\uff0c\u81f3\u4e8e\u989c\u82721\u548c\u989c\u82722\u54ea\u4e00\u4e2a\u8868\u793a\u524d\u666f\u8272\uff0c\u54ea\u4e00\u4e2a\u8868\u793a\u80cc\u666f\u8272\uff0c\u7531\u5176\u8bbe\u5b9a\u7684\u6570\u503c\u6765\u51b3\u5b9a\uff0c\u524d\u666f\u8272\u548c\u80cc\u666f\u8272\u7684\u6570\u503c\u7a7a\u95f4\u662f\u4e0d\u540c\u7684\u3002<\/p>\n\n\n\n<p>m\uff1a\u8f6c\u4e49\u5e8f\u5217\u7684\u7ec8\u6b62\u6807\u5fd7\u3002<\/p>\n\n\n\n<p>\\033[0m\uff1a\u8868\u793a\u5c06\u989c\u8272\u6062\u590d\u56de\u539f\u6765\u7684\u914d\u8272\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u53ef\u4ee5\u7528\u4e00\u5f20\u539f\u7406\u56fe\u6765\u7406\u89e3\uff1a<\/p>\n\n\n\n<p>-----------------------------------------------------------------------------------------------------------------------<\/p>\n\n\n\n<p>\u56fe\u793a\u8bf4\u660e\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/img-blog.csdnimg.cn\/img_convert\/4776bb88cef258c2ef87139cccbc8e25.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"https:\/\/img-blog.csdnimg.cn\/img_convert\/4776bb88cef258c2ef87139cccbc8e25.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"img\"\/><\/div><\/figure>\n\n\n\n<p>\u989c\u8272\u7801\uff1a<\/p>\n\n\n\n<h1 class=\"wp-block-heading\"><img decoding=\"async\" alt=\"img\" src=\"https:\/\/img-blog.csdnimg.cn\/img_convert\/702094a013e82be4f568d94b71709dc9.png\"><\/h1>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\u2463\u3001\u6570\u636e\u7c7b\u578b\u8f6c\u5316<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1\u3001\u5b57\u7b26\u4e32\u8f6c\u5316\u4e3a\u6570\u5b57<\/h3>\n\n\n\n<p>\u6848\u4f8b1: \u5c06\u65e5\u671f\u4e2d\u4ee50\u5f00\u5934\u7684\u6570\u5b57\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u6570\u5b57<\/p>\n\n\n\n<p>\u6bd4\u5982\u4eca\u65e5\u4e3a2022-03-25, \u5982\u679c\u60f3\u83b7\u53d6\u6708\u4efd, \u53ef\u4ee5\u4f7f\u7528 echo $(date +%m) \u6216 echo <code>date +%m<\/code>, \u5c06\u83b7\u53d6\u5230\u5b57\u7b26\u4e32\"03\", \u4f46\u6211\u4eec\u60f3\u8981\u53bb\u6389\u5f00\u59340\u76843, \u7ffb\u904ddate\u7684api\u90fd\u6ca1\u6709\u627e\u5230.<\/p>\n\n\n\n<p>\u8fd9\u65f6\u5019\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u6570\u5b66\u8fd0\u7b97\u5c06\u539f\u5b57\u7b26\u4e32 \u4e0e \u4e00\u4e2a\u6570\u5b570\u76f8\u52a0, \u53d8\u76f8\u901a\u8fc7\u6570\u5b66\u8ba1\u7b97\u83b7\u53d6\u5230\u6574\u5f62\u7684\u8ba1\u7b97\u7ed3\u679c.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;hdfs@hadoop test]$ echo $(expr $(date +%m) + 0)<br>3<br> <br>&#91;hdfs@hadoop test]$ echo `expr $(date +%m) + 0`<br>3<br> <br>&#91;hdfs@hadoop test]$ hive --hivevar year=$(date +%Y) --hivevar month=`expr $(date +%m) + 0` -f \/data\/program\/test_hive.hql<\/code><\/pre>\n\n\n\n<p>test_hive.hql\u4e2d\u5219\u53ef\u4ee5\u4f7f\u7528\u4e0a\u8ff0\u52a8\u6001\u4f20\u53c2\u7684\u503c:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ALTER TABLE ads.my_partition_table_test DROP IF EXISTS PARTITION(year=${hivevar:year}, month=${hivevar:month});<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\"><\/h1>\n\n\n\n<h1 class=\"wp-block-heading\">\u2464\u3001\u767b\u5f55shell \u4e0e \u975e\u767b\u5f55shell\u533a\u522b<\/h1>\n\n\n\n<p>\u767b\u5f55shell\uff1a\u4f7f\u7528linux\u8d26\u6237\u767b\u5f55\u540e\u6267\u884c\u7684shell<\/p>\n\n\n\n<p>\u975e\u767b\u5f55shell\uff1a\u4e0d\u7ecf\u767b\u5f55\uff0c\u76f4\u63a5\u4f7f\u7528shell\uff0c\u5982ssh \u8fdc\u7a0b\u8fde\u63a5\u5230\u4e3b\u673a\u540e\u6267\u884c\u7684shell<\/p>\n\n\n\n<figure class=\"wp-block-image\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/img-blog.csdnimg.cn\/7ac169bb4fd845188a90fc744ae42c49.png'><img class=\"lazyload lazyload-style-2\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"https:\/\/img-blog.csdnimg.cn\/7ac169bb4fd845188a90fc744ae42c49.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"img\"\/><\/div><\/figure>\n\n\n\n<p>\u6ce8\u610f\uff1a<\/p>\n\n\n\n<ul>\n<li>\u5982\u679c\u5c06\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u4fe1\u606f\uff0c\u914d\u7f6e\u5728\/etc\/profile\u4e2d\uff0c\u5bf9\u4e8e\u975e\u767b\u5f55shell\uff0c\u5219\u83b7\u53d6\u4e0d\u5230\u3002<\/li>\n\n\n\n<li>\u800c\u5bf9\u4e8e\/etc\/profile.d\/*.sh\uff0c\u5219\u5bf9\u4e8e2\u79cdshell\uff0c\u90fd\u53ef\u4ee5\u8bbf\u95ee\u5230\u3002<\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u4e8c\u5341\u4e94\u3001\u7a0b\u5e8f\u5f00\u673a\u81ea\u542f\u52a8\u670d\u52a1\u914d\u7f6e<\/strong><\/h1>\n\n\n\n<p>Centos\u7cfb\u7edf\u670d\u52a1\u5668\u811a\u672c\u76ee\u5f55\u4f4d\u7f6e\uff1a\/usr\/lib\/systemd\/<\/p>\n\n\n\n<p>\u5176\u5185\u90e8\u6709\u7cfb\u7edf\uff08system\uff09\u548c\u7528\u6237\uff08user\uff092\u4e2a\u6587\u4ef6\u5939\uff0c\u5982\u9700\u8981\u5f00\u673a\u4e0d\u767b\u5f55\u5373\u8981\u6c42\u80fd\u6267\u884c\u7684\u7a0b\u5e8f\uff0c\u5728\u7cfb\u7edf\u670d\u52a1\uff08system\uff09\u91cc\uff0c\u5373\/usr\/lib\/systemd\/system\uff1b<\/p>\n\n\n\n<p>\u800c\u5982\u679c\u9700\u8981\u7528\u6237\u767b\u5f55\u4e4b\u540e\u624d\u53ef\u4ee5\u8fd0\u884c\u7684\u7a0b\u5e8f\uff0c\u5728\u7528\u6237\u670d\u52a1\uff08user\uff09\u91cc\uff0c\u5373\/usr\/lib\/systemd\/user\u3002<\/p>\n\n\n\n<p>\u8fd9\u91cc\u4ee5nginx\u670d\u52a1\u5f00\u542f\u81ea\u542f\u4e3a\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>[Unit]<\/strong> &nbsp; &nbsp;<br>Description=Nginx restart on Reboot<br>After=network.target &nbsp; &nbsp;<br> &nbsp; &nbsp; <br><strong>[Service]<\/strong> &nbsp; &nbsp;<br>Type=forking &nbsp; &nbsp;<br>User=nginx<br>Group=nginx<br>ExecStart=\/etc\/init.d\/nginx start &nbsp; &nbsp;<br>ExecReload=\/etc\/init.d\/nginx restart &nbsp; &nbsp;<br>ExecStop=\/etc\/init.d\/nginx  stop &nbsp; &nbsp;<br>PrivateTmp=true &nbsp; &nbsp;<br> <br><strong>[Install]<\/strong> &nbsp; &nbsp;<br>WantedBy=multi-user.target &nbsp; <\/pre>\n\n\n\n<p>\u53c2\u6570\u8bf4\u660e\uff1a<\/p>\n\n\n\n<ol>\n<li>Description:\u63cf\u8ff0\u670d\u52a1<\/li>\n\n\n\n<li>After:\u63cf\u8ff0\u672c\u670d\u52a1\u7684\u4e0a\u6e38\u4f9d\u8d56\u5173\u7cfb\uff0c\u5373\u4e0a\u6e38\u542f\u52a8\u5b8c\u6bd5\u540e\uff0c\u624d\u53ef\u4ee5\u542f\u52a8\u672c\u670d\u52a1<\/li>\n\n\n\n<li>[Service]\u670d\u52a1\u8fd0\u884c\u53c2\u6570\u7684\u8bbe\u7f6e<\/li>\n\n\n\n<li>Type=forking\u662f\u540e\u53f0\u8fd0\u884c\u7684\u5f62\u5f0f<\/li>\n\n\n\n<li>User\u670d\u52a1\u542f\u52a8\u7528\u6237<\/li>\n\n\n\n<li>Group\u670d\u52a1\u542f\u52a8\u7528\u6237\u7ec4<\/li>\n\n\n\n<li>ExecStart\u4e3a\u670d\u52a1\u7684\u5177\u4f53\u8fd0\u884c\u547d\u4ee4<\/li>\n\n\n\n<li>ExecReload\u4e3a\u91cd\u542f\u547d\u4ee4<\/li>\n\n\n\n<li>ExecStop\u4e3a\u505c\u6b62\u547d\u4ee4<\/li>\n\n\n\n<li>PrivateTmp=True\u8868\u793a\u7ed9\u670d\u52a1\u5206\u914d\u72ec\u7acb\u7684\u4e34\u65f6\u7a7a\u95f4<\/li>\n<\/ol>\n\n\n\n<p>\u6ce8\u610f\uff1a<\/p>\n\n\n\n<ul>\n<li>[Service]\u7684\u542f\u52a8\u3001\u91cd\u542f\u3001\u505c\u6b62\u547d\u4ee4\u5168\u90e8\u8981\u6c42\u4f7f\u7528\u7edd\u5bf9\u8def\u5f84<\/li>\n\n\n\n<li>[Install]\u670d\u52a1\u5b89\u88c5\u7684\u76f8\u5173\u8bbe\u7f6e\uff0c\u53ef\u8bbe\u7f6e\u4e3a\u591a\u7528\u6237<\/li>\n<\/ul>\n\n\n\n<p>\u4e00\u822c\u6587\u4ef6\u4ee5644\u6743\u9650\u8fdb\u884c\u4fdd\u5b58,\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p>[root@nn2 system]# ll frp.service -rw-r--r-- 1 root root 266 Oct 29 11:50 frp.service<\/p>\n\n\n\n<p>\u8bbe\u7f6e\u5f00\u673a\u81ea\u542f\u52a8\u547d\u4ee4\uff1asystemctl enable nginx.service<\/p>\n\n\n\n<p><strong>&gt;&gt; \u5982\u679c\u67e5\u770bsystemctl\u542f\u52a8\u670d\u52a1\u7684log\u4fe1\u606f?<\/strong><\/p>\n\n\n\n<p>Service\u542f\u52a8\u4e4b\u540e, \u5982\u679c\u60f3\u67e5\u8be2\u5176\u8be6\u7ec6\u65e5\u5fd7\u4fe1\u606f, \u53ef\u4ee5\u4f7f\u7528\u7c7b\u4f3ctail\u7684\u547d\u4ee4, \u4f7f\u7528journalctl -f \u53ef\u4ee5\u6765\u5b9e\u65f6\u8ffd\u8e2a\u65e5\u5fd7.<\/p>\n\n\n\n<p>\u4f7f\u7528journalctl\u53ef\u4ee5\u67e5\u770b\u4f7f\u7528systemctl\u542f\u52a8\u7684service\uff0c\u5e38\u7528\u53c2\u6570\u6709\u4e24\u79cd, \u5982\u4e0b:<\/p>\n\n\n\n<p>\u2460. \u663e\u793a\u591a\u4e2a\u6df7\u5408\u5728\u4e00\u8d77\u7684systemctl \u670d\u52a1\u65e5\u5fd7, \u4e00\u822c\u521a\u542f\u52a8\u5b8c\u4e00\u4e2aservice\u65f6\u67e5\u770b\u6bd4\u8f83\u65b9\u4fbf<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">journalctl -f<\/pre>\n\n\n\n<p>\u2461. \u53ea\u67e5\u770b\u67d0\u4e00\u4e2a\u5177\u4f53\u7684service\u670d\u52a1\u7684\u65e5\u5fd7<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>journalctl -u \u670d\u52a1\u540d<br> <br>\u5982:<br>2021-11-10 10:06:37 nn1 systemd: Started Bigdata KafkaManager.<br>2021-11-10 10:06:37 nn1 kafka-manager: This application is already running (Or delete \/opt\/software\/kafka-manager-1.3.3.23\/RUNNING_PID file).<br>2021-11-10 10:06:37 nn1 systemd: bigdata_kafkaManager.service: main process exited, code=exited, status=255\/n\/a<br>2021-11-10 10:06:37 nn1 systemd: Unit bigdata_kafkaManager.service entered failed state.<br>2021-11-10 10:06:37 nn1 systemd: bigdata_kafkaManager.service failed.<br>2021-11-10 10:06:46 nn1 bigdata_admin: root &#91;\/etc\/systemd\/system]2021-11-10 10:06:46 systemctl is-enabled bigdata_kafkaManager.service<br>2021-11-10 10:06:52 nn1 systemd: Reloading.<br>2021-11-10 10:06:53 nn1 systemd: &#91;\/run\/systemd\/generator.late\/cloudera-scm-server.service:13] Failed to add dependency on +cloudera-scm-server-db.service, ignoring: Invalid argument<br>2021-11-10 10:06:53 nn1 systemd: &#91;\/etc\/systemd\/system\/bigdata_kafkaManager.service:15] Unknown lvalue 'StartLimitIntervalSec' in section 'Service'<br>2021-11-10 10:06:53 nn1 bigdata_admin: root &#91;\/etc\/systemd\/system]2021-11-10 10:06:52 systemctl disable bigdata_kafkaManager.service<br>2021-11-10 10:07:02 nn1 systemd: Stopped Bigdata KafkaManager.<br>2021-11-10 10:07:02 nn1 systemd: &#91;\/etc\/systemd\/system\/bigdata_kafkaManager.service:15] Unknown lvalue 'StartLimitIntervalSec' in section 'Service'<br>2021-11-10 10:07:02 nn1 systemd: &#91;\/etc\/systemd\/system\/bigdata_kafkaManager.service:15] Unknown lvalue 'StartLimitIntervalSec' in section 'Service'<br>2021-11-10 10:07:02 nn1 bigdata_admin: root &#91;\/etc\/systemd\/system]2021-11-10 10:07:02 systemctl stop bigdata_kafkaManager.service<\/code><\/pre>\n\n\n\n<p>\u2462. \u901a\u8fc7 \"\u7cfb\u7edf\u65e5\u5fd7\" \u6765\u8fdb\u884c\u67e5\u8be2<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>tail -100f \/var\/log\/message<br> <br>2021-11-10 10:06:37 nn1 systemd: Started Bigdata KafkaManager.<br>2021-11-10 10:06:37 nn1 kafka-manager: This application is already running (Or delete \/opt\/software\/kafka-manager-1.3.3.23\/RUNNING_PID file).<br>2021-11-10 10:06:37 nn1 systemd: bigdata_kafkaManager.service: main process exited, code=exited, status=255\/n\/a<br>2021-11-10 10:06:37 nn1 systemd: Unit bigdata_kafkaManager.service entered failed state.<br>2021-11-10 10:06:37 nn1 systemd: bigdata_kafkaManager.service failed.<br>2021-11-10 10:06:46 nn1 bigdata_admin: root &#91;\/etc\/systemd\/system]2021-11-10 10:06:46 systemctl is-enabled bigdata_kafkaManager.service<br>2021-11-10 10:06:52 nn1 systemd: Reloading.<br>2021-11-10 10:06:53 nn1 systemd: &#91;\/run\/systemd\/generator.late\/cloudera-scm-server.service:13] Failed to add dependency on +cloudera-scm-server-db.service, ignoring: Invalid argument<br>2021-11-10 10:06:53 nn1 systemd: &#91;\/etc\/systemd\/system\/bigdata_kafkaManager.service:15] Unknown lvalue 'StartLimitIntervalSec' in section 'Service'<br>2021-11-10 10:06:53 nn1 bigdata_admin: root &#91;\/etc\/systemd\/system]2021-11-10 10:06:52 systemctl disable bigdata_kafkaManager.service<br>2021-11-10 10:07:02 nn1 systemd: Stopped Bigdata KafkaManager.<br>2021-11-10 10:07:02 nn1 systemd: &#91;\/etc\/systemd\/system\/bigdata_kafkaManager.service:15] Unknown lvalue 'StartLimitIntervalSec' in section 'Service'<br>2021-11-10 10:07:02 nn1 systemd: &#91;\/etc\/systemd\/system\/bigdata_kafkaManager.service:15] Unknown lvalue 'StartLimitIntervalSec' in section 'Service'<br>2021-11-10 10:07:02 nn1 bigdata_admin: root &#91;\/etc\/systemd\/system]2021-11-10 10:07:02 systemctl stop bigdata_kafkaManager.service<br>2021-11-10 10:07:24 nn1 bigdata_admin: root &#91;\/etc\/systemd\/system]2021-11-10 10:07:08 watch free -g<br>2021-11-10 10:07:24 nn1 bigdata_admin: root &#91;\/etc\/systemd\/system]2021-11-10 10:07:08 watch free -g<br>2021-11-10 10:07:24 nn1 bigdata_admin: root &#91;\/etc\/systemd\/system]2021-11-10 10:07:08 watch free -g<br>2021-11-10 10:18:20 nn1 bigdata_admin: root &#91;\/etc\/systemd\/system]2021-11-10 10:08:19 tail -100f \/var\/log\/messages<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\"><\/h1>\n\n\n\n<h1 class=\"wp-block-heading\"><strong>\u4e8c\u5341\u516d\u3001\u6301\u7eed\u76d1\u63a7Linux\u547d\u4ee4\u7684\u6267\u884c\u60c5\u51b5<\/strong><\/h1>\n\n\n\n<p>watch -d -n 1 ls -l<\/p>\n\n\n\n<p>\u53c2\u6570\u8bf4\u660e\uff1a<\/p>\n\n\n\n<p>\u2460\u3001-n\uff1a\u9ed8\u8ba4\u4e3a2s\u5237\u65b0\u4e00\u6b21\uff0c\u901a\u8fc7-n \u53c2\u6570\u66f4\u65b0\u5237\u65b0\u9891\u6b21\uff1b<\/p>\n\n\n\n<p>\u2461\u3001-d\uff1a\u65b9\u4fbf\u67e5\u770b\u8f93\u51fa\u4e0e\u4e0a\u6b21\u7684\u4e0d\u540c\u4e4b\u5904\u3002<\/p>\n\n\n\n<p>\u53c2\u8003\u535a\u6587\u5217\u8868\uff1a<\/p>\n\n\n\n<ol>\n<li><a href=\"https:\/\/www.cnblogs.com\/yjd_hycf_space\/p\/7730690.html\">Linux\u5e38\u7528\u547d\u4ee4\u5927\u5168\uff08\u975e\u5e38\u5168\uff01\uff01\uff01\uff09 - fcyh - \u535a\u5ba2\u56ed<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.cnblogs.com\/zhaihongliangblogger\/p\/6286773.html\">shell\u4e2dbreak \u4e0e continue - \u4eae\u54e5vvv - \u535a\u5ba2\u56ed<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.linuxprobe.com\/how-to-crontab.html\">crontab\u7528\u6cd5\u4e0e\u5b9e\u4f8b | \u300aLinux\u5c31\u8be5\u8fd9\u4e48\u5b66\u300b<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.jianshu.com\/p\/c999eefbc197\">\u6700\u8be6\u7ec6\u7684CentOS7\u8bbe\u7f6e\u81ea\u5b9a\u4e49\u5f00\u673a\u542f\u52a8\u670d\u52a1\u6559\u7a0b - \u7b80\u4e66<\/a>(centos7\u8bbe\u7f6e\u81ea\u5b9a\u4e49\u5f00\u673a\u542f\u52a8)<\/li>\n\n\n\n<li><a href=\"https:\/\/blog.csdn.net\/vv9951\/article\/details\/98494360\">Centos7\u5141\u8bb83306\u7aef\u53e3\u901a\u8fc7\u9632\u706b\u5899<em>vv\u5c0f\u98de\u7684\u4e13\u680f-CSDN\u535a\u5ba2<\/em>centos \u5141\u8bb8\u7aef\u53e3<\/a>(Centos7\u5141\u8bb83306\u7aef\u53e3\u901a\u8fc7\u9632\u706b\u5899)<\/li>\n\n\n\n<li><a href=\"https:\/\/blog.csdn.net\/yangshangwei\/article\/details\/52563123\">Linux\u5b57\u7b26\u622a\u53d6\u547d\u4ee4-cut_\u5c0f\u5de5\u5320-CSDN\u535a\u5ba2<\/a>(cut\u6587\u672c\u5904\u7406)<\/li>\n\n\n\n<li><a href=\"https:\/\/www.jianshu.com\/p\/bb51eee23820\">\u670d\u52a1\u5668\u65e5\u5fd7 \u4e4b CentOS7\u65e5\u5fd7\u7ba1\u7406\u5de5\u5177 journalctl - \u7b80\u4e66<\/a>(\u670d\u52a1\u5668\u65e5\u5fd7 \u4e4b CentOS7\u65e5\u5fd7\u7ba1\u7406\u5de5\u5177 journalctl)<\/li>\n\n\n\n<li><a href=\"https:\/\/www.cnblogs.com\/su-root\/p\/10743544.html\">echo \u5728shell\u53ca\u811a\u672c\u4e2d\u663e\u793a\u8272\u5f69\u53ca\u95ea\u70c1\u8b66\u544a\u6548\u679c - \u5357\u6e05\u98ce - \u535a\u5ba2\u56ed<\/a>(echo \u5728shell\u53ca\u811a\u672c\u4e2d\u663e\u793a\u8272\u5f69\u53ca\u95ea\u70c1\u8b66\u544a\u6548\u679c)<\/li>\n\n\n\n<li><a href=\"https:\/\/blog.csdn.net\/weixin_43314519\/article\/details\/106934678\">Linux\u547d\u4ee4\u5927\u5168\uff08\u6392\u7248\u6e05\u6670\uff01\uff01\u6301\u7eed\u66f4\u65b0\uff01\uff01\u975e\u5e38\u8be6\u7ec6\uff09<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.cnblogs.com\/51linux\/archive\/2012\/05\/23\/2515299.html\">Linux sort\u547d\u4ee4\u8be6\u89e3<\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Linux\u5e38\u7528\u547d\u4ee4\u5927\u5168\uff08\u975e\u5e38\u5168\u9762\uff09 2022-08-15 23:54:00 Linux\u548cwindows\u76f8\u6bd4\uff0c\u5f88 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1015,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,6,5],"tags":[52,51],"_links":{"self":[{"href":"https:\/\/blog.frost-s.com\/index.php\/wp-json\/wp\/v2\/posts\/1013"}],"collection":[{"href":"https:\/\/blog.frost-s.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.frost-s.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.frost-s.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.frost-s.com\/index.php\/wp-json\/wp\/v2\/comments?post=1013"}],"version-history":[{"count":4,"href":"https:\/\/blog.frost-s.com\/index.php\/wp-json\/wp\/v2\/posts\/1013\/revisions"}],"predecessor-version":[{"id":1029,"href":"https:\/\/blog.frost-s.com\/index.php\/wp-json\/wp\/v2\/posts\/1013\/revisions\/1029"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.frost-s.com\/index.php\/wp-json\/wp\/v2\/media\/1015"}],"wp:attachment":[{"href":"https:\/\/blog.frost-s.com\/index.php\/wp-json\/wp\/v2\/media?parent=1013"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.frost-s.com\/index.php\/wp-json\/wp\/v2\/categories?post=1013"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.frost-s.com\/index.php\/wp-json\/wp\/v2\/tags?post=1013"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}