{"id":341,"date":"2022-07-14T10:00:53","date_gmt":"2022-07-14T02:00:53","guid":{"rendered":"http:\/\/106.52.213.145:21080\/?p=341"},"modified":"2025-07-14T10:02:30","modified_gmt":"2025-07-14T02:02:30","slug":"341","status":"publish","type":"post","link":"https:\/\/apifj.com\/index.php\/2022\/07\/14\/341\/","title":{"rendered":"Ubuntu \u57fa\u7840\u547d\u4ee4\u6587\u6863"},"content":{"rendered":"<h1>Ubuntu \u57fa\u7840\u547d\u4ee4\u6587\u6863<\/h1>\n<p>\u672c\u6587\u6863\u9002\u7528\u4e8e\u521a\u63a5\u89e6 Ubuntu \u7cfb\u7edf\u7684\u65b0\u624b\uff0c\u8986\u76d6\u65e5\u5e38\u64cd\u4f5c\u3001\u6587\u4ef6\u7ba1\u7406\u3001\u7cfb\u7edf\u76d1\u63a7\u3001\u7f51\u7edc\u5de5\u5177\u7b49\u6838\u5fc3\u547d\u4ee4\uff0c\u5e2e\u52a9\u5feb\u901f\u719f\u6089 Linux \u73af\u5883\u3002\u5185\u5bb9\u8bbe\u8ba1\u517c\u987e\u901a\u7528\u6027\u4e0e\u6a21\u578b\u8bad\u7ec3\u573a\u666f\uff08\u5982\u6587\u4ef6\u4f20\u8f93\u3001\u5305\u7ba1\u7406\u3001\u8fdb\u7a0b\u76d1\u63a7\u7b49\uff09\uff0c\u9002\u5408\u4f5c\u4e3a\u5165\u95e8\u53c2\u8003\u3002  <\/p>\n<hr \/>\n<h2>\u4e00\u3001\u57fa\u7840\u6982\u5ff5\u4e0e\u51c6\u5907<\/h2>\n<h3>1.1 \u7ec8\u7aef\uff08Terminal\uff09<\/h3>\n<p>Ubuntu \u7684\u547d\u4ee4\u884c\u64cd\u4f5c\u754c\u9762\uff0c\u6240\u6709\u547d\u4ee4\u9700\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u3002  <\/p>\n<ul>\n<li>\u6253\u5f00\u7ec8\u7aef\uff1a<code>Ctrl + Alt + T<\/code>\uff08\u6700\u5e38\u7528\uff09\uff1b\u6216\u901a\u8fc7\u83dc\u5355\u641c\u7d22\u201c\u7ec8\u7aef\u201d\u3002  <\/li>\n<li>\u547d\u4ee4\u683c\u5f0f\uff1a<code>\u547d\u4ee4 [\u9009\u9879] [\u53c2\u6570]<\/code>\uff08\u9009\u9879\u4ee5<code>-<\/code>\u6216<code>--<\/code>\u5f00\u5934\uff0c\u53c2\u6570\u662f\u64cd\u4f5c\u5bf9\u8c61\uff09\u3002  <\/li>\n<\/ul>\n<hr \/>\n<h2>\u4e8c\u3001\u57fa\u7840\u6587\u4ef6\u4e0e\u76ee\u5f55\u64cd\u4f5c<\/h2>\n<h3>2.1 \u67e5\u770b\u5f53\u524d\u76ee\u5f55\uff08<code>pwd<\/code>\uff09<\/h3>\n<p><strong>\u4f5c\u7528<\/strong>\uff1a\u663e\u793a\u5f53\u524d\u6240\u5728\u7684\u7edd\u5bf9\u8def\u5f84\uff08\u4ece\u6839\u76ee\u5f55<code>\/<\/code>\u5f00\u59cb\u7684\u5b8c\u6574\u8def\u5f84\uff09\u3002<br \/>\n<strong>\u793a\u4f8b<\/strong>\uff1a  <\/p>\n<pre><code class=\"language-bash\">pwd   # \u8f93\u51fa\u7c7b\u4f3c\uff1a\/home\/username\/Documents<\/code><\/pre>\n<h3>2.2 \u5217\u51fa\u76ee\u5f55\u5185\u5bb9\uff08<code>ls<\/code>\uff09<\/h3>\n<p><strong>\u4f5c\u7528<\/strong>\uff1a\u67e5\u770b\u5f53\u524d\u76ee\u5f55\u6216\u6307\u5b9a\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\/\u6587\u4ef6\u5939\u3002<br \/>\n<strong>\u5e38\u7528\u9009\u9879<\/strong>\uff1a  <\/p>\n<ul>\n<li><code>-l<\/code>\uff1a\u957f\u683c\u5f0f\u663e\u793a\uff08\u8be6\u7ec6\u4fe1\u606f\uff1a\u6743\u9650\u3001\u5927\u5c0f\u3001\u4fee\u6539\u65f6\u95f4\u7b49\uff09\u3002  <\/li>\n<li><code>-a<\/code>\uff1a\u663e\u793a\u6240\u6709\u6587\u4ef6\uff08\u5305\u62ec\u9690\u85cf\u6587\u4ef6\uff0c\u4ee5<code>.<\/code>\u5f00\u5934\uff09\u3002  <\/li>\n<li><code>-h<\/code>\uff1a\u914d\u5408<code>-l<\/code>\uff0c\u4ee5\u4eba\u7c7b\u53ef\u8bfb\u7684\u683c\u5f0f\u663e\u793a\u5927\u5c0f\uff08\u5982<code>2K<\/code>\u3001<code>1.5G<\/code>\uff09\u3002<br \/>\n<strong>\u793a\u4f8b<\/strong>\uff1a  <\/p>\n<pre><code class=\"language-bash\">ls          # \u663e\u793a\u5f53\u524d\u76ee\u5f55\u975e\u9690\u85cf\u6587\u4ef6  \nls -l       # \u957f\u683c\u5f0f\u663e\u793a\uff08\u793a\u4f8b\u8f93\u51fa\uff1a-rw-r--r-- 1 user user 1024 Jun 1 12:00 file.txt\uff09  \nls -lh ~    # \u957f\u683c\u5f0f+\u53ef\u8bfb\u5927\u5c0f\uff0c\u67e5\u770b\u7528\u6237\u5bb6\u76ee\u5f55\uff08~\u4ee3\u8868\u7528\u6237\u4e3b\u76ee\u5f55\uff09  <\/code><\/pre>\n<\/li>\n<\/ul>\n<h3>2.3 \u5207\u6362\u76ee\u5f55\uff08<code>cd<\/code>\uff09<\/h3>\n<p><strong>\u4f5c\u7528<\/strong>\uff1a\u8fdb\u5165\u6307\u5b9a\u76ee\u5f55\u3002<br \/>\n<strong>\u5e38\u7528\u53c2\u6570<\/strong>\uff1a  <\/p>\n<ul>\n<li><code>..<\/code>\uff1a\u7236\u76ee\u5f55\uff08\u4e0a\u4e00\u7ea7\uff09\u3002  <\/li>\n<li><code>.<\/code>\uff1a\u5f53\u524d\u76ee\u5f55\u3002  <\/li>\n<li><code>~<\/code>\uff1a\u7528\u6237\u4e3b\u76ee\u5f55\uff08\u5982<code>\/home\/username<\/code>\uff09\u3002  <\/li>\n<li><code>\/<\/code>\uff1a\u6839\u76ee\u5f55\uff08\u6240\u6709\u76ee\u5f55\u7684\u8d77\u70b9\uff09\u3002<br \/>\n<strong>\u793a\u4f8b<\/strong>\uff1a  <\/p>\n<pre><code class=\"language-bash\">cd Documents          # \u8fdb\u5165\u5f53\u524d\u76ee\u5f55\u4e0b\u7684 Documents \u6587\u4ef6\u5939  \ncd ..                 # \u8fd4\u56de\u4e0a\u4e00\u7ea7\u76ee\u5f55  \ncd ~                  # \u56de\u5230\u7528\u6237\u4e3b\u76ee\u5f55  \ncd \/usr\/local         # \u8fdb\u5165\u7edd\u5bf9\u8def\u5f84 \/usr\/local \u76ee\u5f55  <\/code><\/pre>\n<\/li>\n<\/ul>\n<h3>2.4 \u521b\u5efa\/\u5220\u9664\u76ee\u5f55\uff08<code>mkdir<\/code>\/<code>rmdir<\/code>\uff09<\/h3>\n<ul>\n<li><strong><code>mkdir<\/code><\/strong>\uff1a\u521b\u5efa\u65b0\u76ee\u5f55\u3002\n<pre><code class=\"language-bash\">mkdir projects                  # \u5728\u5f53\u524d\u76ee\u5f55\u521b\u5efa projects \u6587\u4ef6\u5939  \nmkdir -p data\/train             # \u9012\u5f52\u521b\u5efa\u591a\u7ea7\u76ee\u5f55\uff08\u82e5\u7236\u76ee\u5f55\u4e0d\u5b58\u5728\u5219\u81ea\u52a8\u521b\u5efa\uff09  <\/code><\/pre>\n<\/li>\n<li><strong><code>rmdir<\/code><\/strong>\uff1a\u5220\u9664\u7a7a\u76ee\u5f55\uff08\u4ec5\u5f53\u76ee\u5f55\u4e3a\u7a7a\u65f6\u6709\u6548\uff09\u3002\n<pre><code class=\"language-bash\">rmdir empty_dir                 # \u5220\u9664\u7a7a\u76ee\u5f55  <\/code><\/pre>\n<\/li>\n<\/ul>\n<h3>2.5 \u6587\u4ef6\u64cd\u4f5c\uff08<code>touch<\/code>\/<code>cp<\/code>\/<code>mv<\/code>\/<code>rm<\/code>\uff09<\/h3>\n<ul>\n<li><strong><code>touch<\/code><\/strong>\uff1a\u521b\u5efa\u7a7a\u6587\u4ef6\u6216\u66f4\u65b0\u6587\u4ef6\u65f6\u95f4\u6233\u3002\n<pre><code class=\"language-bash\">touch note.txt                  # \u521b\u5efa note.txt \u6587\u4ef6\uff08\u82e5\u5df2\u5b58\u5728\u5219\u66f4\u65b0\u4fee\u6539\u65f6\u95f4\uff09  <\/code><\/pre>\n<\/li>\n<li><strong><code>cp<\/code><\/strong>\uff1a\u590d\u5236\u6587\u4ef6\/\u76ee\u5f55\u3002\n<pre><code class=\"language-bash\">cp file.txt backup\/             # \u5c06 file.txt \u590d\u5236\u5230 backup \u76ee\u5f55  \ncp -r src\/ dest\/                # \u9012\u5f52\u590d\u5236\u76ee\u5f55\uff08-r \u8868\u793a\u9012\u5f52\uff0c\u5fc5\u9009\uff01\uff09  <\/code><\/pre>\n<\/li>\n<li><strong><code>mv<\/code><\/strong>\uff1a\u79fb\u52a8\u6587\u4ef6\/\u76ee\u5f55\uff08\u6216\u91cd\u547d\u540d\uff09\u3002\n<pre><code class=\"language-bash\">mv data.csv \/tmp                # \u5c06 data.csv \u79fb\u52a8\u5230 \/tmp \u76ee\u5f55  \nmv old_name.py new_name.py      # \u91cd\u547d\u540d\u6587\u4ef6\uff08\u672c\u8d28\u662f\u79fb\u52a8\u5230\u540c\u76ee\u5f55+\u65b0\u540d\u79f0)  <\/code><\/pre>\n<\/li>\n<li><strong><code>rm<\/code><\/strong>\uff1a\u5220\u9664\u6587\u4ef6\/\u76ee\u5f55\uff08<strong>\u5371\u9669\u64cd\u4f5c\uff01<\/strong>\uff09\u3002\n<pre><code class=\"language-bash\">rm test.txt                     # \u5220\u9664 test.txt \u6587\u4ef6\uff08\u65e0\u6cd5\u6062\u590d\uff01\uff09  \nrm -r logs\/                     # \u9012\u5f52\u5220\u9664\u76ee\u5f55 logs\uff08\u76ee\u5f55\u975e\u7a7a\u65f6\u5fc5\u9009 -r\uff09  \n# \u6ce8\u610f\uff1arm -rf \/ \u4f1a\u5220\u9664\u6574\u4e2a\u7cfb\u7edf\uff01\u65b0\u624b\u5207\u52ff\u5c1d\u8bd5\uff01  <\/code><\/pre>\n<\/li>\n<\/ul>\n<hr \/>\n<h2>\u4e09\u3001\u7cfb\u7edf\u4fe1\u606f\u4e0e\u76d1\u63a7<\/h2>\n<h3>3.1 \u67e5\u770b\u7cfb\u7edf\/\u786c\u4ef6\u4fe1\u606f<\/h3>\n<ul>\n<li><strong><code>uname<\/code><\/strong>\uff1a\u67e5\u770b\u7cfb\u7edf\u5185\u6838\u4fe1\u606f\u3002\n<pre><code class=\"language-bash\">uname -a                         # \u663e\u793a\u5b8c\u6574\u5185\u6838\u4fe1\u606f\uff08\u5982 Linux ubuntu 5.4.0-100-generic\uff09  <\/code><\/pre>\n<\/li>\n<li><strong><code>df<\/code><\/strong>\uff1a\u67e5\u770b\u78c1\u76d8\u7a7a\u95f4\u5360\u7528\uff08<code>-h<\/code> \u53ef\u8bfb\u683c\u5f0f\uff09\u3002\n<pre><code class=\"language-bash\">df -h                            # \u8f93\u51fa\uff1aFilesystem Size Used Avail Use% Mounted on  <\/code><\/pre>\n<\/li>\n<li><strong><code>free<\/code><\/strong>\uff1a\u67e5\u770b\u5185\u5b58\/swap \u4f7f\u7528\u60c5\u51b5\uff08<code>-h<\/code> \u53ef\u8bfb\u683c\u5f0f\uff09\u3002\n<pre><code class=\"language-bash\">free -h                          # \u8f93\u51fa\uff1aMem: 7.7G 2.3G 5.4G ...  <\/code><\/pre>\n<\/li>\n<\/ul>\n<h3>3.2 \u8fdb\u7a0b\u76d1\u63a7\uff08<code>top<\/code>\/<code>htop<\/code>\uff09<\/h3>\n<ul>\n<li><strong><code>top<\/code><\/strong>\uff1a\u5b9e\u65f6\u76d1\u63a7\u8fdb\u7a0b\u8d44\u6e90\u5360\u7528\uff08\u6309<code>q<\/code>\u9000\u51fa\uff09\u3002\n<pre><code class=\"language-bash\">top                              # \u663e\u793a CPU\u3001\u5185\u5b58\u5360\u7528\u6700\u9ad8\u7684\u8fdb\u7a0b  <\/code><\/pre>\n<\/li>\n<li><strong><code>htop<\/code><\/strong>\uff08\u9700\u5148\u5b89\u88c5\uff09\uff1a\u66f4\u53cb\u597d\u7684\u4ea4\u4e92\u5f0f\u8fdb\u7a0b\u76d1\u63a7\u5de5\u5177\uff08\u529f\u80fd\u66f4\u5f3a\u5927\uff09\u3002\n<pre><code class=\"language-bash\">sudo apt install htop            # \u5b89\u88c5 htop  \nhtop                             # \u542f\u52a8\u76d1\u63a7\uff08\u652f\u6301\u9f20\u6807\u64cd\u4f5c\uff09  <\/code><\/pre>\n<\/li>\n<\/ul>\n<h3>3.3 \u67e5\u770b\u7528\u6237\u4e0e\u767b\u5f55\u4fe1\u606f<\/h3>\n<ul>\n<li><strong><code>whoami<\/code><\/strong>\uff1a\u663e\u793a\u5f53\u524d\u767b\u5f55\u7528\u6237\u540d\u3002\n<pre><code class=\"language-bash\">whoami                           # \u8f93\u51fa\uff1ausername  <\/code><\/pre>\n<\/li>\n<li><strong><code>w<\/code><\/strong>\uff1a\u67e5\u770b\u5f53\u524d\u767b\u5f55\u7528\u6237\u53ca\u6d3b\u52a8\u3002\n<pre><code class=\"language-bash\">w                                # \u8f93\u51fa\uff1a10:00:00 up 2 days, 2 users, load average: 0.12, 0.05, 0.01  <\/code><\/pre>\n<\/li>\n<\/ul>\n<hr \/>\n<h2>\u56db\u3001\u7f51\u7edc\u76f8\u5173\u547d\u4ee4<\/h2>\n<h3>4.1 \u67e5\u770b\u7f51\u7edc\u72b6\u6001\uff08<code>ip<\/code>\/<code>ping<\/code>\uff09<\/h3>\n<ul>\n<li><strong><code>ip addr<\/code><\/strong>\uff1a\u67e5\u770b\u7f51\u5361\u4fe1\u606f\uff08\u66ff\u4ee3\u65e7\u7248<code>ifconfig<\/code>\uff09\u3002\n<pre><code class=\"language-bash\">ip addr                          # \u8f93\u51fa\uff1aeth0: <BROADCAST,MULTICAST,UP> mtu 1500 ...  <\/code><\/pre>\n<\/li>\n<li><strong><code>ping<\/code><\/strong>\uff1a\u6d4b\u8bd5\u7f51\u7edc\u8fde\u901a\u6027\uff08<code>-c<\/code> \u6307\u5b9a\u6b21\u6570\uff09\u3002\n<pre><code class=\"language-bash\">ping -c 5 www.baidu.com          # \u5411\u767e\u5ea6\u53d1\u9001 5 \u6b21 ICMP \u8bf7\u6c42\uff08\u6d4b\u8bd5\u7f51\u7edc\u662f\u5426\u901a\uff09  <\/code><\/pre>\n<\/li>\n<\/ul>\n<h3>4.2 \u6587\u4ef6\u4f20\u8f93\uff08<code>scp<\/code>\uff09<\/h3>\n<p><strong>\u4f5c\u7528<\/strong>\uff1a\u901a\u8fc7 SSH \u534f\u8bae\u5728\u672c\u5730\u4e0e\u8fdc\u7a0b\u670d\u52a1\u5668\u95f4\u4f20\u8f93\u6587\u4ef6\uff08\u6a21\u578b\u8bad\u7ec3\u5e38\u7528\uff09\u3002<br \/>\n<strong>\u683c\u5f0f<\/strong>\uff1a<code>scp [\u9009\u9879] \u672c\u5730\u8def\u5f84 \u8fdc\u7a0b\u7528\u6237@\u8fdc\u7a0bIP:\u8fdc\u7a0b\u8def\u5f84<\/code>\uff08\u6216\u53cd\u5411\uff09\u3002<br \/>\n<strong>\u793a\u4f8b<\/strong>\uff1a  <\/p>\n<pre><code class=\"language-bash\"># \u672c\u5730 \u2192 \u8fdc\u7a0b\uff08\u4e0a\u4f20\uff09  \nscp \/home\/user\/model.pth root@192.168.1.100:\/data\/models\/  \n\n# \u8fdc\u7a0b \u2192 \u672c\u5730\uff08\u4e0b\u8f7d\uff09  \nscp root@192.168.1.100:\/data\/logs\/train.log \/home\/user\/logs\/  \n\n# \u4f20\u8f93\u76ee\u5f55\uff08\u52a0 -r\uff09  \nscp -r \/home\/user\/dataset root@192.168.1.100:\/data\/  <\/code><\/pre>\n<h3>4.3 SSH \u8fdc\u7a0b\u767b\u5f55\uff08<code>ssh<\/code>\uff09<\/h3>\n<p><strong>\u4f5c\u7528<\/strong>\uff1a\u8fdc\u7a0b\u8fde\u63a5\u5230\u53e6\u4e00\u53f0 Linux \u670d\u52a1\u5668\uff08\u6a21\u578b\u8bad\u7ec3\u5e38\u7528\uff09\u3002<br \/>\n<strong>\u793a\u4f8b<\/strong>\uff1a  <\/p>\n<pre><code class=\"language-bash\">ssh username@192.168.1.100        # \u8fde\u63a5 IP \u4e3a 192.168.1.100 \u7684\u670d\u52a1\u5668\uff08\u9700\u8f93\u5165\u5bc6\u7801\uff09  \nssh -p 2222 username@example.com  # \u8fde\u63a5\u6307\u5b9a\u7aef\u53e3\uff08\u5982 2222\uff09\u7684\u670d\u52a1\u5668  <\/code><\/pre>\n<hr \/>\n<h2>\u4e94\u3001\u5305\u7ba1\u7406\uff08APT\uff09<\/h2>\n<p>Ubuntu \u4f7f\u7528 <code>apt<\/code> \u5de5\u5177\u7ba1\u7406\u8f6f\u4ef6\u5305\uff08\u7c7b\u4f3c\u201c\u5e94\u7528\u5546\u5e97\u201d\u547d\u4ee4\u884c\u7248\uff09\u3002  <\/p>\n<h3>5.1 \u57fa\u7840\u64cd\u4f5c<\/h3>\n<pre><code class=\"language-bash\">sudo apt update                   # \u66f4\u65b0\u8f6f\u4ef6\u5305\u5217\u8868\uff08\u83b7\u53d6\u6700\u65b0\u53ef\u7528\u7248\u672c\uff09  \nsudo apt upgrade                  # \u5347\u7ea7\u5df2\u5b89\u88c5\u7684\u8f6f\u4ef6\u5305\uff08\u9700\u5148 update\uff09  \nsudo apt install package_name     # \u5b89\u88c5\u8f6f\u4ef6\uff08\u5982\uff1asudo apt install python3\uff09  \nsudo apt remove package_name      # \u5378\u8f7d\u8f6f\u4ef6\uff08\u4fdd\u7559\u914d\u7f6e\u6587\u4ef6\uff09  \nsudo apt purge package_name       # \u5f7b\u5e95\u5378\u8f7d\uff08\u5220\u9664\u914d\u7f6e\u6587\u4ef6\uff09  \nsudo apt autoremove               # \u81ea\u52a8\u5220\u9664\u4e0d\u518d\u9700\u8981\u7684\u4f9d\u8d56\u5305  <\/code><\/pre>\n<h3>5.2 \u641c\u7d22\u8f6f\u4ef6\u5305<\/h3>\n<pre><code class=\"language-bash\">apt search keyword                # \u641c\u7d22\u5305\u542b\u5173\u952e\u5b57\u7684\u8f6f\u4ef6\u5305\uff08\u5982\uff1aapt search tensorflow\uff09  \napt show package_name             # \u67e5\u770b\u8f6f\u4ef6\u5305\u8be6\u60c5\uff08\u7248\u672c\u3001\u4f9d\u8d56\u7b49\uff09  <\/code><\/pre>\n<hr \/>\n<h2>\u516d\u3001\u7528\u6237\u4e0e\u6743\u9650\u7ba1\u7406<\/h2>\n<h3>6.1 \u7528\u6237\u6743\u9650\u57fa\u7840<\/h3>\n<p>Linux \u4e2d\u6bcf\u4e2a\u6587\u4ef6\/\u76ee\u5f55\u6709 <strong>\u8bfb\uff08r\uff09\u3001\u5199\uff08w\uff09\u3001\u6267\u884c\uff08x\uff09<\/strong> \u6743\u9650\uff0c\u5206\u4e3a\u4e09\u4e2a\u89d2\u8272\uff1a  <\/p>\n<ul>\n<li><strong>\u6587\u4ef6\u6240\u6709\u8005\uff08u\uff09<\/strong>\uff1a\u6587\u4ef6\u7684\u62e5\u6709\u8005\u3002  <\/li>\n<li><strong>\u540c\u7ec4\u7528\u6237\uff08g\uff09<\/strong>\uff1a\u4e0e\u6240\u6709\u8005\u540c\u4e00\u7528\u6237\u7ec4\u7684\u7528\u6237\u3002  <\/li>\n<li><strong>\u5176\u4ed6\u7528\u6237\uff08o\uff09<\/strong>\uff1a\u9664\u4ee5\u4e0a\u4e24\u7c7b\u5916\u7684\u7528\u6237\u3002  <\/li>\n<\/ul>\n<h3>6.2 \u4fee\u6539\u6743\u9650\uff08<code>chmod<\/code>\uff09<\/h3>\n<p><strong>\u4f5c\u7528<\/strong>\uff1a\u8c03\u6574\u6587\u4ef6\/\u76ee\u5f55\u7684\u6743\u9650\uff08<code>+<\/code>\u6dfb\u52a0\uff0c<code>-<\/code>\u79fb\u9664\uff0c<code>=<\/code>\u8bbe\u7f6e\uff09\u3002<br \/>\n<strong>\u793a\u4f8b<\/strong>\uff1a  <\/p>\n<pre><code class=\"language-bash\">chmod u+x script.sh               # \u7ed9\u6240\u6709\u8005\u6dfb\u52a0\u6267\u884c\u6743\u9650\uff08\u811a\u672c\u8fd0\u884c\u5e38\u7528\uff09  \nchmod 755 dir\/                    # \u6570\u5b57\u6a21\u5f0f\uff1a7\uff08rwx\uff09\u7ed9\u6240\u6709\u8005\uff0c5\uff08r-x\uff09\u7ed9\u540c\u7ec4\u548c\u5176\u4ed6\u7528\u6237  <\/code><\/pre>\n<h3>6.3 \u4fee\u6539\u6240\u6709\u8005\uff08<code>chown<\/code>\uff09<\/h3>\n<p><strong>\u4f5c\u7528<\/strong>\uff1a\u53d8\u66f4\u6587\u4ef6\/\u76ee\u5f55\u7684\u6240\u6709\u8005\u6216\u6240\u5c5e\u7ec4\u3002<br \/>\n<strong>\u793a\u4f8b<\/strong>\uff1a  <\/p>\n<pre><code class=\"language-bash\">sudo chown new_user file.txt      # \u5c06 file.txt \u7684\u6240\u6709\u8005\u6539\u4e3a new_user\uff08\u9700\u7ba1\u7406\u5458\u6743\u9650\uff09  \nsudo chown user:group dir\/        # \u5c06 dir \u76ee\u5f55\u7684\u6240\u6709\u8005\u6539\u4e3a user\uff0c\u6240\u5c5e\u7ec4\u6539\u4e3a group  <\/code><\/pre>\n<hr \/>\n<h2>\u4e03\u3001\u6587\u672c\u5904\u7406\u5de5\u5177<\/h2>\n<h3>7.1 \u67e5\u770b\u6587\u4ef6\u5185\u5bb9\uff08<code>cat<\/code>\/<code>less<\/code>\uff09<\/h3>\n<ul>\n<li><strong><code>cat<\/code><\/strong>\uff1a\u5feb\u901f\u67e5\u770b\u5c0f\u6587\u4ef6\u5185\u5bb9\uff08\u76f4\u63a5\u8f93\u51fa\u5230\u7ec8\u7aef\uff09\u3002\n<pre><code class=\"language-bash\">cat data.txt                     # \u663e\u793a data.txt \u5168\u90e8\u5185\u5bb9\uff08\u6587\u4ef6\u592a\u5927\u65f6\u4f1a\u5237\u5c4f\uff09  <\/code><\/pre>\n<\/li>\n<li><strong><code>less<\/code><\/strong>\uff1a\u5206\u9875\u67e5\u770b\u5927\u6587\u4ef6\uff08\u652f\u6301\u4e0a\u4e0b\u7ffb\u9875\uff0c\u6309<code>q<\/code>\u9000\u51fa\uff09\u3002\n<pre><code class=\"language-bash\">less large_log.log               # \u5206\u9875\u67e5\u770b large_log.log  <\/code><\/pre>\n<\/li>\n<\/ul>\n<h3>7.2 \u7f16\u8f91\u6587\u4ef6\uff08<code>nano<\/code>\/<code>vim<\/code>\uff09<\/h3>\n<h4><strong><code>nano<\/code><\/strong>\uff08\u65b0\u624b\u63a8\u8350\uff09<\/h4>\n<p><strong>\u4f5c\u7528<\/strong>\uff1a\u8f7b\u91cf\u7ea7\u6587\u672c\u7f16\u8f91\u5668\uff08\u6bd4 Vim \u66f4\u53cb\u597d\uff0c\u9002\u5408\u65b0\u624b\uff09\u3002<br \/>\n<strong>\u793a\u4f8b<\/strong>\uff1a  <\/p>\n<pre><code class=\"language-bash\">nano config.ini                   # \u6253\u5f00 config.ini \u7f16\u8f91\uff08\u754c\u9762\u4e0b\u65b9\u6709\u64cd\u4f5c\u63d0\u793a\uff09  \n# \u7f16\u8f91\u5b8c\u6210\u540e\u6309 Ctrl+O \u4fdd\u5b58\uff0cCtrl+X \u9000\u51fa\u3002  <\/code><\/pre>\n<h4><strong><code>vim<\/code><\/strong>\uff08\u9ad8\u6548\u4f46\u9700\u5b66\u4e60\uff09<\/h4>\n<p><strong>\u4f5c\u7528<\/strong>\uff1a\u529f\u80fd\u5f3a\u5927\u7684\u6587\u672c\u7f16\u8f91\u5668\uff08\u9700\u638c\u63e1\u57fa\u7840\u64cd\u4f5c\uff09\u3002<br \/>\n<strong>\u5b89\u88c5<\/strong>\uff1a  <\/p>\n<pre><code class=\"language-bash\">sudo apt install vim              # \u5b89\u88c5 vim  <\/code><\/pre>\n<p><strong>\u57fa\u7840\u64cd\u4f5c<\/strong>\uff1a  <\/p>\n<ol>\n<li><strong>\u6253\u5f00\u6587\u4ef6<\/strong>\uff1a<code>vim file.txt<\/code>  <\/li>\n<li><strong>\u6a21\u5f0f\u5207\u6362<\/strong>\uff1a\n<ul>\n<li><strong>\u666e\u901a\u6a21\u5f0f<\/strong>\uff08\u9ed8\u8ba4\uff09\uff1a\u6309 <code>i<\/code> \u8fdb\u5165\u63d2\u5165\u6a21\u5f0f\uff08\u7f16\u8f91\u6587\u672c\uff09\u3002  <\/li>\n<li><strong>\u547d\u4ee4\u6a21\u5f0f<\/strong>\uff1a\u6309 <code>Esc<\/code> \u9000\u51fa\u63d2\u5165\u6a21\u5f0f\uff0c\u8f93\u5165 <code>:<\/code> \u8fdb\u5165\u547d\u4ee4\u6a21\u5f0f\uff08\u5982\u4fdd\u5b58\u3001\u9000\u51fa\uff09\u3002  <\/li>\n<\/ul>\n<\/li>\n<li><strong>\u5e38\u7528\u547d\u4ee4<\/strong>\uff1a\n<ul>\n<li><code>:w<\/code>\uff1a\u4fdd\u5b58\u6587\u4ef6\u3002  <\/li>\n<li><code>:q<\/code>\uff1a\u9000\u51fa\uff08\u82e5\u672a\u4fdd\u5b58\u4f1a\u63d0\u793a\uff09\u3002  <\/li>\n<li><code>:wq<\/code>\uff1a\u4fdd\u5b58\u5e76\u9000\u51fa\u3002  <\/li>\n<li><code>:q!<\/code>\uff1a\u5f3a\u5236\u9000\u51fa\uff08\u4e0d\u4fdd\u5b58\uff09\u3002  <\/li>\n<li><code>\/keyword<\/code>\uff1a\u641c\u7d22\u6587\u672c\uff08\u6309 <code>n<\/code> \u67e5\u627e\u4e0b\u4e00\u4e2a\uff09\u3002  <\/li>\n<\/ul>\n<\/li>\n<li><strong>\u793a\u4f8b<\/strong>\uff1a\n<pre><code class=\"language-bash\">vim script.py                  # \u7f16\u8f91 script.py  \n# \u6309 i \u8fdb\u5165\u63d2\u5165\u6a21\u5f0f \u2192 \u4fee\u6539\u4ee3\u7801 \u2192 Esc \u2192 :wq \u4fdd\u5b58\u9000\u51fa  <\/code><\/pre>\n<\/li>\n<\/ol>\n<h3>7.3 \u641c\u7d22\u6587\u672c\uff08<code>grep<\/code>\uff09<\/h3>\n<p><strong>\u4f5c\u7528<\/strong>\uff1a\u5728\u6587\u4ef6\u4e2d\u641c\u7d22\u5305\u542b\u6307\u5b9a\u5173\u952e\u5b57\u7684\u884c\uff08\u6a21\u578b\u65e5\u5fd7\u5206\u6790\u5e38\u7528\uff09\u3002<br \/>\n<strong>\u793a\u4f8b<\/strong>\uff1a  <\/p>\n<pre><code class=\"language-bash\">grep &quot;error&quot; app.log              # \u641c\u7d22 app.log \u4e2d\u5305\u542b &quot;error&quot; \u7684\u884c  \ngrep -i &quot;Warning&quot; sys.log         # \u5ffd\u7565\u5927\u5c0f\u5199\u641c\u7d22\uff08-i \u9009\u9879\uff09  <\/code><\/pre>\n<hr \/>\n<h2>\u516b\u3001Python \u4e0e Conda \u73af\u5883\u7ba1\u7406<\/h2>\n<h3>8.1 Python \u57fa\u7840<\/h3>\n<h4><strong>\u5b89\u88c5 Python<\/strong><\/h4>\n<pre><code class=\"language-bash\">sudo apt install python3          # \u5b89\u88c5 Python 3\uff08Ubuntu \u9ed8\u8ba4\u81ea\u5e26\uff09  \nsudo apt install python3-pip      # \u5b89\u88c5 pip\uff08Python \u5305\u7ba1\u7406\u5de5\u5177\uff09  <\/code><\/pre>\n<h4><strong>\u5e38\u7528\u547d\u4ee4<\/strong><\/h4>\n<pre><code class=\"language-bash\">python3 --version                # \u67e5\u770b Python \u7248\u672c  \npip list                         # \u67e5\u770b\u5df2\u5b89\u88c5\u7684 Python \u5305  \npip install numpy                # \u5b89\u88c5 Python \u5305\uff08\u5982 numpy\uff09  \npip freeze &gt; requirements.txt    # \u5bfc\u51fa\u5f53\u524d\u73af\u5883\u7684\u6240\u6709\u4f9d\u8d56\u5305  \npip install -r requirements.txt  # \u6839\u636e requirements.txt \u5b89\u88c5\u4f9d\u8d56  <\/code><\/pre>\n<h3>8.2 Conda \u73af\u5883\u7ba1\u7406<\/h3>\n<h4><strong>\u5b89\u88c5 Miniconda<\/strong><\/h4>\n<ol>\n<li>\u4e0b\u8f7d Miniconda \u5b89\u88c5\u811a\u672c\uff08\u63a8\u8350 Python 3.9 \u7248\u672c\uff09\uff1a\n<pre><code class=\"language-bash\">wget https:\/\/repo.anaconda.com\/miniconda\/Miniconda3-latest-Linux-x86_64.sh  <\/code><\/pre>\n<\/li>\n<li>\u8fd0\u884c\u5b89\u88c5\u811a\u672c\uff1a\n<pre><code class=\"language-bash\">bash Miniconda3-latest-Linux-x86_64.sh  \n# \u6309\u63d0\u793a\u64cd\u4f5c\uff08\u9ed8\u8ba4\u5b89\u88c5\u5230 ~\/miniconda3\uff09  <\/code><\/pre>\n<\/li>\n<li>\u6fc0\u6d3b Conda\uff1a\n<pre><code class=\"language-bash\">source ~\/miniconda3\/bin\/activate  # \u6fc0\u6d3b Conda\uff08\u6bcf\u6b21\u65b0\u7ec8\u7aef\u9700\u6267\u884c\uff09  <\/code><\/pre>\n<\/li>\n<\/ol>\n<h4><strong>\u5e38\u7528 Conda \u547d\u4ee4<\/strong><\/h4>\n<pre><code class=\"language-bash\">conda create -n myenv python=3.8  # \u521b\u5efa\u540d\u4e3a myenv \u7684 Python 3.8 \u73af\u5883  \nconda activate myenv              # \u6fc0\u6d3b myenv \u73af\u5883  \nconda deactivate                 # \u9000\u51fa\u5f53\u524d\u73af\u5883  \nconda env list                   # \u5217\u51fa\u6240\u6709\u73af\u5883  \nconda remove -n myenv --all      # \u5220\u9664 myenv \u73af\u5883  \nconda install numpy              # \u5728\u5f53\u524d\u73af\u5883\u5b89\u88c5\u5305\uff08\u7b49\u540c pip install\uff09  <\/code><\/pre>\n<h4><strong>\u5bfc\u51fa\/\u6062\u590d\u73af\u5883<\/strong><\/h4>\n<pre><code class=\"language-bash\">conda env export &gt; environment.yml  # \u5bfc\u51fa\u5f53\u524d\u73af\u5883\u914d\u7f6e  \nconda env create -f environment.yml # \u6839\u636e environment.yml \u521b\u5efa\u73af\u5883  <\/code><\/pre>\n<hr \/>\n<h2>\u4e5d\u3001Tmux \u7ec8\u7aef\u590d\u7528\u5668<\/h2>\n<h3>9.1 Tmux \u7b80\u4ecb<\/h3>\n<p><strong>\u4f5c\u7528<\/strong>\uff1a\u7ec8\u7aef\u590d\u7528\u5de5\u5177\uff0c\u5141\u8bb8\u5728\u5355\u4e2a\u7ec8\u7aef\u7a97\u53e3\u4e2d\u521b\u5efa\u591a\u4e2a\u4f1a\u8bdd\u3001\u7a97\u53e3\u548c\u9762\u677f\uff0c\u9002\u5408\u957f\u65f6\u95f4\u8fd0\u884c\u4efb\u52a1\uff08\u5982\u6a21\u578b\u8bad\u7ec3\uff09\u3002  <\/p>\n<h4><strong>\u5b89\u88c5 Tmux<\/strong><\/h4>\n<pre><code class=\"language-bash\">sudo apt install tmux            # \u5b89\u88c5 Tmux  <\/code><\/pre>\n<h3>9.2 \u57fa\u7840\u64cd\u4f5c<\/h3>\n<h4><strong>\u542f\u52a8 Tmux<\/strong><\/h4>\n<pre><code class=\"language-bash\">tmux                             # \u542f\u52a8\u65b0\u4f1a\u8bdd\uff08\u9ed8\u8ba4\u7f16\u53f7\u4e3a 0\uff09  \ntmux new -s session_name         # \u521b\u5efa\u547d\u540d\u4f1a\u8bdd\uff08\u5982 tmux new -s train\uff09  <\/code><\/pre>\n<h4><strong>\u4f1a\u8bdd\u7ba1\u7406<\/strong><\/h4>\n<ul>\n<li><strong>\u5206\u79bb\u4f1a\u8bdd<\/strong>\uff08\u540e\u53f0\u8fd0\u884c\uff09\uff1a<code>Ctrl + B<\/code> \u677e\u5f00\u540e\u6309 <code>D<\/code>  <\/li>\n<li><strong>\u67e5\u770b\u4f1a\u8bdd\u5217\u8868<\/strong>\uff1a\n<pre><code class=\"language-bash\">tmux ls                         # \u67e5\u770b\u6240\u6709\u4f1a\u8bdd  <\/code><\/pre>\n<\/li>\n<li><strong>\u91cd\u65b0\u8fde\u63a5\u4f1a\u8bdd<\/strong>\uff1a\n<pre><code class=\"language-bash\">tmux attach -t 0                # \u8fde\u63a5\u7f16\u53f7\u4e3a 0 \u7684\u4f1a\u8bdd  \ntmux attach -t session_name     # \u8fde\u63a5\u547d\u540d\u4f1a\u8bdd  <\/code><\/pre>\n<\/li>\n<li><strong>\u5173\u95ed\u4f1a\u8bdd<\/strong>\uff1a\n<pre><code class=\"language-bash\">exit                            # \u5728\u4f1a\u8bdd\u4e2d\u8f93\u5165 exit \u5173\u95ed  \n\u6216  \ntmux kill-session -t 0          # \u5f3a\u5236\u5173\u95ed\u7f16\u53f7\u4e3a 0 \u7684\u4f1a\u8bdd  <\/code><\/pre>\n<\/li>\n<\/ul>\n<h4><strong>\u7a97\u53e3\u7ba1\u7406<\/strong><\/h4>\n<ul>\n<li><strong>\u521b\u5efa\u65b0\u7a97\u53e3<\/strong>\uff1a<code>Ctrl + B<\/code> \u677e\u5f00\u540e\u6309 <code>C<\/code>  <\/li>\n<li><strong>\u5207\u6362\u7a97\u53e3<\/strong>\uff1a\n<ul>\n<li><code>Ctrl + B<\/code> \u677e\u5f00\u540e\u6309 <code>\u6570\u5b57\u952e<\/code>\uff08\u5982 <code>0<\/code> \u5207\u6362\u5230\u7b2c 1 \u4e2a\u7a97\u53e3\uff09  <\/li>\n<li><code>Ctrl + B<\/code> \u677e\u5f00\u540e\u6309 <code>N<\/code>\uff08\u4e0b\u4e00\u4e2a\u7a97\u53e3\uff09\u6216 <code>P<\/code>\uff08\u4e0a\u4e00\u4e2a\u7a97\u53e3\uff09  <\/li>\n<\/ul>\n<\/li>\n<li><strong>\u5173\u95ed\u5f53\u524d\u7a97\u53e3<\/strong>\uff1a<code>Ctrl + B<\/code> \u677e\u5f00\u540e\u6309 <code>&amp;<\/code>  <\/li>\n<\/ul>\n<h4><strong>\u9762\u677f\u7ba1\u7406<\/strong><\/h4>\n<ul>\n<li><strong>\u6c34\u5e73\u5206\u5272\u9762\u677f<\/strong>\uff1a<code>Ctrl + B<\/code> \u677e\u5f00\u540e\u6309 <code>&quot;<\/code>  <\/li>\n<li><strong>\u5782\u76f4\u5206\u5272\u9762\u677f<\/strong>\uff1a<code>Ctrl + B<\/code> \u677e\u5f00\u540e\u6309 <code>%<\/code>  <\/li>\n<li><strong>\u5207\u6362\u9762\u677f<\/strong>\uff1a<code>Ctrl + B<\/code> \u677e\u5f00\u540e\u6309\u65b9\u5411\u952e\uff08\u4e0a\u4e0b\u5de6\u53f3\uff09  <\/li>\n<li><strong>\u5173\u95ed\u9762\u677f<\/strong>\uff1a<code>Ctrl + B<\/code> \u677e\u5f00\u540e\u6309 <code>X<\/code>  <\/li>\n<\/ul>\n<h3>9.3 \u9ad8\u7ea7\u6280\u5de7<\/h3>\n<ul>\n<li><strong>\u6eda\u52a8\u67e5\u770b\u5386\u53f2\u8f93\u51fa<\/strong>\uff1a<code>Ctrl + B<\/code> \u677e\u5f00\u540e\u6309 <code>[<\/code>\uff0c\u7136\u540e\u4f7f\u7528\u65b9\u5411\u952e\u6216\u9f20\u6807\u6eda\u8f6e\u6d4f\u89c8\uff0c\u6309 <code>Q<\/code> \u9000\u51fa\u3002  <\/li>\n<li><strong>\u540c\u6b65\u8f93\u5165\u5230\u6240\u6709\u9762\u677f<\/strong>\uff1a<code>Ctrl + B<\/code> \u677e\u5f00\u540e\u6309 <code>:<\/code>\uff0c\u8f93\u5165 <code>setw synchronize-panes<\/code>\u3002  <\/li>\n<\/ul>\n<hr \/>\n<h2>\u5341\u3001\u6ce8\u610f\u4e8b\u9879\uff08\u65b0\u624b\u5fc5\u770b\uff01\uff09<\/h2>\n<ol>\n<li><strong>\u6743\u9650\u95ee\u9898<\/strong>\uff1a\u6d89\u53ca\u7cfb\u7edf\u7ea7\u64cd\u4f5c\uff08\u5982\u4fee\u6539 <code>\/etc<\/code> \u76ee\u5f55\u3001\u5b89\u88c5\u8f6f\u4ef6\uff09\u9700\u52a0 <code>sudo<\/code>\uff08\u4ee3\u8868\u201c\u8d85\u7ea7\u7528\u6237\u6743\u9650\u201d\uff09\uff0c\u4f46\u4e0d\u8981\u6ee5\u7528 <code>sudo<\/code>\u3002  <\/li>\n<li><strong>\u5371\u9669\u547d\u4ee4<\/strong>\uff1a<code>rm -rf<\/code> \u4f1a\u5f3a\u5236\u5220\u9664\u76ee\u5f55\uff08\u5305\u62ec\u975e\u7a7a\u76ee\u5f55\uff09\uff0c\u5207\u52ff\u5bf9 <code>\/<\/code>\u3001<code>\/home<\/code> \u7b49\u5173\u952e\u8def\u5f84\u4f7f\u7528\uff01  <\/li>\n<li><strong>\u8def\u5f84\u89c4\u8303<\/strong>\uff1a\u4f7f\u7528\u7edd\u5bf9\u8def\u5f84\uff08\u5982 <code>\/usr\/bin<\/code>\uff09\u6216\u76f8\u5bf9\u8def\u5f84\uff08\u5982 <code>..\/data<\/code>\uff09\u65f6\uff0c\u6ce8\u610f\u76ee\u5f55\u662f\u5426\u5b58\u5728\u3002  <\/li>\n<li><strong>\u547d\u4ee4\u8865\u5168<\/strong>\uff1a\u8f93\u5165\u547d\u4ee4\u6216\u8def\u5f84\u65f6\u6309 <code>Tab<\/code> \u952e\u81ea\u52a8\u8865\u5168\uff08\u907f\u514d\u624b\u8bef\uff09\u3002  <\/li>\n<\/ol>\n<hr \/>\n<h2>\u9644\u5f55\uff1a\u6a21\u578b\u8bad\u7ec3\u5e38\u7528\u6269\u5c55\u547d\u4ee4<\/h2>\n<ul>\n<li><strong>\u67e5\u770b GPU \u4fe1\u606f<\/strong>\uff08NVIDIA \u663e\u5361\uff09\uff1a<code>nvidia-smi<\/code>\uff08\u5b9e\u65f6\u76d1\u63a7\u663e\u5b58\/\u7b97\u529b\u5360\u7528\uff09\u3002  <\/li>\n<li><strong>\u540e\u53f0\u8fd0\u884c\u4efb\u52a1<\/strong>\uff1a`nohup python train.py &gt; log<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Ubuntu \u57fa\u7840\u547d\u4ee4\u6587\u6863 \u672c\u6587\u6863\u9002\u7528\u4e8e\u521a\u63a5\u89e6 Ubuntu \u7cfb\u7edf\u7684\u65b0\u624b\uff0c\u8986\u76d6\u65e5\u5e38\u64cd\u4f5c\u3001\u6587\u4ef6\u7ba1\u7406\u3001\u7cfb\u7edf\u76d1\u63a7\u3001\u7f51&#8230; &raquo; <a class=\"read-more-link\" href=\"https:\/\/apifj.com\/index.php\/2022\/07\/14\/341\/\">\u9605\u8bfb\u5168\u6587<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-341","post","type-post","status-publish","format-standard","hentry","category-dl"],"_links":{"self":[{"href":"https:\/\/apifj.com\/index.php\/wp-json\/wp\/v2\/posts\/341","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/apifj.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/apifj.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/apifj.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/apifj.com\/index.php\/wp-json\/wp\/v2\/comments?post=341"}],"version-history":[{"count":2,"href":"https:\/\/apifj.com\/index.php\/wp-json\/wp\/v2\/posts\/341\/revisions"}],"predecessor-version":[{"id":343,"href":"https:\/\/apifj.com\/index.php\/wp-json\/wp\/v2\/posts\/341\/revisions\/343"}],"wp:attachment":[{"href":"https:\/\/apifj.com\/index.php\/wp-json\/wp\/v2\/media?parent=341"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/apifj.com\/index.php\/wp-json\/wp\/v2\/categories?post=341"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/apifj.com\/index.php\/wp-json\/wp\/v2\/tags?post=341"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}