{"id":447,"date":"2017-09-02T23:11:47","date_gmt":"2017-09-02T15:11:47","guid":{"rendered":"https:\/\/i007.cc\/wordpress\/?p=447"},"modified":"2018-10-25T10:05:23","modified_gmt":"2018-10-25T02:05:23","slug":"40-%e4%b8%aa%e5%be%88%e6%9c%89%e7%94%a8%e7%9a%84-mac-os-x-shell-%e8%84%9a%e6%9c%ac%e5%92%8c%e7%bb%88%e7%ab%af%e5%91%bd%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/i007.cc\/wordpress\/archives\/447","title":{"rendered":"40 \u4e2a\u5f88\u6709\u7528\u7684 Mac OS X Shell \u811a\u672c\u548c\u7ec8\u7aef\u547d\u4ee4"},"content":{"rendered":"<header class=\"question-title-wrapper\"><span class=\"question-title-link\">40 \u4e2a\u5f88\u6709\u7528\u7684 Mac OS X Shell \u811a\u672c\u548c\u7ec8\u7aef\u547d\u4ee4<\/span><\/header>\n<section class=\"box content-container\">\n<aside class=\"box-fl\">\n<div class=\"vote_collect_wrapper\">\n<div class=\"vote_collect\"><span class=\"vote_count\">4<\/span><\/div>\n<p><a class=\"collect collect_question tooltipstered\" data-violet=\"collect\" data-ajax=\"https:\/\/www.oschina.net\/question\/_widgets\/_collect?id=62983\" data-tooltipster=\"{&quot;side&quot;:&quot;right&quot;,&quot;trigger&quot;:&quot;custom&quot;,&quot;triggerOpen&quot;:{&quot;mouseenter&quot;:true,&quot;click&quot;:true},&quot;triggerClose&quot;:{&quot;click&quot;:true,&quot;scroll&quot;:true,&quot;mouseleave&quot;: true}}\"><span class=\"collect-count\">\u6536\u85cf(147)<\/span><\/a><\/div>\n<\/aside>\n<header class=\"detail\">\n<section class=\"wrap cke_editable cke_editable_themed cke_contents_ltr cke_show_borders clearfix\">\u8fd9\u91cc\u6709\u4e00\u5806\u7684 Mac OS X \u4e0b\u7684\u7ec8\u7aef\u547d\u4ee4\uff0c\u6211\u5c06\u8fd9\u4e9b\u547d\u4ee4\u8fdb\u884c\u4e86\u7b80\u5355\u7684\u5206\u7c7b\uff0c\u8fd9\u91cc\u5f88\u591a\u547d\u4ee4\u5728\u5176\u4ed6\u7cfb\u7edf\uff08Windows\u3001Linux\uff09\u4e00\u6837\u6709\u6548\uff0c\u7279\u522b\u662f Linux\/Unix\u3002\u5e0c\u671b\u8fd9\u4e9b\u547d\u4ee4\u5bf9\u4f60\u6709\u5e2e\u52a9\u3002<\/p>\n<h3>\u7cfb\u7edf<\/h3>\n<p>\u91cd\u542f Mac OS X:<\/p>\n<pre class=\"hljs shell arduino\"><span class=\"hljs-built_in\">shutdown<\/span> - r now<\/pre>\n<p>\u5173\u95ed Mac OS X:<\/p>\n<pre class=\"hljs shell arduino\"><span class=\"hljs-built_in\">shutdown<\/span> now<\/pre>\n<h3>\u7535\u6e90\u7ba1\u7406\/\u7701\u7535<\/h3>\n<p>\u83b7\u53d6\u5f53\u524d\u7535\u6e90\u7ba1\u7406\u8bbe\u7f6e\u7684\u4fe1\u606f<\/p>\n<pre class=\"hljs shell ebnf\"><span class=\"hljs-attribute\">pmset -g<\/span><\/pre>\n<p>\u8bbe\u7f6e\u663e\u793a\u5668\u65e0\u6d3b\u52a815\u5206\u949f\u540e\u5173\u95ed<\/p>\n<pre class=\"hljs shell lsl\">sudo pmset displaysleep <span class=\"hljs-number\">15<\/span><\/pre>\n<p>\u8ba9\u8ba1\u7b97\u673a\u5728\u65e0\u6d3b\u52a830\u5206\u949f\u540e\u4f11\u7720<\/p>\n<pre class=\"hljs shell autoit\">sudo pmset <span class=\"hljs-built_in\">sleep<\/span> <span class=\"hljs-number\">30<\/span><\/pre>\n<h3>OS X \u5916\u89c2<\/h3>\n<p>\u7981\u7528\u4eea\u8868\u76d8\uff08\u522b\u5fd8\u4e86\u5c06\u4eea\u8868\u76d8 Dock \u56fe\u6807\u62d6\u52a8\u51fa\u6765\uff09<\/p>\n<pre class=\"hljs shell stylus\">defaults write com<span class=\"hljs-selector-class\">.apple<\/span><span class=\"hljs-selector-class\">.dashboard<\/span> mcx-disabled -boolean YES\nkillall Dock<\/pre>\n<p>\u542f\u7528\u4eea\u8868\u76d8<\/p>\n<pre class=\"hljs shell stylus\">defaults write com<span class=\"hljs-selector-class\">.apple<\/span><span class=\"hljs-selector-class\">.dashboard<\/span> mcx-disabled -boolean NO\nkillall Dock<\/pre>\n<p>\u5f3a\u5236 Finder \u7a0b\u5e8f\u663e\u793a\u9690\u85cf\u6587\u4ef6<\/p>\n<pre class=\"hljs shell stylus\">defaults write com<span class=\"hljs-selector-class\">.apple<\/span><span class=\"hljs-selector-class\">.finder<\/span> AppleShowAllFiles TRUE<\/pre>\n<p>\u5f3a\u5236 Finder \u7a0b\u5e8f\u4e0d\u663e\u793a\u9690\u85cf\u6587\u4ef6<\/p>\n<pre class=\"hljs shell stylus\">defaults write com<span class=\"hljs-selector-class\">.apple<\/span><span class=\"hljs-selector-class\">.finder<\/span> AppleShowAllFiles FALSE<\/pre>\n<h3>\u7f51\u7edc<\/h3>\n<p>ping \u67d0\u4e2a\u4e3b\u673a<\/p>\n<pre class=\"hljs shell dos\"><span class=\"hljs-built_in\">ping<\/span> -o oschina.<span class=\"hljs-built_in\">net<\/span><\/pre>\n<p>\u4f7f\u7528 traceroute \u8bca\u65ad\u5230\u67d0\u4e2a\u4e3b\u673a\u7684\u8def\u7531\u8282\u70b9<\/p>\n<pre class=\"hljs shell css\"><span class=\"hljs-selector-tag\">traceroute<\/span> <span class=\"hljs-selector-tag\">oschina<\/span><span class=\"hljs-selector-class\">.net<\/span><\/pre>\n<p>\u68c0\u67e5\u67d0\u4e2a\u4e3b\u673a\u662f\u5426\u8fd0\u884c HTTP \u670d\u52a1\uff0c\u6216\u8005\u68c0\u67e5\u67d0\u7f51\u7ad9\u662f\u5426\u53ef\u7528<\/p>\n<pre class=\"hljs shell 1c\">curl -I www.oschina.net <span class=\"hljs-string\">| head -n 1<\/span><\/pre>\n<p>\u7ba1\u7406 Windows \u7f51\u7edc\uff08\u76f8\u5f53\u4e8e Windows \u4e0b\u7684 NET \u547d\u4ee4\uff09\uff0c\u8be5\u547d\u4ee4\u6709\u5f88\u591a\u9009\u9879\uff0c\u8fd0\u884c\u4e0b\u9762\u547d\u4ee4\u6765\u67e5\u770b\u8fd9\u4e9b\u9009\u9879<\/p>\n<pre class=\"hljs shell stata\"><span class=\"hljs-keyword\">man<\/span> <span class=\"hljs-keyword\">net<\/span><\/pre>\n<p>\u4f7f\u7528 dig \u6765\u8bca\u65ad\u57df\u540d\u4fe1\u606f<\/p>\n<pre class=\"hljs shell stylus\">dig www<span class=\"hljs-selector-class\">.oschina<\/span><span class=\"hljs-selector-class\">.net<\/span> A\ndig www<span class=\"hljs-selector-class\">.oschina<\/span><span class=\"hljs-selector-class\">.net<\/span> MX<\/pre>\n<p>\u67e5\u770b\u8c01\u6b63\u5728\u767b\u5f55\u5230\u4f60\u7684 Mac \u673a\u5668<\/p>\n<pre class=\"hljs shell ebnf\"><span class=\"hljs-attribute\">w<\/span><\/pre>\n<p>\u663e\u793a\u7cfb\u7edf\u8def\u7531\u8868<\/p>\n<pre class=\"hljs shell ebnf\"><span class=\"hljs-attribute\">netstat -r<\/span><\/pre>\n<p>\u663e\u793a\u6d3b\u52a8\u7f51\u7edc\u8fde\u63a5<\/p>\n<pre class=\"hljs shell ebnf\"><span class=\"hljs-attribute\">netstat -an<\/span><\/pre>\n<p>\u663e\u793a\u7f51\u7edc\u7edf\u8ba1<\/p>\n<pre class=\"hljs shell bash\">netstat <span class=\"hljs-_\">-s<\/span><\/pre>\n<h3>\u6545\u969c\u8bca\u65ad<\/h3>\n<p>\u5217\u8868\u6240\u6709\u6253\u5f00\u7684\u6587\u4ef6<\/p>\n<pre class=\"hljs shell ebnf\"><span class=\"hljs-attribute\">lsof<\/span><\/pre>\n<p>\u91cd\u542f Bonjour \u2013 \u5f53\u7f51\u7edc\u4e2d\u6ca1\u6709 Mac \u65f6\u5f88\u6709\u7528<\/p>\n<pre class=\"hljs shell stylus\">sudo launchctl unload \/System\/Library\/LaunchDaemons\/com<span class=\"hljs-selector-class\">.apple<\/span><span class=\"hljs-selector-class\">.mDNSResponder<\/span><span class=\"hljs-selector-class\">.plist<\/span>\nsudo launchctl load \/System\/Library\/LaunchDaemons\/com<span class=\"hljs-selector-class\">.apple<\/span><span class=\"hljs-selector-class\">.mDNSResponder<\/span><span class=\"hljs-selector-class\">.plist<\/span><\/pre>\n<p>\u5f39\u51fa CD \uff08\u6ce8\u610f\u4e0d\u4e00\u5b9a\u662f disk1\uff09<\/p>\n<pre class=\"hljs shell mipsasm\"><span class=\"hljs-keyword\">diskutil <\/span>eject <span class=\"hljs-keyword\">disk1<\/span><\/pre>\n<h3>\u6587\u672c\u64cd\u4f5c\u547d\u4ee4<\/h3>\n<p><em>\u7ecf\u5e38\u4f60\u9700\u8981\u4ece\u526a\u5207\u677f\u6216\u8005\u6587\u4ef6\u4e2d\u83b7\u53d6\u67d0\u4e9b\u6587\u672c\uff0c\u5e76\u5bf9\u8fd9\u4e9b\u6587\u672c\u8fdb\u884c\u8f6c\u6362\u548c\u4f7f\u7528\uff0c\u8fd9\u91cc\u5217\u4e3e\u7684\u547d\u4ee4\u90fd\u662f\u8ddf\u6587\u672c\u5904\u7406\u76f8\u5173\u7684<\/em><\/p>\n<p>\u7edf\u8ba1\u526a\u8d34\u677f\u4e2d\u6587\u672c\u7684\u884c\u6570<\/p>\n<pre class=\"hljs shell 1c\">pbpaste <span class=\"hljs-string\">| wc -l<\/span><\/pre>\n<p>\u7edf\u8ba1\u526a\u8d34\u677f\u4e2d\u6587\u672c\u7684\u5355\u8bcd\u6570<\/p>\n<pre class=\"hljs shell 1c\">pbpaste <span class=\"hljs-string\">| wc -w<\/span><\/pre>\n<p>\u5bf9\u526a\u8d34\u677f\u4e2d\u7684\u6587\u672c\u884c\u8fdb\u884c\u6392\u5e8f\u540e\u91cd\u65b0\u5199\u56de\u526a\u8d34\u677f<\/p>\n<pre class=\"hljs shell coq\">pbpaste | <span class=\"hljs-type\">sort<\/span> | <span class=\"hljs-type\">pbcopy<\/span><\/pre>\n<p>\u5bf9\u526a\u8d34\u677f\u4e2d\u7684\u6587\u672c\u884c\u8fdb\u884c\u5012\u5e8f\u540e\u653e\u56de\u526a\u8d34\u677f<\/p>\n<pre class=\"hljs shell coq\">pbpaste | <span class=\"hljs-type\">rev<\/span> | <span class=\"hljs-type\">pbcopy<\/span><\/pre>\n<p>\u79fb\u9664\u526a\u8d34\u677f\u4e2d\u91cd\u590d\u7684\u6587\u672c\u884c\uff0c\u7136\u540e\u5199\u56de\u526a\u8d34\u677f<\/p>\n<pre class=\"hljs shell coq\">pbpaste | <span class=\"hljs-type\">sort<\/span> | <span class=\"hljs-type\">uniq<\/span> | <span class=\"hljs-type\">pbcopy<\/span><\/pre>\n<p>\u627e\u51fa\u526a\u8d34\u677f\u4e2d\u6587\u672c\u4e2d\u5b58\u5728\u7684\u91cd\u590d\u884c\uff0c\u5e76\u590d\u5236\u540e\u5199\u56de\u526a\u8d34\u677f\uff08\u5305\u542b\u91cd\u590d\u884c\u7684\u4e00\u884c\uff09<\/p>\n<pre class=\"hljs shell coq\">pbpaste | <span class=\"hljs-type\">sort<\/span> | <span class=\"hljs-type\">uniq<\/span> -d | <span class=\"hljs-type\">pbcopy<\/span><\/pre>\n<p>\u627e\u51fa\u526a\u8d34\u677f\u4e2d\u6587\u672c\u4e2d\u5b58\u5728\u7684\u91cd\u590d\u884c\uff0c\u5e76\u590d\u5236\u540e\u5199\u56de\u526a\u8d34\u677f\uff08\u4e0d\u5305\u542b\u91cd\u590d\u884c\uff09<\/p>\n<pre class=\"hljs shell coq\">pbpaste | <span class=\"hljs-type\">sort<\/span> | <span class=\"hljs-type\">uniq<\/span> -u | <span class=\"hljs-type\">pbcopy<\/span><\/pre>\n<p>\u5bf9\u526a\u8d34\u677f\u4e2d\u7684 HTML \u6587\u672c\u8fdb\u884c\u6e05\u7406\u540e\u5199\u56de\u526a\u8d34\u677f<\/p>\n<pre class=\"hljs shell coq\">pbpaste | <span class=\"hljs-type\">tidy<\/span> | <span class=\"hljs-type\">pbcopy<\/span><\/pre>\n<p>\u663e\u793a\u526a\u8d34\u677f\u4e2d\u6587\u672c\u7684\u524d 5 \u884c<\/p>\n<pre class=\"hljs shell 1c\">pbpaste <span class=\"hljs-string\">| head -n 5<\/span><\/pre>\n<p>\u663e\u793a\u526a\u8d34\u677f\u4e2d\u6587\u672c\u7684\u6700\u540e 5 \u884c<\/p>\n<pre class=\"hljs shell 1c\">pbpaste <span class=\"hljs-string\">| tail -n 5<\/span><\/pre>\n<p>\u5c06\u526a\u8d34\u677f\u4e2d\u6587\u672c\u91cc\u5b58\u5728\u7684 Tab \u8df3\u683c\u7b26\u53f7\u8f6c\u6210\u7a7a\u683c<\/p>\n<pre class=\"hljs shell coq\">pbpaste | <span class=\"hljs-type\">expand<\/span> | <span class=\"hljs-type\">pbcopy<\/span><\/pre>\n<h3>\u5176\u4ed6\u6709\u7528\u7684\u547d\u4ee4<\/h3>\n<h4>A:<\/h4>\n<pre class=\"hljs shell ebnf\"><span class=\"hljs-attribute\">htpasswd -nb username password<\/span><\/pre>\n<h4>B:<\/h4>\n<pre class=\"hljs shell coffeescript\">AuthType Basic\nAuthName <span class=\"hljs-string\">\"restricted area\"<\/span>\nAuthUserFile <span class=\"hljs-regexp\">\/path\/to\/your\/site\/<\/span>.htpasswd\n<span class=\"hljs-built_in\">require<\/span> valid-user<\/pre>\n<p>\u663e\u793a\u7ec8\u7aef\u7a97\u53e3\u4e2d\u4e4b\u524d\u8f93\u5165\u7684\u547d\u4ee4<\/p>\n<pre class=\"hljs shell bash\"><span class=\"hljs-built_in\">history<\/span><\/pre>\n<p>\u5c06\u6587\u4ef6\u8f6c\u6210 HTML\uff0c\u652f\u6301\u683c\u5f0f\u5305\u62ec Text, .RTF, .DOC.<\/p>\n<pre class=\"hljs shell livecodeserver\">textutil -<span class=\"hljs-built_in\">convert<\/span> html <span class=\"hljs-built_in\">file<\/span>.extension<\/pre>\n<p>Nano \u662f\u4e00\u4e2a\u5f88\u7b80\u5355\u6613\u7528\u7684\u6587\u672c\u7f16\u8f91\u5668\uff0c\u53ef\u7528\u4e8e\u5feb\u901f\u66f4\u6539\u6587\u672c\u6587\u4ef6\uff0c\u6bd4 vim \u529f\u80fd\u5f31\u5f88\u591a\uff0c\u4f46\u5f88\u65b9\u4fbf<\/p>\n<pre class=\"hljs shell accesslog\">nano <span class=\"hljs-string\">[file_to_edit]<\/span><\/pre>\n<p>\u5728 nano \u7f16\u8f91\u5668\u4e2d\uff0c\u53ef\u4f7f\u7528 ctrl+o \u6765\u4fdd\u6301\uff0cctrl+x \u6765\u9000\u51fa\u3002<\/p>\n<p>\u6e05\u7406\u7ec8\u7aef\u663e\u793a\u7684\u5185\u5bb9<\/p>\n<pre class=\"hljs shell arduino\"><span class=\"hljs-built_in\">clear<\/span><\/pre>\n<h3>iTunes \u76f8\u5173<\/h3>\n<p>\u66f4\u6539 iTunes \u94fe\u63a5\u884c\u4e3a\u4e3a\u672c\u673a iTunes \u5e93\uff0c\u800c\u4e0d\u662f iTunes Store<\/p>\n<pre class=\"hljs shell stylus\">defaults write com<span class=\"hljs-selector-class\">.apple<\/span><span class=\"hljs-selector-class\">.iTunes<\/span> invertStoreLinks -bool YES<\/pre>\n<p>\u66f4\u6539 iTunes \u94fe\u63a5\u884c\u4e3a\u4e3a iTunes Store\uff0c\u800c\u4e0d\u662f\u672c\u673a iTunes \u5e93<\/p>\n<pre class=\"hljs shell stylus\">defaults write com<span class=\"hljs-selector-class\">.apple<\/span><span class=\"hljs-selector-class\">.iTunes<\/span> invertStoreLinks -bool NO<\/pre>\n<h3>\u5176\u4ed6 Mac OS X \u7ec8\u7aef\u8d44\u6e90<\/h3>\n<p><a href=\"http:\/\/www.kernelthread.com\/mac\/osx\/tools.html\" rel=\"nofollow\">Mac OS X Hacking Tools<\/a>\u00a0(old but detailed list for the obsessive only).<\/p>\n<p><a href=\"http:\/\/hayne.net\/MacDev\/Bash\/\" rel=\"nofollow\">Cameron Hayne\u2019s Bash Scripts<\/a><\/p>\n<p><a href=\"http:\/\/www.macosxhints.com\/\" rel=\"nofollow\">Mac OS X Hints<\/a><\/p>\n<p><a href=\"http:\/\/discussions.apple.com\/\" rel=\"nofollow\">Apple Forums<\/a><\/p>\n<p>\u6ce8\u610f: \u524d\u9762\u7684\u5f88\u591a\u4f8b\u5b50\u6211\u4eec\u7528\u4e86 pbpaste \u6765\u4ece\u526a\u8d34\u677f\u4e2d\u83b7\u53d6\u6570\u636e\uff0c\u4e5f\u53ef\u4f7f\u7528 cat \u6765\u4ece\u6587\u4ef6\u4e2d\u83b7\u53d6\u6570\u636e<\/p>\n<pre class=\"hljs shell vim\"><span class=\"hljs-keyword\">cat<\/span> [\/path\/<span class=\"hljs-keyword\">to<\/span>\/filename]<\/pre>\n<p>\u8981\u5c06\u7ed3\u679c\u653e\u5230\u684c\u9762\u7684\u4e00\u4e2a\u6587\u4ef6\uff0c\u53ef\u5c06 pbcopy \u66ff\u6362\u4e3a\uff1a<\/p>\n<pre class=\"hljs shell awk\">&gt; ~<span class=\"hljs-regexp\">\/Desktop\/<\/span>filename.txt<\/pre>\n<\/section>\n<\/header>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>40 \u4e2a\u5f88\u6709\u7528\u7684 Mac OS X Sh<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[],"tags":[123],"class_list":["post-447","post","type-post","status-publish","format-standard","hentry","tag-07-mac"],"_links":{"self":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/447","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/comments?post=447"}],"version-history":[{"count":0,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/posts\/447\/revisions"}],"wp:attachment":[{"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/media?parent=447"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/categories?post=447"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/i007.cc\/wordpress\/wp-json\/wp\/v2\/tags?post=447"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}