{"id":1596,"date":"2023-04-15T15:58:01","date_gmt":"2023-04-15T07:58:01","guid":{"rendered":"http:\/\/175.24.184.226\/?p=1596"},"modified":"2023-04-15T15:58:30","modified_gmt":"2023-04-15T07:58:30","slug":"04-linux%e5%b8%b8%e7%94%a8%e5%9f%ba%e6%9c%ac%e5%91%bd%e4%bb%a4%e5%ae%9e%e6%88%98","status":"publish","type":"post","link":"\/?p=1596","title":{"rendered":"04-Linux\u5e38\u7528\u57fa\u672c\u547d\u4ee4\u5b9e\u6218"},"content":{"rendered":"<h3>Linux\u6587\u4ef6\u7cfb\u7edf<\/h3>\n<ol>\n<li>\u6587\u4ef6\u540d\u540d\u79f0\u4e25\u683c\u533a\u5206\u5b57\u7b26\u5927\u5c0f\u5199\uff1b<\/li>\n<li>\u6587\u4ef6\u53ef\u4ee5\u4f7f\u7528\u9664\u4e86<code>\/<\/code>\u4ee5\u5916\u7684\u4efb\u610f\u5b57\u7b26\uff1b<\/li>\n<li>\u6587\u4ef6\u540d\u957f\u5ea6\u4e0d\u80fd\u8d85\u8fc7255\u4e2a\u5b57\u7b26\uff1b<\/li>\n<li>\u4ee5<code>.<\/code>\u5f00\u5934\u7684\u6587\u4ef6\u4e3a\u9690\u85cf\u6587\u4ef6\uff0c\u9664\u4e86\uff1a\n<ul>\n<li><code>.<\/code>:\u5f53\u524d\u76ee\u5f55<\/li>\n<li><code>..<\/code>:\u5f53\u524d\u76ee\u5f55\u7684\u4e0a\u4e00\u7ea7\u76ee\u5f55<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>\u5de5\u4f5c\u76ee\u5f55\uff1a working directory<\/p>\n<p>\u5bb6\u76ee\u5f55\uff1a home<\/p>\n<h3>\u5e38\u7528\u547d\u4ee4\uff1a<\/h3>\n<h4>pwd<\/h4>\n<ul>\n<li>printing working directory(\u663e\u793a\u5de5\u4f5c\u76ee\u5f55)<\/li>\n<\/ul>\n<h4>cd<\/h4>\n<p><strong>change directory(\u5207\u6362\u76ee\u5f55)<\/strong><\/p>\n<ul>\n<li><code>cd [\/PATH\/TO\/SOMEDIR]<\/code><\/li>\n<li><code>cd<\/code> \u6216<code>cd ~<\/code>\u5207\u6362\u7528\u6237\u7684\u5bb6\u76ee\u5f55<\/li>\n<li><code>cd ~USERNAME<\/code>: \u5207\u6362\u81f3\u6307\u5b9a\u7528\u6237\u7684\u5bb6\u76ee\u5f55<\/li>\n<li><code>cd -<\/code>:\u5728\u4e0a\u4e00\u6b21\u6240\u5728\u76ee\u5f55\u4e0e\u5f53\u524d\u6240\u5728\u76ee\u5f55\u6765\u56de\u5207\u6362<\/li>\n<li>\u76f8\u5173\u7684\u73af\u5883\u53d8\u91cf\uff1a\n<ul>\n<li><code>PWD<\/code>\u5f53\u524d\u5de5\u4f5c\u76ee\u5f55\uff0c<code>$PWD<\/code><\/li>\n<li><code>OLDPWD<\/code>\u4e0a\u4e00\u6b21\u7684\u5de5\u4f5c\u76ee\u5f55,<code>$PLDPWD<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4>ls<\/h4>\n<p><strong>list,\u5217\u51fa\u6307\u5b9a\u76ee\u5f55\u4e0b\u7684\u5185\u5bb9<\/strong><\/p>\n<ul>\n<li>\n<p>ls [OPTION]... [FILE]...<\/p>\n<\/li>\n<li>\n<p>-a:\u663e\u793a\u6240\u6709\u6587\u4ef6\uff0c\u5305\u62ec\u9690\u85cf\u6587\u4ef6<\/p>\n<\/li>\n<li>\n<p>-A:\u663e\u793a \u9664\u4e86.\u548c..\u4e4b\u5916\u7684\u6240\u6709\u6587\u4ef6<\/p>\n<\/li>\n<li>\n<p>-l\uff1a --long,\u957f\u683c\u5f0f\u5217\u8868\uff0c\u5373\u73b0\u65f6\u6587\u4ef6\u7684\u8be6\u7ec6\u5c5e\u6027\u4fe1\u606f\uff1b<\/p>\n<p><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/image-20230226021124350.png\" alt=\"image-20230226021124350\" \/> <\/p>\n<ul>\n<li>d: (\u7b2c\u4e00\u4e2a\u5b57\u6bb5)\u6587\u4ef6\u7c7b\u578b\uff0c\u8fd8\u6709-,d,b,c,l,s,p<\/li>\n<li>-\u4ee3\u8868\u662f\u5e38\u89c4\u6587\u4ef6\uff0c <\/li>\n<li>d\u4ee3\u8868\u662f\u6587\u4ef6\u5939-\u76ee\u5f55\u6587\u4ef6\uff0c<\/li>\n<li>-b\u4ee3\u8868block device\u5757\u8bbe\u5907\u6587\u4ef6\u3001\u652f\u6301\u4ee5block\u4e3a\u5355\u4f4d\u8fdb\u884c\u968f\u673a\u8bbf\u95ee\uff0c <\/li>\n<li>-c\u4ee3\u8868character device\u5b57\u7b26\u8bbe\u5907\u6587\u4ef6\u3001\u652f\u6301\u4ee5character\u4e3a\u5355\u4f4d\u8fdb\u884c\u7ebf\u6027\u8bbf\u95ee\uff09\n<ul>\n<li>major number:\u4e3b\u8bbe\u5907\u53f7\uff0c\u7528\u6807\u8bc6\u8bbe\u5907\u7c7b\u578b\uff0c\u8fdb\u800c\u786e\u5b9a\u8981\u52a0\u8f7d\u7684\u9a71\u52a8\u7a0b\u5e8f<\/li>\n<li>minor number:\u6b21\u8bbe\u5907\u53f7\uff0c\u7528\u4e8e\u6807\u8bc6\u540c\u4e00\u7c7b\u578b\u4e2d\u7684\u4e0d\u540c\u8bbe\u5907<\/li>\n<\/ul>\n<\/li>\n<li>-l:symbolic link,\u7b26\u53f7\u94fe\u63a5\u6587\u4ef6<\/li>\n<li>-p:pipe,\u547d\u540d\u7ba1\u9053<\/li>\n<li>-s:socket\uff0c\u5957\u63a5\u5b57\u6587\u4ef6\uff0c\u4e24\u4e2a\u6587\u4ef6\u8fdb\u884c\u901a\u4fe1<\/li>\n<li>rwxrwxr-x.<\/li>\n<li>\u5de6\u4e09\u4f4drwx:\u6587\u4ef6\u5c5e\u4e3b\u7684\u6743\u9650\uff1b<\/li>\n<li>\u4e2d\u4e09\u4f4drwx:\u6587\u4ef6\u5c5e\u7ec4\u7684\u6743\u9650\uff1b<\/li>\n<li>\u53f3\u4e09\u4f4dr-x:\u5176\u4ed6\u7528\u6237\uff08\u975e\u5c5e\u4e3b\/\u5c5e\u7ec4\uff09\u7684\u6743\u9650\uff1b<\/li>\n<li>\u672b\u5c3e\u5982\u679c\u8fd8\u6709\u70b9\u53f7<code>.<\/code>,\u8bf4\u660e\u6587\u4ef6\u8fd8\u6709\u9690\u85cf\u5c5e\u6027<\/li>\n<li>4096\uff1a\u6570\u5b57\u4ee3\u8868\u6587\u4ef6\u7684\u5927\u5c0f\uff0c\u5355\u4f4d\u662f\u5b57\u8282<\/li>\n<li>Nov 16 23:57: \u6587\u4ef6\u6700\u540e\u4e00\u6b21\u4fee\u6539\u7684\u65f6\u95f4<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>-h, --human-readable:\u5bf9\u6587\u4ef6\u5927\u5c0f\u8fdb\u884c\u5355\u4f4d\u6362\u7b97\uff1b\u6362\u7b97\u540e\u7684\u7ed3\u679c\u53ef\u80fd\u4f1a\u662f\u975e\u7cbe\u786e\u503c<\/p>\n<\/li>\n<li>\n<p>-d\uff1a\u67e5\u770b\u76ee\u5f55\u81ea\u8eab\u800c\u975e\u5176\u5185\u90e8\u7684\u6587\u4ef6\u5217\u8868<\/p>\n<\/li>\n<li>\n<p>-r\uff1areberse\u9006\u5e8f\u663e\u793a<\/p>\n<\/li>\n<li>\n<p>-R\uff1arecursive\uff0c\u9012\u5f52\u663e\u793a<\/p>\n<\/li>\n<\/ul>\n<h4>cat<\/h4>\n<p><strong>concatenate<\/strong><\/p>\n<ul>\n<li>\u6587\u4ef6\u6587\u672c\u67e5\u770b\u5de5\u5177\uff1a\n<ul>\n<li>cat \/etc\/fstab<\/li>\n<li>cat \/stc\/passwd<\/li>\n<\/ul>\n<\/li>\n<li>cat [OPTION]... [FILE]...\n<ul>\n<li>-n: \u7ed9\u663e\u793a\u7684\u6587\u672c\u884c\u7f16\u53f7<\/li>\n<li>-E: \u663e\u793a\u884c\u7ed3\u675f\u7b26$<\/li>\n<\/ul>\n<\/li>\n<li>tac [OPTION]... [FILE]... \/\/ \u4e0ecat\u76f8\u6bd4\uff0c\u6587\u4ef6\u5185\u5bb9\u662f\u9006\u5e8f\u7684\n<ul>\n<li>-n: \u7ed9\u663e\u793a\u7684\u6587\u672c\u884c\u7f16\u53f7<\/li>\n<li>-E: \u663e\u793a\u884c\u7ed3\u675f\u7b26$<\/li>\n<li><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/image-20230227221448713.png\" alt=\"image-20230227221448713\" \/> <\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h4>file<\/h4>\n<p>\u67e5\u770b\u6587\u4ef6\u5185\u5bb9\u7c7b\u578b<\/p>\n<h4>echo<\/h4>\n<p><strong>\u56de\u663e<\/strong><\/p>\n<ul>\n<li>echo [SHOT-OPTION]... [STRING]...<\/li>\n<li>STRING\u53ef\u4ee5\u4f7f\u7528\u82f1\u8c6a\uff0c\u5355\u5f15\u53f7\u548c\u53cc\u5f15\u53f7\u5747\u53ef\u4f7f\u7528\n<ul>\n<li>\u5355\u5f15\u53f7\uff1a\u5f3a\u5f15\u7528\uff0c\u53d8\u91cf\u5f15\u7528\u4e0d\u6267\u884c\u66ff\u6362<\/li>\n<li>~]# ''$SHELL\u2019<\/li>\n<li>\u53cc\u5f15\u53f7\uff1a\u5f31\u5f15\u7528\uff0c\u53d8\u91cf\u5f15\u7528\u4f1a\u88ab\u66ff\u6362<\/li>\n<li>~]# '$SHELL'<\/li>\n<li>\u6ce8\u610f\uff1a\u53d8\u91cf\u5f15\u7528\u7684\u6b63\u89c4\u7b26\u5408 <code>${name}<\/code><\/li>\n<\/ul>\n<\/li>\n<li>-n: \u4e0d\u8fdb\u884c\u6362\u884c\uff1b<\/li>\n<li>-e: \u8ba9\u8f6c\u4e49\u7b26\u751f\u6548<\/li>\n<li><img src=\"https:\/\/lemon-guess.oss-cn-hangzhou.aliyuncs.com\/img\/image-20230227222119382.png\" alt=\"image-20230227222119382\" \/> <\/li>\n<\/ul>\n<h4>\u5173\u673a\u6216\u91cd\u542f\u547d\u4ee4(shutdown)<\/h4>\n<p>shuwdown <code>[OPTIONS...][TIME][WALL...]<\/code><\/p>\n<ul>\n<li>OPTIONS:\n<ul>\n<li>-h: halt<\/li>\n<li>-r:reboot<\/li>\n<li>-c:cancel<\/li>\n<\/ul>\n<\/li>\n<li>TIME:\n<ul>\n<li>now<\/li>\n<li>hh:mm<\/li>\n<li>+m<\/li>\n<\/ul>\n<\/li>\n<li>WALL<\/li>\n<\/ul>\n<h4>\u65e5\u671f\u76f8\u5173\u547d\u4ee4<\/h4>\n<blockquote>\n<p>Lixun\u7cfb\u7edf\u542f\u52a8\u65f6\u4ece\u786c\u4ef6\u8bfb\u53d6\u65e5\u671f\u548c\u65f6\u95f4\u4fe1\u606f\uff1b\u8bfb\u53d6\u5b8c\u6210\u4ee5\u540e\uff0c\u5c31\u4e0d\u518d\u4e8e\u786c\u4ef6\u76f8\u5173\u8054<\/p>\n<p>\u7cfb\u7edf\u65f6\u949f\uff1a date<\/p>\n<p>\u786c\u4ef6\u65f6\u949f\uff1a clock<\/p>\n<\/blockquote>\n<p><strong>date<\/strong><\/p>\n<ul>\n<li>\n<pre><code>\u663e\u793a\u65f6\u95f4       date [OPTION]... [+FORMAT]\n\u8bbe\u5b9a\u65e5\u671f\u65f6\u95f4    date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]<\/code><\/pre>\n<\/li>\n<li>\n<pre><code>ubuntu@VM-0-6-ubuntu:~$ date\n2023\u5e74 02\u6708 27\u65e5 \u661f\u671f\u4e00 22:34:46 CST\nubuntu@VM-0-6-ubuntu:~$ date +%F\n2023-02-27\nubuntu@VM-0-6-ubuntu:~$ date +%H\n22\nubuntu@VM-0-6-ubuntu:~$ date +%c\n2023\u5e7402\u670827\u65e5 \u661f\u671f\u4e00 22\u65f635\u520608\u79d2\nubuntu@VM-0-6-ubuntu:~$ date +%H\n22\nubuntu@VM-0-6-ubuntu:~$ date +%Y\n2023\nubuntu@VM-0-6-ubuntu:~$ date +%M\n35\nubuntu@VM-0-6-ubuntu:~$ date +%m\n02\nubuntu@VM-0-6-ubuntu:~$ date +%S\n44\nubuntu@VM-0-6-ubuntu:~$ date +%s\n1677508570<\/code><\/pre>\n<\/li>\n<\/ul>\n<p><strong>clock, hwclock\u786c\u4ef6\u65f6\u949f<\/strong><\/p>\n<ul>\n<li>\u663e\u793a\u6216\u8bbe\u5b9a\u786c\u4ef6\u65f6\u949f\n<ul>\n<li>-s,  --htcosys;\u4ee5\u786c\u4ef6\u4e3a\u51c6\uff0c\u628a\u7cfb\u7edf\u8c03\u6574\u4e3a\u786c\u4ef6\u65f6\u95f4\u76f8\u540c\uff1b<\/li>\n<li>-w, --systohc;\u4ee5\u7cfb\u7edf\u4e3a\u51c6\uff0c\u628a\u7cfb\u7edf\u8c03\u6574\u4e3a\u7cfb\u7edf\u65f6\u95f4\u76f8\u540c\uff1b<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>cal<\/strong><\/p>\n<p>\u65e5\u5386<\/p>\n<ul>\n<li><code>cal [[month] year]<\/code><\/li>\n<\/ul>\n<h4>which<\/h4>\n<ul>\n<li>\n<p>which - shows the full path of (shell) commands<\/p>\n<\/li>\n<li>\n<p>which [options] programname [...]<\/p>\n<ul>\n<li>--skip-alias:\u5ffd\u7565\u522b\u540d<\/li>\n<\/ul>\n<pre><code class=\"language-shell\">[root@rhino014 ~]# which ls\nalias ls='ls --color=auto'\n      \/usr\/bin\/ls\n[root@rhino014 ~]# which --skip-alias ls\n\/usr\/bin\/ls<\/code><\/pre>\n<\/li>\n<\/ul>\n<h4>whereis<\/h4>\n<p><strong>whereis - locate the binary, source, and manual page files for a command(\u80fd\u663e\u793a\u4e8c\u8fdb\u5236\u6587\u4ef6\u3001\u6e90\u7801\u6587\u4ef6\u3001\u624b\u518c\u9875)<\/strong><\/p>\n<p>man whereis \u67e5\u770b\u53ef\u9009\u9879\uff1a<\/p>\n<pre><code>SYNOPSIS\n       whereis [options] [-BMS directory... -f] name...\nOPTIONS\n       -b     Search only for binaries.\n\n       -m     Search only for manuals.\n\n       -s     Search only for sources.\n\n       -u     Only  show  the  command  names  that  have unusual entries.  A command is said to be\n              unusual if it does not have just one entry of each explicitly requested  type.   Thus\n              &#039;whereis  -m  -u *&#039; asks for those files in the current directory which have no docu\u2010\n              mentation file, or more than one.\n\n       -B list\n              Limit the places where whereis searches for binaries, by a whitespace-separated  list\n              of directories.\n\n       -M list\n              Limit  the  places where whereis searches for manuals, by a whitespace-separated list\n              of directories.\n\n       -S list\n              Limit the places where whereis searches for sources, by a  whitespace-separated  list\n              of directories.\n\n       -f     Terminates  the  directory  list and signals the start of filenames.  It must be used\n              when any of the -B, -M, or -S options is used.\n\n       -l     Output list of effective lookup paths the whereis is using.  When non of -B,  -M,  or\n              -S  is  specified  the  option will out hard coded paths that the command was able to\n              find on system.\n<\/code><\/pre>\n<p>\u8fd0\u7528\u6d4b\u8bd5\uff1a<\/p>\n<pre><code>[root@rhino014 ~]# whereis -b ls # \u4ec5\u641c\u7d22\u4e8c\u8fdb\u5236\u6587\u4ef6\u8def\u5f84\nls: \/usr\/bin\/ls\n[root@rhino014 ~]# whereis -m ls # \u4ec5\u641c\u7d22\u4f7f\u7528\u624b\u518c\u6587\u4ef6\u8def\u5f84\nls: \/usr\/share\/man\/man1\/ls.1.gz \/usr\/share\/man\/man1p\/ls.1p.gz<\/code><\/pre>\n<h4>who<\/h4>\n<p>who - show who is logged on<\/p>\n<p>who [OPTION]...<\/p>\n<ul>\n<li>-b \u7cfb\u7edf\u6b64\u6b21\u542f\u52a8\u7684\u65f6\u95f4<\/li>\n<li>-r \u8fd0\u884c\u7ea7\u522b<\/li>\n<\/ul>\n<pre><code>[root@rhino014 ~]# who\nroot     pts\/4        2023-03-02 17:49 (192.168.8.5)\nroot     pts\/5        2023-03-02 16:35 (192.168.8.5)\nYou have mail in \/var\/spool\/mail\/root\n[root@rhino014 ~]# who -b\n         system boot  2022-10-03 10:30\nYou have mail in \/var\/spool\/mail\/root\n[root@rhino014 ~]# who -d\n         pts\/0        2023-03-02 18:24             21113 id=ts\/0  term=0 exit=0\n         pts\/1        2023-03-02 18:04             21814 id=ts\/1  term=0 exit=0\n         pts\/2        2023-03-02 18:24             26833 id=ts\/2  term=0 exit=0\n         pts\/3        2022-10-14 17:11             27715 id=ts\/3  term=0 exit=0\n         pts\/6        2022-10-25 16:11              3776 id=ts\/6  term=0 exit=0\n         pts\/7        2023-02-20 11:08             30255 id=ts\/7  term=0 exit=0\n         pts\/8        2023-02-06 11:59              9349 id=ts\/8  term=0 exit=0\n         pts\/9        2022-10-18 17:41             46290 id=ts\/9  term=0 exit=0\n         pts\/10       2023-02-06 11:59             15423 id=s\/10  term=0 exit=0\n         pts\/11       2022-10-04 12:30               991 id=s\/11  term=0 exit=0\n         pts\/12       2023-02-06 09:39             11101 id=s\/12  term=0 exit=0\n         pts\/13       2022-10-18 13:23              1726 id=s\/13  term=0 exit=0\n[root@rhino014 ~]# who -l\n[root@rhino014 ~]# who -u\nroot     pts\/4        2023-03-02 17:49   .          5156 (192.168.8.5)\nroot     pts\/5        2023-03-02 16:35 02:17       43483 (192.168.8.5)\n[root@rhino014 ~]# who -r\n         run-level 5  2022-10-03 10:31<\/code><\/pre>\n<h4>w<\/h4>\n<p>w - show who is logged on and what they are doing<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Linux\u6587\u4ef6\u7cfb\u7edf \u6587\u4ef6\u540d\u540d\u79f0\u4e25\u683c\u533a\u5206\u5b57\u7b26\u5927\u5c0f\u5199\uff1b \u6587\u4ef6\u53ef\u4ee5\u4f7f\u7528\u9664\u4e86\/\u4ee5\u5916\u7684\u4efb\u610f\u5b57\u7b26\uff1b \u6587\u4ef6\u540d\u957f\u5ea6\u4e0d\u80fd\u8d85\u8fc7255\u4e2a\u5b57\u7b26\uff1b \u4ee5.\u5f00\u5934\u7684\u6587\u4ef6   \u2026 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0},"categories":[131],"tags":[],"_links":{"self":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts\/1596"}],"collection":[{"href":"\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1596"}],"version-history":[{"count":1,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/1596\/revisions"}],"predecessor-version":[{"id":1597,"href":"\/index.php?rest_route=\/wp\/v2\/posts\/1596\/revisions\/1597"}],"wp:attachment":[{"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1596"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1596"},{"taxonomy":"post_tag","embeddable":true,"href":"\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1596"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}