{"id":2568,"date":"2015-12-12T10:44:02","date_gmt":"2015-12-12T02:44:02","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=2568"},"modified":"2015-12-12T10:44:02","modified_gmt":"2015-12-12T02:44:02","slug":"mac%e4%b8%ad%e7%9a%84linux%e5%91%bd%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/2568.html","title":{"rendered":"Mac\u4e2d\u7684Linux\u547d\u4ee4"},"content":{"rendered":"<p>=Start=<\/p>\n<h5>\u7f18\u7531<\/h5>\n<p>\u867d\u7136Mac\u7cfb\u7edf\u548cLinux\u7cfb\u7edf\u90fd\u662fUNIX-like\u7cfb\u7edf\uff0c\u5f88\u591a\u5730\u65b9\u90fd\u5f88\u50cf\uff0c\u89e3\u51b3\u65b9\u6848\u4e5f\u6bd4\u8f83\u901a\u7528\u2014\u2014\u5927\u540c\u5c0f\u5f02\uff0c\u4f46\u6709\u65f6\u5019\u5c31\u662f\u90a3\u4e48\u4e00\u70b9\u70b9\u7684\u4e0d\u540c\uff0c\u5bfc\u81f4\u672c\u6765\u5728Linux\u4e0a\u53ef\u4ee5work\u7684\u7a0b\u5e8f\u653e\u5230Mac\u4e0a\u5c31\u65e0\u6cd5work\u4e86\uff0c\u6700\u8fd1\u78b0\u5230\u4e86\u4e0d\u5c11\u8fd9\u6837\u7684\u6848\u4f8b\uff0c\u60f3\u7740\u6bcf\u6b21\u9047\u5230\u7684\u65f6\u5019\u90fd\u5f97\u91cd\u65b0Google\u8fd8\u662f\u4e0d\u592a\u65b9\u4fbf\uff0c\u4e8e\u662f\u5c31\u60f3\u627e\u4e2a\u5730\u65b9\u8bb0\u5f55\u4e0b\u6765\uff0c\u65b9\u4fbf\u81ea\u5df1\u548c\u540e\u6765\u8005\u3002<\/p>\n<h5>\u5185\u5bb9<\/h5>\n<h6>1.\u7528sed\u8fdb\u884c\u5c31\u5730\u66ff\u6362\uff08sed\u7684&#8217;-i&#8217;\u9009\u9879\uff09<\/h6>\n<pre class=\"lang:default decode:true\">$ chapter1\/1_1_local_machine_info.py\nenv: python\\r: No such file or directory\n#\u4e0a\u9762\u7684\u95ee\u9898\u5f88\u660e\u663e\u2014\u2014\u884c\u5c3e\u7684\u6362\u884c\u7b26\u662fWindows\u683c\u5f0f\u7684'\\r\\n'\uff0c\u800c\u4e0d\u662fLinux\u6216Mac\u7684'\\n'\uff0c\u5982\u679c\u60f3\u8981\u6b63\u5e38\u8fd0\u884c\uff0c\u9700\u8981\u5c06\u6587\u4ef6\u4e2d\u7684'\\r'\u5220\u9664\n\n#\u9519\u8bef\u4e00\n$ sed -i 's\/\\r$\/\/' chapter1\/1_1_local_machine_info.py\nsed: 1: \"chapter1\/1_1_local_mach ...\": command c expects \\ followed by text\n$ sed -i 's\/\\r\/\/' chapter1\/1_1_local_machine_info.py\nsed: 1: \"chapter1\/1_1_local_mach ...\": command c expects \\ followed by text\n#\u89e3\u91ca http:\/\/stackoverflow.com\/questions\/4247068\/sed-command-failing-on-mac-but-works-on-linux\n\n#\u9519\u8bef\u4e8c\n$ sed -i '' 's\/\\r\/\/' chapter1\/1_1_local_machine_info.py\n$ chapter1\/1_1_local_machine_info.py\nzsh: chapter1\/1_1_local_machine_info.py: bad interpreter: \/us\/bin\/env: no such file or directory\n#\u89e3\u91ca http:\/\/stackoverflow.com\/questions\/21621722\/removing-carriage-return-on-mac-os-x-using-sed\n\n#\u6b63\u786e\u65b9\u6cd5\n$ sed -i '' $'s\/\\r\/\/' chapter1\/1_1_local_machine_info.py\n#\u6279\u91cf\u66ff\u6362\n$ find \/path\/to -type f -iname \"*.py\" -print0 | xargs -0 -I {} sed -i '.bak' $'s\/\\r\/\/' {}<\/pre>\n<h6>2.\u5728Mac\u4e0a\u542f\u52a8MySQL\/Apache\u7b49\u670d\u52a1<\/h6>\n<pre class=\"lang:default decode:true\">#Mac\u4e0a\u542f\u52a8MySQL\u670d\u52a1\nmysql.server status\nmysql.server start\n\n#Mac\u4e0a\u542f\u52a8Apache\u670d\u52a1\napachectl -v\napachectl status\napachectl start<\/pre>\n<h6>3.\u67e5\u770b Mac \u7cfb\u7edf\u7684\u7aef\u53e3\u5f00\u653e\u60c5\u51b5<\/h6>\n<pre class=\"lang:default decode:true\">#\u67e5\u770b Mac \u7cfb\u7edf\u7684\u7aef\u53e3\u5f00\u653e\u60c5\u51b5\nnetstat -nat\nnetstat -nat | grep 3306\nnetstat -nat | grep LISTEN\nlsof -n -P -i TCP -s TCP:LISTEN<\/pre>\n<h5>\u53c2\u8003\u94fe\u63a5\uff1a<\/h5>\n<ul>\n<li><a href=\"http:\/\/www.cnphp6.com\/archives\/83481\" target=\"_blank\">http:\/\/www.cnphp6.com\/archives\/83481<\/a><\/li>\n<li><a href=\"http:\/\/ju.outofmemory.cn\/entry\/131947\" target=\"_blank\">http:\/\/ju.outofmemory.cn\/entry\/131947<\/a><\/li>\n<li><a href=\"http:\/\/my.oschina.net\/foreverich\/blog\/402252\" target=\"_blank\">http:\/\/my.oschina.net\/foreverich\/blog\/402252<\/a><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h6>\u5907\u6ce81\uff08Mac OS\u548cLinux\u7684\u4e0d\u540c\u4e4b\u5904\uff09\uff1a<\/h6>\n<p><a href=\"http:\/\/en.wikipedia.org\/wiki\/Mac_OS#Mac_OS_X\" target=\"_blank\">Mac OS<\/a> is based on a <a href=\"http:\/\/en.wikipedia.org\/wiki\/BSD\" target=\"_blank\">BSD<\/a> code base, while Linux is an independent development of a unix-like system. This means that these systems are similar, but not <a href=\"http:\/\/en.wikipedia.org\/wiki\/Binary_compatibility\" target=\"_blank\">binary compatible<\/a>.<\/p>\n<p>=EOF=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>=Start= \u7f18\u7531 \u867d\u7136Mac\u7cfb\u7edf\u548cLinux\u7cfb\u7edf\u90fd\u662fUNIX-like\u7cfb\u7edf\uff0c\u5f88\u591a\u5730\u65b9\u90fd\u5f88\u50cf\uff0c\u89e3\u51b3\u65b9\u6848\u4e5f\u6bd4\u8f83 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,11,560,12],"tags":[30,559,19],"class_list":["post-2568","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-linux","category-mac","category-tools","tag-linux","tag-mac","tag-tips"],"views":3042,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2568","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=2568"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2568\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=2568"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=2568"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=2568"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}