{"id":192,"date":"2023-11-23T14:41:58","date_gmt":"2023-11-23T06:41:58","guid":{"rendered":"http:\/\/8.141.4.74\/?p=192"},"modified":"2025-01-01T22:16:38","modified_gmt":"2025-01-01T14:16:38","slug":"centos%e5%88%9d%e5%a7%8b%e5%8c%96%e9%85%8d%e7%bd%ae","status":"publish","type":"post","link":"http:\/\/8.141.4.74\/?p=192","title":{"rendered":"CentOS\u521d\u59cb\u5316\u914d\u7f6e"},"content":{"rendered":"<h1>CentOS  \u521d\u59cb\u5316\u914d\u7f6e\u4e8b\u9879<\/h1>\n<h2>1.\u914d\u7f6e\u547d\u4ee4\u63d0\u793a\u7b26<\/h2>\n<pre><code class=\"language-bash\">#\u5b89\u88c5\u7f51\u7edc\u7ba1\u7406\u548c\u7ba1\u7406\u7684\u57fa\u672c\u5de5\u5177\n[root@Centos7.9 ~]#yum -y install net-tools,vim\n#\u67e5\u770b\u5f53\u524d\u7684PS1(\u5df2\u7ecf\u66f4\u8be5\u8fc7\u4e86)\n[root@Centos7.9 profile.d]#echo $PS1 \n\\[\\e[1;32m\\][\\u@\\H \\W]\\$\\[\\e[0m\\]\n\n[root@Centos7.9 ~]#cd \/etc\/profile.d\/\n#\u521b\u5efa\u4e00\u4e2a\u4ee5.sh\u7ed3\u5c3e\u7684\u6587\u4ef6\u5373\u53ef\n[root@Centos7.9 profile.d]#touch color.sh\n\n#\u5c06\u4e0b\u9762\u4e09\u884c\u4ee3\u7801copy\u5230color.sh\u6587\u4ef6\u4e2d\uff0c\u4fdd\u5b58\u9000\u51fa\nPS1=&#039;\\[\\e[1;32m\\][\\u@\\H \\W]\\$\\[\\e[0m\\]&#039;\n# history-\u663e\u793a\u547d\u4ee4\u8f93\u5165\u7684\u65e5\u671f\u548c\u65f6\u95f4\nexport HISTTIMEFORMAT=&#039;%F %T &#039;\n\n#\u9000\u51fa\u7cfb\u7edf\uff0c\u91cd\u65b0\u8fdb\u5165\u5373\u53ef\u751f\u6548\nexit<\/code><\/pre>\n<h2>2.\u5b9a\u5236vim\u7684\u5de5\u4f5c\u7279\u6027<\/h2>\n<pre><code class=\"language-bash\">\u5168\u5c40\uff1a\/etc\/vimrc\n\u4e2a\u4eba\uff1a~\/.vimrc\n\n#\u521a\u521b\u5efa\u597d\u7684\u673a\u5668\/root\/\u4e0b\u662f\u6ca1\u6709.vimrc\u8fd9\u4e2a\u6587\u4ef6\u7684\uff0c\u9700\u8981\u521b\u5efa\n[root@Centos7.9 profile.d]#touch \/root\/.vimrc\n\n#\u5c06\u4e0b\u9762\u5185\u5bb9copy\u5230\/root\/.vimrc\u4e2d\nvim \/root\/.vimrc\n&quot;set nu\nsyntax on\n&quot;set paste\n&quot;\u8bbe\u7f6eF2\u5f00\u542f,\u5e73\u65f6\u4e0d\u5f00\u542f\nset pastetoggle=&lt;F2&gt;\n&quot;\u53ea\u8981\u662f\u63d2\u5165\u6a21\u5f0f\u5c31\u5f00\u542f,\u5e73\u65f6\u4e0d\u5f00\u542f\nautocmd InsertLeave * set nopaste\nautocmd InsertEnter * set paste\nset ignorecase\nset tabstop=2 &quot;ts=4\nset shiftwidth=2\nset nohlsearch &quot;\u53d6\u6d88\u9ad8\u4eae\u663e\u793a\uff0c\u4f46\u662f\u5149\u6807\u4f9d\u7136\u4f1a\u8df3\u8f6c\nset expandtab &quot;\u7528\u7a7a\u683c\u4ee3\u66fftab\nset backspace=indent,eol,start\nset noautoindent nosmartindent nocindent &quot;\u8bbe\u7f6e\u81ea\u52a8\u6362\u884c\uff0c\u6839\u636e\u6587\u4ef6\u7c7b\u578b\u786e\u5b9a\u6362\u884c\u683c\u5f0f\uff0c\u4f8b\u5982yaml\nset listchars=tab:&gt;-,eol:$,space:. &quot;vim\u4f4e\u7248\u672c\u4f1a\u62a5\u9519\uff0c\u8fd9\u91cc\u4f7f\u7528\u7684\u662fvim 9.1\n&quot;set cursorline\nautocmd FileType * setlocal formatoptions-=cro\nautocmd BufNewFile *.sh exec &quot;:call SetTitle()&quot;\nfunc SetTitle()\n    if expand(&quot;%:e&quot;) == &#039;sh&#039;\n    call setline(1,&quot;#!\/bin\/bash&quot;)\n    call setline(2,&quot;#&quot;)\n    call setline(3,&quot;#*******************************************************&quot;)\n    call setline(4,&quot;#Author:            xingyuyu&quot;)\n    call setline(5,&quot;#Date:              &quot;.strftime(&quot;%Y-%m-%d&quot;))\n    call setline(6,&quot;#Filename:          &quot;.expand(&quot;%&quot;))\n    call setline(7,&quot;#Copyright (C):     &quot;.strftime(&quot;%Y&quot;).&quot; All rights reserved&quot;)\n    call setline(8,&quot;#********************************************************&quot;)\n    call setline(9,&quot;&quot;)\n    endif\nendfunc\nautocmd BufNewFile * normal G\n&quot; \u5f53\u9000\u51fa Vim \u65f6\u81ea\u52a8\u4fdd\u5b58\u5149\u6807\u4f4d\u7f6e\nau BufReadPost *\n  \\ if line(&quot;&#039;\\&quot;&quot;) &gt; 1 &amp;&amp; line(&quot;&#039;\\&quot;&quot;) &lt;= line(&quot;$&quot;) |\n  \\   exe &quot;normal! g`\\&quot;&quot; |\n  \\ endif\n\n&quot; \u8fd9\u5c06\u4f7f Vim \u8bb0\u4f4f\u6bcf\u4e2a\u6587\u4ef6\u7684\u4e0a\u6b21\u7f16\u8f91\u4f4d\u7f6e\nset viminfo=&#039;10,\\&quot;100,:20,%,n~\/.viminfo\n\n# \u67e5\u770b\u4e00\u4e2a\u6a21\u5f0f\u662f\u5426\u662f\u5f00\u542f\u7684\n# \u6309\u4e0b\u5192\u53f7\uff0c\u8fdb\u5165\u6269\u5c55\u6a21\u5f0f\uff0c\u4f7f\u7528: set noexpandtab?\u53ea\u9700\u5728\u540e\u9762\u52a0\u4e0a\u4e00\u4e2a\u95ee\u53f7\u5373\u53ef\n\n:set noautoindent nosmartindent nocindent: \u8fd9\u6761\u547d\u4ee4\u662f\u7528\u6765\u5173\u95ed Vim \u4e2d\u7684\u51e0\u79cd\u81ea\u52a8\u7f29\u8fdb\u6a21\u5f0f\u3002\u5728 Vim \u4e2d\uff0c\u7f29\u8fdb\u8bbe\u7f6e\u5f71\u54cd\u7740\u7f16\u8f91\u5668\u5982\u4f55\u5904\u7406\u65b0\u884c\u7684\u7f29\u8fdb\u3002\nautoindent: \u8fd9\u4e2a\u9009\u9879\u4f1a\u4f7f\u5f97\u65b0\u7684\u884c\u81ea\u52a8\u7ee7\u627f\u524d\u4e00\u884c\u7684\u7f29\u8fdb\u3002\u5173\u95ed\u5b83\uff08noautoindent\uff09\u610f\u5473\u7740\u65b0\u884c\u4e0d\u4f1a\u81ea\u52a8\u590d\u5236\u524d\u4e00\u884c\u7684\u7f29\u8fdb\u3002\nsmartindent: \u8fd9\u662f\u4e00\u79cd\u66f4\u667a\u80fd\u7684\u81ea\u52a8\u7f29\u8fdb\u65b9\u5f0f\uff0c\u4e3b\u8981\u7528\u4e8e\u7f16\u7a0b\uff0c\u5c24\u5176\u662f C \u8bed\u8a00\u3002\u5b83\u4f1a\u6839\u636e\u4ee3\u7801\u7684\u7ed3\u6784\u6765\u8c03\u6574\u65b0\u884c\u7684\u7f29\u8fdb\u3002\u5173\u95ed\u5b83\uff08nosmartindent\uff09\u610f\u5473\u7740 Vim \u4e0d\u4f1a\u5c1d\u8bd5\u6839\u636e\u4ee3\u7801\u7ed3\u6784\u6765\u81ea\u52a8\u8bbe\u7f6e\u7f29\u8fdb\u3002\ncindent: \u7c7b\u4f3c\u4e8e smartindent\uff0c\u4f46\u66f4\u4e13\u95e8\u9488\u5bf9 C \u8bed\u8a00\u548c\u7c7b\u4f3c\u8bed\u6cd5\u7684\u7f16\u7a0b\u8bed\u8a00\u3002\u5173\u95ed\u8fd9\u4e2a\u9009\u9879\uff08nocindent\uff09\u610f\u5473\u7740 Vim \u4e0d\u4f1a\u81ea\u52a8\u8c03\u6574 C \u8bed\u8a00\u4ee3\u7801\u7684\u7f29\u8fdb\u3002\n\n:set backspace=indent,eol,start: \u8fd9\u6761\u547d\u4ee4\u8bbe\u7f6e\u4e86\u5728\u63d2\u5165\u6a21\u5f0f\u4e0b\u9000\u683c\u952e\u7684\u884c\u4e3a\u3002\u8fd9\u4e2a\u8bbe\u7f6e\u63a5\u53d7\u51e0\u4e2a\u503c\uff0c\u51b3\u5b9a\u9000\u683c\u952e\u53ef\u4ee5\u5220\u9664\u4ec0\u4e48\u7c7b\u578b\u7684\u5185\u5bb9\u3002\nindent: \u5141\u8bb8\u9000\u683c\u952e\u5220\u9664\u81ea\u52a8\u7f29\u8fdb\u3002\u8fd9\u610f\u5473\u7740\u4f60\u53ef\u4ee5\u7528\u9000\u683c\u952e\u5220\u9664\u7531 autoindent\u3001smartindent \u6216 cindent \u7b49\u8bbe\u7f6e\u81ea\u52a8\u6dfb\u52a0\u7684\u7a7a\u767d\u5b57\u7b26\u3002\neol: \u5141\u8bb8\u9000\u683c\u952e\u5220\u9664\u6362\u884c\u7b26\uff0c\u8fd9\u4f7f\u4f60\u80fd\u591f\u7528\u9000\u683c\u952e\u5408\u5e76\u4e24\u884c\u3002\nstart: \u5141\u8bb8\u9000\u683c\u952e\u5220\u9664\u63d2\u5165\u6a21\u5f0f\u5f00\u59cb\u4ee5\u6765\u6dfb\u52a0\u7684\u6240\u6709\u5185\u5bb9\u3002\u4e5f\u5c31\u662f\u8bf4\uff0c\u4f60\u53ef\u4ee5\u4e00\u76f4\u9000\u683c\u5230\u4f60\u5f00\u59cb\u63d2\u5165\u65f6\u7684\u4f4d\u7f6e\uff0c\u751a\u81f3\u66f4\u65e9\u3002\n\u8fd9\u4e2a\u8bbe\u7f6e\u7684\u7ec4\u5408 (indent,eol,start) \u63d0\u4f9b\u4e86\u5728\u63d2\u5165\u6a21\u5f0f\u4e0b\u8f83\u4e3a\u7075\u6d3b\u7684\u9000\u683c\u952e\u884c\u4e3a\uff0c\u5141\u8bb8\u4f60\u5220\u9664\u51e0\u4e4e\u6240\u6709\u4f60\u5728\u63d2\u5165\u6a21\u5f0f\u4e0b\u53ef\u80fd\u521b\u5efa\u7684\u5185\u5bb9\u3002\n<\/code><\/pre>\n<h2>3.\u914d\u7f6e\u547d\u4ee4\u7684\u5b50\u547d\u4ee4\u8865\u5168<\/h2>\n<pre><code class=\"language-bash\">[root@Centos7.9 profile.d]#yum -y install bash-completion\n\u5df2\u52a0\u8f7d\u63d2\u4ef6\uff1afastestmirror\nLoading mirror speeds from cached hostfile\n * base: mirrors.163.com\n * extras: mirrors.163.com\n * updates: mirrors.163.com\n\u6b63\u5728\u89e3\u51b3\u4f9d\u8d56\u5173\u7cfb\n--&gt; \u6b63\u5728\u68c0\u67e5\u4e8b\u52a1\n---&gt; \u8f6f\u4ef6\u5305 bash-completion.noarch.1.2.1-8.el7 \u5c06\u88ab \u5b89\u88c5\n--&gt; \u89e3\u51b3\u4f9d\u8d56\u5173\u7cfb\u5b8c\u6210\n\n\u4f9d\u8d56\u5173\u7cfb\u89e3\u51b3\n\n=================================================================================================================================================================================================================\n Package                                                 \u67b6\u6784                                           \u7248\u672c                                                  \u6e90                                            \u5927\u5c0f\n=================================================================================================================================================================================================================\n\u6b63\u5728\u5b89\u88c5:\n bash-completion                                         noarch                                         1:2.1-8.el7                                           base                                          87 k\n\n\u4e8b\u52a1\u6982\u8981\n=================================================================================================================================================================================================================\n\u5b89\u88c5  1 \u8f6f\u4ef6\u5305\n\n\u603b\u4e0b\u8f7d\u91cf\uff1a87 k\n\u5b89\u88c5\u5927\u5c0f\uff1a263 k\nDownloading packages:\nbash-completion-2.1-8.el7.noarch.rpm                                                                                                                                                      |  87 kB  00:00:01\nRunning transaction check\nRunning transaction test\nTransaction test succeeded\nRunning transaction\n  \u6b63\u5728\u5b89\u88c5    : 1:bash-completion-2.1-8.el7.noarch                                                                                                                                                           1\/1\n  \u9a8c\u8bc1\u4e2d      : 1:bash-completion-2.1-8.el7.noarch                                                                                                                                                           1\/1\n\n\u5df2\u5b89\u88c5:\n  bash-completion.noarch 1:2.1-8.el7\n\n\u5b8c\u6bd5\uff01\n[root@Centos7.9 profile.d]#\n\n#\u751f\u6548\n[root@Centos7.9 profile.d]#bash\n\n#Ubuntu\u4e5f\u53ef\u4ee5\u8fdb\u884c\u547d\u4ee4\u8865\u5168\n[root@Ubuntu ~]#apt install -y bash-completion<\/code><\/pre>\n<h2>4.\u521b\u5efa\u767b\u5f55\u63d0\u793a\u6587\u4ef6<\/h2>\n<pre><code class=\"language-bash\">#\u8fdb\u5165\/etc\/motd\u6587\u4ef6\n[root@Centos7.9 ~]#vim \/etc\/motd\n\n\u751f\u6210ASCII\u827a\u672f\u5b57\u96c6\uff1ahttps:\/\/www.bootschool.net\/ascii-art\n\n\u4f8b\u5982\uff1a\u5c06\u4e0b\u9762\u62f7\u8d1d\u5230\u6587\u4ef6\u4e2d\uff0c\u6216\u8005\u5c06\u6587\u4ef6\u4e0b\u8f7d\u4e0b\u6765\u76f4\u63a5\u66ff\u6362\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\/\/                          _ooOoo_                               \/\/\n\/\/                         o8888888o                              \/\/\n\/\/                         88&quot; . &quot;88                              \/\/\n\/\/                         (| ^_^ |)                              \/\/\n\/\/                         O\\  =  \/O                              \/\/\n\/\/                      ____\/`---&#039;\\____                           \/\/\n\/\/                    .&#039;  \\\\|     |\/\/  `.                         \/\/\n\/\/                   \/  \\\\|||  :  |||\/\/  \\                        \/\/\n\/\/                  \/  _||||| -:- |||||-  \\                       \/\/\n\/\/                  |   | \\\\\\  -  \/\/\/ |   |                       \/\/\n\/\/                  | \\_|  &#039;&#039;\\---\/&#039;&#039;  |   |                       \/\/\n\/\/                  \\  .-\\__  `-`  ___\/-. \/                       \/\/\n\/\/                ___`. .&#039;  \/--.--\\  `. . ___                     \/\/\n\/\/              .&quot;&quot; &#039;&lt;  `.___\\_&lt;|&gt;_\/___.&#039;  &gt;&#039;&quot;&quot;.                  \/\/\n\/\/            | | :  `- \\`.;`\\ _ \/`;.`\/ - ` : | |                 \/\/\n\/\/            \\  \\ `-.   \\_ __\\ \/__ _\/   .-` \/  \/                 \/\/\n\/\/      ========`-.____`-.___\\_____\/___.-`____.-&#039;========         \/\/\n\/\/                           `=---=&#039;                              \/\/\n\/\/      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^        \/\/\n\/\/            \u4f5b\u7956\u4fdd\u4f51       \u6c38\u4e0d\u5b95\u673a     \u6c38\u65e0BUG                    \/\/\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/<\/code><\/pre>\n<h2>5.\u8bbe\u7f6ealias<\/h2>\n<pre><code class=\"language-bash\">#\u5728\u65e5\u5e38\u5de5\u4f5c\u4e2d\uff0c\u9700\u8981\u53cd\u590d\u6267\u884c\u4e00\u4e2a\u5f88\u957f\u7684\u547d\u4ee4\uff0c\u4e3a\u4e86\u63d0\u9ad8\u5de5\u4f5c\u91cf\u5c06\u4e00\u4e9b\u590d\u6742\u5e38\u7528\u7684\u547d\u4ee4\u505a\u6210alias\n#\u5c06alias\u5199\u5165\u5230\/root\/.bashrc\u4e2d\n[root@Centos7.9 network-scripts]#vim \/root\/.bashrc\n\nalias vi=&#039;vim&#039;\nalias scandisk=&#039;echo &#039;\\&#039;&#039;- - -&#039;\\&#039;&#039; &gt; \/sys\/class\/scsi_host\/host0\/scan;echo &#039;\\&#039;&#039;- - -&#039;\\&#039;&#039; &gt; \/sys\/class\/scsi_host\/host1\/scan;echo &#039;\\&#039;&#039;- - -&#039;\\&#039;&#039; &gt; \/sys\/class\/scsi_host\/host2\/scan&#039;\nalias nm=&#039;systemctl restart NetworkManager&#039;\nalias yy=&#039;yum -y install&#039;\nalias yr=&#039;yum remove&#039;\nalias lh=&#039;ls -lh --color=auto&#039;\nalias cdnet=&#039;cd \/etc\/sysconfig\/network-scripts\/&#039;\nalias cdrepo=&#039;cd \/etc\/yum.repos.d\/&#039;\nalias viens160=&#039;vim \/etc\/sysconfig\/network-scripts\/ifcfg-ens160&#039;\nalias epel=&#039;sed -ri \/enabled\/s\/enabled=0\/enabled=1\/\/etc\/yum.repos.d\/base.repo&#039;\nalias disepel=&#039;sed -ri \/enabled\/s\/enabled=1\/enabled=0\/\/etc\/yum.repos.d\/base.repo&#039;\nalias rm=&#039;rm -i&#039;\nalias cdnet=&#039;cd \/etc\/sysconfig\/network-scripts\/&#039;\nalias editnet=&#039;vim \/etc\/sysconfig\/network-scripts\/ifcfg-eth0&#039;\n\n#\u5c06\u8fd9\u4e9bcopy\u5230\u6587\u4ef6\u5f53\u4e2d\n[root@Centos7.9 network-scripts]#source \/root\/.bashrc\n\n#\u67e5\u770b\u662f\u5426\u751f\u6548\n[root@Centos7.9 network-scripts]#alias\nalias cdnet=&#039;cd \/etc\/sysconfig\/network-scripts\/&#039;\nalias cdrepo=&#039;cd \/etc\/yum.repos.d\/&#039;\nalias cp=&#039;cp -i&#039;\nalias disepel=&#039;sed -ri \/enabled\/s\/enabled=1\/enabled=0\/\/etc\/yum.repos.d\/base.repo&#039;\nalias editnet=&#039;vim \/etc\/sysconfig\/network-scripts\/ifcfg-eth0&#039;\nalias egrep=&#039;egrep --color=auto&#039;\nalias epel=&#039;sed -ri \/enabled\/s\/enabled=0\/enabled=1\/\/etc\/yum.repos.d\/base.repo&#039;\nalias fgrep=&#039;fgrep --color=auto&#039;\nalias grep=&#039;grep --color=auto&#039;\nalias l.=&#039;ls -d .* --color=auto&#039;\nalias lh=&#039;ls -lh --color=auto&#039;\nalias ll=&#039;ls -l --color=auto&#039;\nalias ls=&#039;ls --color=auto&#039;\nalias mv=&#039;mv -i&#039;\nalias nm=&#039;systemctl restart NetworkManager&#039;\nalias rm=&#039;rm -i&#039;\nalias scandisk=&#039;echo &#039;\\&#039;&#039;- - -&#039;\\&#039;&#039; &gt; \/sys\/class\/scsi_host\/host0\/scan;echo &#039;\\&#039;&#039;- - -&#039;\\&#039;&#039; &gt; \/sys\/class\/scsi_host\/host1\/scan;echo &#039;\\&#039;&#039;- - -&#039;\\&#039;&#039; &gt; \/sys\/class\/scsi_host\/host2\/scan&#039;\nalias vi=&#039;vim&#039;\nalias viens160=&#039;vim \/etc\/sysconfig\/network-scripts\/ifcfg-ens160&#039;\nalias which=&#039;alias | \/usr\/bin\/which --tty-only --read-alias --show-dot --show-tilde&#039;\nalias yr=&#039;yum remove&#039;\nalias yy=&#039;yum -y install&#039;\n<\/code><\/pre>\n<h2>6.\u4fee\u6539\u7f51\u5361\u540d\u53d8\u6210\u4f20\u7edf\u7684\u7f51\u5361(eth0)<\/h2>\n<pre><code class=\"language-bash\">#\u67e5\u770b\u8981\u4fee\u6539\u7684\u6587\u4ef6\n[root@Centos7.9 ~]#vim \/etc\/default\/grub\n\n#CentOS\u4f7f\u7528sed\u8fdb\u884c\u4fee\u6539\u6587\u4ef6\n[root@Centos7.9 ~]#sed -ri &#039;\/^GRUB_CMDLINE_LINUX\/s#(.*)&quot;$#\\1 net.ifnames=0&quot;#&#039; \/etc\/default\/grub\n\n#Ubuntu\u4f7f\u7528sed\u8fdb\u884c\u4fee\u6539\u6587\u4ef6\n\n#\u67e5\u770b\u6587\u4ef6\u662f\u5426\u66f4\u6539\n[root@Centos7.9 ~]#cat \/etc\/default\/grub\nGRUB_TIMEOUT=5\nGRUB_DISTRIBUTOR=&quot;$(sed &#039;s, release .*$,,g&#039; \/etc\/system-release)&quot;\nGRUB_DEFAULT=saved\nGRUB_DISABLE_SUBMENU=true\nGRUB_TERMINAL_OUTPUT=&quot;console&quot;\nGRUB_CMDLINE_LINUX=&quot;crashkernel=auto rd.lvm.lv=centos\/root rd.lvm.lv=centos\/swap rhgb quiet net.ifnames=0&quot;\nGRUB_DISABLE_RECOVERY=&quot;true&quot;\n[root@Centos7.9 ~]#\n\n#\u751f\u6548\n[root@Centos7.9 ~]#grub2-mkconfig -o \/boot\/grub2\/grub.cfg\nGenerating grub configuration file ...\nFound linux image: \/boot\/vmlinuz-3.10.0-1160.el7.x86_64\nFound initrd image: \/boot\/initramfs-3.10.0-1160.el7.x86_64.img\nFound linux image: \/boot\/vmlinuz-0-rescue-9b4d5004256f4475a92c1e73d79fea17\nFound initrd image: \/boot\/initramfs-0-rescue-9b4d5004256f4475a92c1e73d79fea17.img\ndone\n[root@Centos7.9 ~]#\n#\u4e5f\u53ef\u4ee5\u8fd9\u6837\u5199\n[root@Centos7.9 ~]#grub2-mkconfig -o \/etc\/grub2.cf\n#\u56e0\u4e3a\u8fd9\u4e24\u4e2a\u662f\u8f6f\u94fe\u63a5\u7684\u5173\u7cfb\n[root@CentOS8 ~]# ll \/etc\/grub2.cfg\nlrwxrwxrwx. 1 root root 22 11\u6708  8 2021 \/etc\/grub2.cfg -&gt; ..\/boot\/grub2\/grub.cfg\n#\u547d\u4ee4\u89e3\u91ca\uff1a\n#grub2-mkconfig -o \/boot\/grub2\/grub.cfg \u662f\u4e00\u4e2aLinux\u7cfb\u7edf\u547d\u4ee4\uff0c\u7528\u4e8e\u751f\u6210\u6216\u66f4\u65b0GRUB2\u5f15\u5bfc\u52a0\u8f7d\u5668\u7684\u914d\u7f6e\u6587\u4ef6\u3002\u4e0b\u9762\u662f\u547d\u4ee4\u5404\u90e8\u5206\u7684\u8be6\u7ec6\u89e3\u91ca\uff1a\n#grub2-mkconfig\uff1a\u8fd9\u662f\u4e00\u4e2a\u7528\u4e8e\u751f\u6210GRUB2\u914d\u7f6e\u6587\u4ef6\u7684\u547d\u4ee4\u3002GRUB2\u662f\u4e00\u4e2a\u901a\u7528\u7684\u5f15\u5bfc\u52a0\u8f7d\u5668\uff0c\u5b83\u5141\u8bb8\u5728\u542f\u52a8\u65f6\u9009\u62e9\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf\u6216\u5185\u6838\u7248\u672c\u3002\n#-o\uff1a\u8fd9\u662f\u4e00\u4e2a\u9009\u9879\uff0c\u8868\u793a\u8f93\u51fa\u3002\u5b83\u544a\u8bc9grub2-mkconfig\u5c06\u751f\u6210\u7684\u914d\u7f6e\u6587\u4ef6\u5185\u5bb9\u5199\u5165\u5230\u6307\u5b9a\u7684\u6587\u4ef6\u4e2d\u3002\n#\/boot\/grub2\/grub.cfg\uff1a\u8fd9\u662f\u914d\u7f6e\u6587\u4ef6\u7684\u8def\u5f84\u3002\/boot\/grub2\/\u76ee\u5f55\u901a\u5e38\u5305\u542bGRUB2\u7684\u76f8\u5173\u6587\u4ef6\uff0c\u800cgrub.cfg\u662fGRUB2\u5f15\u5bfc\u52a0\u8f7d\u5668\u7684\u4e3b\u8981\u914d\u7f6e\u6587\u4ef6\u3002\u6b64\u6587\u4ef6\u5305\u542b\u4e86\u5f15\u5bfc\u83dc\u5355\u7684\u8bbe\u7f6e\u4ee5\u53ca\u53ef\u7528\u64cd\u4f5c\u7cfb\u7edf\u7684\u5217\u8868\u3002\u7efc\u4e0a\u6240\u8ff0\uff0cgrub2-mkconfig -o \/boot\/grub2\/grub.cfg \u547d\u4ee4\u7684\u4f5c\u7528\u662f\u751f\u6210\u6216\u66f4\u65b0GRUB2\u7684\u4e3b\u8981\u914d\u7f6e\u6587\u4ef6\uff08grub.cfg\uff09\uff0c\u4ee5\u4fbf\u6b63\u786e\u5f15\u5bfc\u60a8\u7684Linux\u7cfb\u7edf\u3002\u5728\u5b89\u88c5\u65b0\u7684\u5185\u6838\u6216\u64cd\u4f5c\u7cfb\u7edf\u65f6\uff0c\u8fd9\u4e2a\u547d\u4ee4\u901a\u5e38\u4f1a\u88ab\u7528\u6765\u66f4\u65b0\u5f15\u5bfc\u83dc\u5355\u3002\n\n#Ubuntu\u751f\u6548\n[root@Ubuntu ~]#grub-mkconfig -o \/boot\/grub\/grub.cfg\n\n#\u91cd\u542f\u751f\u6548\n[root@Centos7.9 ~]#reboot\n\n#\u5220\u9664\u4e4b\u524d\u7684\u7f51\u5361\u914d\u7f6e\u6587\u4ef6\uff0c\u5982\u679c\u4e0d\u5220\u9664\uff0c\u7f51\u7edc\u4f1a\u8d77\u4e0d\u6765\n[root@Centos7.9 ~]#cd \/etc\/sysconfig\/network-scripts\/\n[root@Centos7.9 network-scripts]#rm -rf ifcef-ens33\n\n#\u91cd\u65b0\u521b\u5efaeth0\u7f51\u5361\u7684\u914d\u7f6e\u6587\u4ef6\n[root@Centos7.9 network-scripts]#touch ifcfg-eth0\n[root@Centos7.9 network-scripts]#vim ifcfg-eth0\n\n#\u5c06\u4e0b\u9762\u5185\u5bb9\u62f7\u8d1d\u7684\u5230\u6587\u4ef6\u4e2d\nDEVICE=eth0\nNAME=eth0\nBOOTPROTO=static\nIPADDR=10.0.0.108\nNETMASK=255.255.255.0\nGATEWAY=10.0.0.2\nDNS1=10.0.0.2\n\n#\u91cd\u542f\u7f51\u7edc\n[root@Centos7.9 network-scripts]#systemctl restart network\n\u6216\u8005\n[root@Centos7.9 network-scripts]#ifdown ifcfg-eth0\n[root@Centos7.9 network-scripts]#ifup ifcfg-eth0\n<\/code><\/pre>\n<h2>7.\u4fee\u6539\u5f53\u524d\u7cfb\u7edf\u7684\u8bed\u8a00\u73af\u5883<\/h2>\n<pre><code class=\"language-bash\">#CentOS 6\n#\u4e34\u65f6\u66f4\u6539\u8bed\u8a00\u73af\u5883\uff08\u4ec5\u5bf9\u5f53\u524d shell \u4f1a\u8bdd\u6709\u6548\uff09\uff1a\u5c06\u7acb\u5373\u5c06\u5f53\u524d shell \u7684\u8bed\u8a00\u73af\u5883\u5207\u6362\u5230\u82f1\u6587\u3002\u4f46\u8bf7\u6ce8\u610f\uff0c\u8fd9\u79cd\u66f4\u6539\u53ea\u5bf9\u5f53\u524d\u4f1a\u8bdd\u6709\u6548\u3002\u5982\u679c\u60a8\u5173\u95ed shell \u6216\u91cd\u65b0\u542f\u52a8\u8ba1\u7b97\u673a\uff0c\u66f4\u6539\u5c06\u4e0d\u518d\u4fdd\u7559\u3002\nexport LANG=en_US.UTF-8\n#\u6c38\u4e45\u66f4\u6539\u8bed\u8a00\u73af\u5883\uff08\u5bf9\u6240\u6709\u7528\u6237\u548c\u4f1a\u8bdd\u751f\u6548\uff09\uff1a\nsudo vi \/etc\/sysconfig\/i18n\n#\u5728\u6587\u4ef6\u4e2d\uff0c\u627e\u5230\u4ee5\u4e0b\u884c\uff1a\nLANG=&quot;zh_CN.UTF-8&quot;\n#\u4fee\u6539\u4e3a\uff1a\nLANG=&quot;en_US.UTF-8&quot;\n#reboot\n\n#CentOS 7\u30018\n#\u4e34\u65f6\u66f4\u6539\u8bed\u8a00\u73af\u5883\uff08\u4ec5\u5bf9\u5f53\u524d shell \u4f1a\u8bdd\u6709\u6548\uff09\uff1a\nexport LANG=en_US.UTF-8\n#\u6c38\u4e45\u66f4\u6539\u8bed\u8a00\u73af\u5883\uff08\u5bf9\u6240\u6709\u7528\u6237\u548c\u4f1a\u8bdd\u751f\u6548\uff09\uff1a\nsudo vi \/etc\/locale.conf\n#\u5728\u6587\u4ef6\u4e2d\uff0c\u627e\u5230\u4ee5\u4e0b\u884c\uff1a\nLANG=&quot;zh_CN.UTF-8&quot;\n#\u4fee\u6539\u4e3a\uff1a\nLANG=&quot;en_US.UTF-8&quot;\n#reboot\n<\/code><\/pre>\n<h2>8.ssh\u5141\u8bb8root\u767b\u5f55<\/h2>\n<pre><code class=\"language-bash\"> # \u5141\u8bb8root\u7528\u6237SSH\u767b\u5f55\n echo &quot;PermitRootLogin yes&quot; &gt;&gt; \/etc\/ssh\/sshd_config\n # \u91cd\u542fSSH\u670d\u52a1\u4ee5\u5e94\u7528\u66f4\u6539\n systemctl restart sshd<\/code><\/pre>\n<h2>9.\u5173\u95edselinux<\/h2>\n<pre><code class=\"language-bash\"> sed -ri &#039;\/^SELINUX=\/s\/(.*)enforcing\/\\1disabled\/&#039; \/etc\/selinux\/config\n reboot<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>CentOS \u521d\u59cb\u5316\u914d\u7f6e\u4e8b\u9879 1.\u914d\u7f6e\u547d\u4ee4\u63d0\u793a\u7b26 #\u5b89\u88c5\u7f51\u7edc\u7ba1\u7406\u548c\u7ba1\u7406\u7684\u57fa\u672c\u5de5\u5177 [root@Cen [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[18],"views":229,"_links":{"self":[{"href":"http:\/\/8.141.4.74\/index.php?rest_route=\/wp\/v2\/posts\/192"}],"collection":[{"href":"http:\/\/8.141.4.74\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/8.141.4.74\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/8.141.4.74\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/8.141.4.74\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=192"}],"version-history":[{"count":6,"href":"http:\/\/8.141.4.74\/index.php?rest_route=\/wp\/v2\/posts\/192\/revisions"}],"predecessor-version":[{"id":516,"href":"http:\/\/8.141.4.74\/index.php?rest_route=\/wp\/v2\/posts\/192\/revisions\/516"}],"wp:attachment":[{"href":"http:\/\/8.141.4.74\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=192"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/8.141.4.74\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=192"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/8.141.4.74\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=192"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}