<div id="cnblogs_post_body" class="blogpost-body">
<h1 id="linnux系统常见目录及文件" tid="tid-WwZEp6">linnux系统常见目录及文件<button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h1>
<h2 id="linux目录结构" tid="tid-nJRCbQ">linux目录结构<button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h2>
<h3 id="常见目录" tid="tid-5TnXFd">常见目录<button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h3>
<div class="table-wrapper"><table>
<thead>
<tr>
<th>目录名</th>
<th>职能</th>
</tr>
</thead>
<tbody>
<tr>
<td>bin</td>
<td>存放二进制命令文件</td>
</tr>
<tr>
<td>sbin</td>
<td>存放管理员二进制命令文件</td>
</tr>
<tr>
<td>etc</td>
<td>存放系统或者服务的配置文件</td>
</tr>
<tr>
<td>mnt</td>
<td>临时挂载目录(资源的入口)</td>
</tr>
<tr>
<td>opt</td>
<td>存放第三方软件(通常情况下就是软件的压缩包)</td>
</tr>
<tr>
<td>proc</td>
<td>内存相关信息</td>
</tr>
<tr>
<td>tmp</td>
<td>临时存放数据</td>
</tr>
<tr>
<td>var</td>
<td>经常变化的文件(日志文件)</td>
</tr>
<tr>
<td>usr</td>
<td>用户相关程序</td>
</tr>
</tbody>
</table></div>
<h3 id="目录结构说明" tid="tid-7C2rha">目录结构说明<button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h3>
<ol>
<li>linux根下⾯的⽬录是⼀个有层次的树状结构</li>
<li>linux每个⽬录可以挂载在不同的设备(磁盘)上 挂载</li>
</ol>
<p>当我们连接一个存储设备时,我们可以从dev目录下查找到</p>
<code-box id="code-AaBCGS"><button boxid="code-AaBCGS" type="button" class="clipboard code-copay-btn hljs-comment" data-clipboard-action="copy" data-clipboard-target="#code-AaBCGS pre" aria-label="复制代码" style="opacity: 0; visibility: hidden;"><i class="iconfont icon-fuzhi1"></i></button><div class="code-tools" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(40, 44, 52);"><hljs-len class="code-hljs-len" style="visibility: visible;">apache</hljs-len></div><pre boxid="code-AaBCGS" class="hljs apache code-pre-line" style="white-space: pre;"><code-line class="line-numbers-rows"></code-line><span class="hljs-attribute">ls</span> -l /dev/cdrom
<code-line class="line-numbers-rows"></code-line><span class="hljs-attribute">lrwxrwxrwx</span>. <span class="hljs-number">1</span> root root <span class="hljs-number">3</span> Jan <span class="hljs-number">10</span> <span class="hljs-number">09</span>:<span class="hljs-number">29</span> /dev/cdrom -> sr<span class="hljs-number">0</span></pre></code-box>
<p>我们可以将其挂载到一个目录下:</p>
<code-box id="code-npdDZC"><button boxid="code-npdDZC" type="button" class="clipboard code-copay-btn hljs-comment" data-clipboard-action="copy" data-clipboard-target="#code-npdDZC pre" aria-label="复制代码" style="opacity: 0; visibility: hidden;"><i class="iconfont icon-fuzhi1"></i></button><div class="code-tools" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(40, 44, 52);"><hljs-len class="code-hljs-len" style="visibility: visible;">awk</hljs-len></div><pre boxid="code-npdDZC" class="hljs awk code-pre-line" style="white-space: pre;"><code-line class="line-numbers-rows"></code-line>mount <span class="hljs-regexp">/dev/</span>cdrom <span class="hljs-regexp">/mnt/</span></pre></code-box>
<p>挂载后可以通过/mnt/访问到这个存储设备的内容</p>
<p>也可以取消挂载:</p>
<code-box id="code-tnCPDi"><button boxid="code-tnCPDi" type="button" class="clipboard code-copay-btn hljs-comment" data-clipboard-action="copy" data-clipboard-target="#code-tnCPDi pre" aria-label="复制代码" style="opacity: 0; visibility: hidden;"><i class="iconfont icon-fuzhi1"></i></button><div class="code-tools" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(40, 44, 52);"><hljs-len class="code-hljs-len" style="visibility: visible;">jboss-cli</hljs-len></div><pre boxid="code-tnCPDi" class="hljs jboss-cli code-pre-line" style="white-space: pre;"><code-line class="line-numbers-rows"></code-line>unmount <span class="hljs-string">/mnt</span></pre></code-box>
<h2 id="etc目录下重要的数据文件" tid="tid-t7wNh3">etc目录下重要的数据文件<button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h2>
<h4 id="tid-XtsPai" tid="tid-XtsPai">1./etc/fstab (filesystem table 系统挂载信息表)<button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h4>
<p>磁盘 --- 分区格式化 --- 系统中可以看到磁盘设备 --- 挂载</p>
<p>临时挂载:<code>mount /dev/cdrom/mnt</code></p>
<p>永久挂载:修改/etc/fatab文件</p>
<code-box id="code-KB3Fzb"><button boxid="code-KB3Fzb" type="button" class="clipboard code-copay-btn hljs-comment" data-clipboard-action="copy" data-clipboard-target="#code-KB3Fzb pre" aria-label="复制代码" style="opacity: 0; visibility: hidden;"><i class="iconfont icon-fuzhi1"></i></button><div class="code-tools" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(40, 44, 52);"><hljs-len class="code-hljs-len" style="visibility: visible;">awk</hljs-len></div><pre boxid="code-KB3Fzb" class="hljs awk code-pre-line" style="white-space: pre;"><code-line class="line-numbers-rows"></code-line>文件内容:
<code-line class="line-numbers-rows"></code-line><span class="hljs-regexp">/dev/</span>第⼀个分区 : /boot
<code-line class="line-numbers-rows"></code-line><span class="hljs-regexp">/dev/</span>第⼆个分区 : swap
<code-line class="line-numbers-rows"></code-line><span class="hljs-regexp">/dev/</span>第三个分区 : /
<code-line class="line-numbers-rows"></code-line>cat <span class="hljs-regexp">/etc/</span>fstab <span class="hljs-comment"># 查看⽂件内容</span>
<code-line class="line-numbers-rows"></code-line>blkid <span class="hljs-comment"># 查看磁盘分区</span>
<code-line class="line-numbers-rows"></code-line>总结:实现磁盘存储设备,挂载操作永久⽣效,开机⾃动加载挂载信息</pre></code-box>
<h4 id="tid-Ftamz2" tid="tid-Ftamz2">2./etc/rc.local (此文件中只能存放linux系统命令操作信息)<button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h4>
<p>系统正常加载启动 --- 读取rc.local文件 --- 文件主要保存命令信息 --- 执行文件中的命令 --- 系统启动成功</p>
<code-box id="code-cy37Nn"><button boxid="code-cy37Nn" type="button" class="clipboard code-copay-btn hljs-comment" data-clipboard-action="copy" data-clipboard-target="#code-cy37Nn pre" aria-label="复制代码" style="opacity: 0; visibility: hidden;"><i class="iconfont icon-fuzhi1"></i></button><div class="code-tools" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(40, 44, 52);"><hljs-len class="code-hljs-len" style="visibility: visible;">awk</hljs-len></div><pre boxid="code-cy37Nn" class="hljs awk code-pre-line" style="white-space: pre;"><code-line class="line-numbers-rows"></code-line><span class="hljs-comment"># eg:我们可以在这个文件中加一个开机自动备份的功能</span>
<code-line class="line-numbers-rows"></code-line> cp <span class="hljs-regexp">/etc/</span>sysconfig<span class="hljs-regexp">/network-scripts/i</span>fcfg-eth0 <span class="hljs-regexp">/tmp/i</span>fcfg-eth0.bak <span class="hljs-comment"># 将文件备份到指定路径的命令</span>
<code-line class="line-numbers-rows"></code-line> echo <span class="hljs-string">"cp /etc/sysconfig/network-scripts/ifcfg eth0 /tmp/ifcfg-eth0.bak"</span> >> <span class="hljs-regexp">/etc/</span>rc.local
<code-line class="line-numbers-rows"></code-line> <span class="hljs-comment"># 将这条命令追加写到rc.local中</span>
<code-line class="line-numbers-rows"></code-line>chmod +x <span class="hljs-regexp">/etc/</span>rc.d/rc.local</pre></code-box>
<blockquote>
<p>运维操作规范(运维⼈员==救⽕队员)<br>
1)操作之前进⾏检查 2)操作之前进⾏备份 3)操作之后进⾏确认 4)操作之后进⾏总结<br>
具体操作:</p>
<p>1)检查相应路径是否存在备份⽂件 --有备份⽂件:进⾏删除<br>
2)先在命令⾏进行测试执⾏ 3)编辑开机⾃动加载命令配置⽂件rc.local 4)重启系统进⾏确认</p>
</blockquote>
<h4 id="tid-KPKxw6" tid="tid-KPKxw6">3./etc/inittab (系统启动运行级别配置文件)<button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h4>
<code-box id="code-KZ82GC"><button boxid="code-KZ82GC" type="button" class="clipboard code-copay-btn hljs-comment" data-clipboard-action="copy" data-clipboard-target="#code-KZ82GC pre" aria-label="复制代码" style="opacity: 0; visibility: hidden;"><i class="iconfont icon-fuzhi1"></i></button><div class="code-tools" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(40, 44, 52);"><hljs-len class="code-hljs-len" style="visibility: visible;">cmake</hljs-len></div><pre boxid="code-KZ82GC" class="hljs cmake code-pre-line" style="white-space: pre;"><code-line class="line-numbers-rows"></code-line> 系统启动运⾏级别
<code-line class="line-numbers-rows"></code-line> 系统启动时候:
<code-line class="line-numbers-rows"></code-line> A系统启动:⽹络服务运⾏ 安全服务运⾏ 存储服务运⾏ <span class="hljs-number">01</span>级 别
<code-line class="line-numbers-rows"></code-line> B系统启动:安全服务运⾏ 存储服务运⾏ <span class="hljs-number">02</span>级 别
<code-line class="line-numbers-rows"></code-line> C系统启动:存储服务运⾏ <span class="hljs-number">03</span>级 别
<code-line class="line-numbers-rows"></code-line> 三种系统:运⾏启动级别不⼀样
<code-line class="line-numbers-rows"></code-line>
<code-line class="line-numbers-rows"></code-line> centos6 (<span class="hljs-number">7</span>种运⾏级别)
<code-line class="line-numbers-rows"></code-line> <span class="hljs-number">0</span> 关机级别(init <span class="hljs-number">0</span>)
<code-line class="line-numbers-rows"></code-line> <span class="hljs-number">1</span> 单⽤户模式(重置⽤户密码信息root 修复系统)
<code-line class="line-numbers-rows"></code-line>救援模式
<code-line class="line-numbers-rows"></code-line> <span class="hljs-number">2</span> 多⽤户模式 NFS (没有⽹络服务)
<code-line class="line-numbers-rows"></code-line> <span class="hljs-number">3</span> 多⽤户模式 (命令⾏模式)
<code-line class="line-numbers-rows"></code-line> <span class="hljs-number">4</span> 未知 未使⽤
<code-line class="line-numbers-rows"></code-line> <span class="hljs-number">5</span> 图形化界⾯模式(init <span class="hljs-number">5</span>)
<code-line class="line-numbers-rows"></code-line> <span class="hljs-number">6</span> 重启级别
<code-line class="line-numbers-rows"></code-line> centos7 (<span class="hljs-keyword">target</span>⽬标)
<code-line class="line-numbers-rows"></code-line> ls /usr/lib/systemd/system/runlevel*<span class="hljs-keyword">target</span> -l <span class="hljs-comment"># 查看文件命令</span>
<code-line class="line-numbers-rows"></code-line> poweroff.<span class="hljs-keyword">target</span>
<code-line class="line-numbers-rows"></code-line> rescue.<span class="hljs-keyword">target</span>
<code-line class="line-numbers-rows"></code-line> multi-user.<span class="hljs-keyword">target</span>
<code-line class="line-numbers-rows"></code-line> multi-user.<span class="hljs-keyword">target</span>
<code-line class="line-numbers-rows"></code-line> multi-user.<span class="hljs-keyword">target</span>
<code-line class="line-numbers-rows"></code-line> graphical.<span class="hljs-keyword">target</span>
<code-line class="line-numbers-rows"></code-line> reboot.<span class="hljs-keyword">target</span></pre></code-box>
<p>调整系统运行级别</p>
<code-box id="code-BXSEmD"><button boxid="code-BXSEmD" type="button" class="clipboard code-copay-btn hljs-comment" data-clipboard-action="copy" data-clipboard-target="#code-BXSEmD pre" aria-label="复制代码" style="opacity: 0; visibility: hidden;"><i class="iconfont icon-fuzhi1"></i></button><div class="code-tools" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(40, 44, 52);"><hljs-len class="code-hljs-len" style="visibility: visible;">dsconfig</hljs-len></div><pre boxid="code-BXSEmD" class="hljs dsconfig code-pre-line" style="white-space: pre;"><code-line class="line-numbers-rows"></code-line><span class="hljs-string">centos6</span>
<code-line class="line-numbers-rows"></code-line> <span class="hljs-string">init</span> 级别信息 临时修改
<code-line class="line-numbers-rows"></code-line> <span class="hljs-string">vim</span> /<span class="hljs-string">etc</span>/<span class="hljs-string">inittab</span> 永久修改
<code-line class="line-numbers-rows"></code-line> <span class="hljs-string">centos7</span>
<code-line class="line-numbers-rows"></code-line> <span class="hljs-string">systemctl</span> <span class="hljs-built_in">get-default</span> 获取级别信息
<code-line class="line-numbers-rows"></code-line> <span class="hljs-string">systemctl</span> <span class="hljs-built_in">set-default</span> 修改了级别</pre></code-box>
<h4 id="tid-Ds6APK" tid="tid-Ds6APK">4./etc/profile (配置环境变量信息或者别名信息⽂件)<button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h4>
<p>类似于win中的环境变量配置,是linux中的环境变量特征</p>
<ol>
<li>环境变量都⽤⼤写字⺟表示</li>
<li>环境变量可以被所有⽤户所使⽤</li>
<li>环境⼀般是系统安装就已经设置</li>
</ol>
<code-box id="code-ENz73J"><button boxid="code-ENz73J" type="button" class="clipboard code-copay-btn hljs-comment" data-clipboard-action="copy" data-clipboard-target="#code-ENz73J pre" aria-label="复制代码" style="opacity: 0; visibility: hidden;"><i class="iconfont icon-fuzhi1"></i></button><div class="code-tools" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(40, 44, 52);"><hljs-len class="code-hljs-len" style="visibility: visible;">autoit</hljs-len></div><pre boxid="code-ENz73J" class="hljs autoit code-pre-line" style="white-space: pre;"><code-line class="line-numbers-rows"></code-line> <span class="hljs-meta"># 第⼀个⾥程:定义变量</span>
<code-line class="line-numbers-rows"></code-line> [root<span class="hljs-symbol">@jasonNB</span> ~]<span class="hljs-meta"># oldboy=123</span>
<code-line class="line-numbers-rows"></code-line> <span class="hljs-meta"># 第⼆个⾥程:调取变量信息</span>
<code-line class="line-numbers-rows"></code-line> [root<span class="hljs-symbol">@jasonNB</span> ~]<span class="hljs-meta"># echo $oldboy</span>
<code-line class="line-numbers-rows"></code-line> <span class="hljs-meta"># 第三个⾥程:调整变量值信息</span>
<code-line class="line-numbers-rows"></code-line> [root<span class="hljs-symbol">@jasonNB</span> ~]<span class="hljs-meta"># oldboy=456</span>
<code-line class="line-numbers-rows"></code-line> [root<span class="hljs-symbol">@jasonNB</span> ~]<span class="hljs-meta"># echo $oldboy</span></pre></code-box>
<h4 id="tid-Y24TGC" tid="tid-Y24TGC">5./etc/bashrc (设置别名信息)<button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h4>
<p>常用于将一些命令缩写,来减少操作的复杂性</p>
<code-box id="code-QdRR8Y"><button boxid="code-QdRR8Y" type="button" class="clipboard code-copay-btn hljs-comment" data-clipboard-action="copy" data-clipboard-target="#code-QdRR8Y pre" aria-label="复制代码" style="opacity: 0; visibility: hidden;"><i class="iconfont icon-fuzhi1"></i></button><div class="code-tools" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(40, 44, 52);"><hljs-len class="code-hljs-len" style="visibility: visible;">awk</hljs-len></div><pre boxid="code-QdRR8Y" class="hljs awk code-pre-line" style="white-space: pre;"><code-line class="line-numbers-rows"></code-line>执行以下两句及结果
<code-line class="line-numbers-rows"></code-line>[root@vm ~]<span class="hljs-comment"># ls -l /etc/hosts</span>
<code-line class="line-numbers-rows"></code-line> -rw-r--r--. <span class="hljs-number">1</span> root root <span class="hljs-number">181</span> Dec <span class="hljs-number">7</span> <span class="hljs-number">12</span>:<span class="hljs-number">28</span> <span class="hljs-regexp">/etc/</span>hosts
<code-line class="line-numbers-rows"></code-line> [root@vm ~]<span class="hljs-comment"># ll /etc/hosts</span>
<code-line class="line-numbers-rows"></code-line> -rw-r--r--. <span class="hljs-number">1</span> root root <span class="hljs-number">181</span> Dec <span class="hljs-number">7</span> <span class="hljs-number">12</span>:<span class="hljs-number">28</span> <span class="hljs-regexp">/etc/</span>hosts
<code-line class="line-numbers-rows"></code-line> <span class="hljs-string">'''别名的定义既可以在profile⾥⾯也可以在bashrc⾥设置'''</span>
<code-line class="line-numbers-rows"></code-line> <span class="hljs-regexp">/etc/</span>profile 国法
<code-line class="line-numbers-rows"></code-line> <span class="hljs-regexp">/etc/</span>bashrc 国法
<code-line class="line-numbers-rows"></code-line> ~/.bashrc 家规
<code-line class="line-numbers-rows"></code-line> ~/.bash_profile 家规 </pre></code-box>
<h4 id="tid-dmzGTB" tid="tid-dmzGTB">6./etc/motd(用户登录之后的提示信息)<button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h4>
<code-box id="code-DMf2c4"><button boxid="code-DMf2c4" type="button" class="clipboard code-copay-btn hljs-comment" data-clipboard-action="copy" data-clipboard-target="#code-DMf2c4 pre" aria-label="复制代码" style="opacity: 0; visibility: hidden;"><i class="iconfont icon-fuzhi1"></i></button><div class="code-tools" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(40, 44, 52);"><hljs-len class="code-hljs-len" style="visibility: visible;">haxe</hljs-len></div><pre boxid="code-DMf2c4" class="hljs haxe code-pre-line" style="white-space: pre;"><code-line class="line-numbers-rows"></code-line>[]<span class="hljs-meta"># vi /etc/motd</span>
<code-line class="line-numbers-rows"></code-line>将此段文本放进去
<code-line class="line-numbers-rows"></code-line> _oo0oo_
<code-line class="line-numbers-rows"></code-line> <span class="hljs-number">088888880</span>
<code-line class="line-numbers-rows"></code-line> <span class="hljs-number">88</span><span class="hljs-string">" . "</span><span class="hljs-number">88</span>
<code-line class="line-numbers-rows"></code-line> (| -<span class="hljs-literal">_</span>- |)
<code-line class="line-numbers-rows"></code-line> <span class="hljs-number">0</span>\ = /<span class="hljs-number">0</span>
<code-line class="line-numbers-rows"></code-line> ___/<span class="hljs-string">'---'</span>\___
<code-line class="line-numbers-rows"></code-line> .<span class="hljs-string">' \\\\| |// '</span>.
<code-line class="line-numbers-rows"></code-line> / \\\\||| : <span class="hljs-type"></span>|||<span class="hljs-comment">// \\</span>
<code-line class="line-numbers-rows"></code-line> /<span class="hljs-literal">_</span> ||||| -:<span class="hljs-type">- </span>|||||- \\
<code-line class="line-numbers-rows"></code-line> | | \\\\\\ - <span class="hljs-comment">/// | |</span>
<code-line class="line-numbers-rows"></code-line> | \<span class="hljs-literal">_</span>| <span class="hljs-string">''</span>\---/<span class="hljs-string">''</span> |<span class="hljs-literal">_</span>/ |
<code-line class="line-numbers-rows"></code-line> \ .-\__ <span class="hljs-string">'-'</span> __/-. /
<code-line class="line-numbers-rows"></code-line> ___<span class="hljs-string">'. .'</span> /--.--\ <span class="hljs-string">'. .'</span>___
<code-line class="line-numbers-rows"></code-line> .<span class="hljs-string">""</span> <span class="hljs-string">'< '</span>.___\<span class="hljs-literal">_</span><|><span class="hljs-literal">_</span>/___.<span class="hljs-string">' >'</span> <span class="hljs-string">""</span>.
<code-line class="line-numbers-rows"></code-line> | | : <span class="hljs-type"></span>'- \<span class="hljs-string">'.;'</span>\ <span class="hljs-literal">_</span> /<span class="hljs-string">';.'</span>/ - <span class="hljs-string">' : | |
<code-line class="line-numbers-rows"></code-line> \ \ '</span><span class="hljs-literal">_</span>. \<span class="hljs-literal">_</span> __\ /__ <span class="hljs-literal">_</span>/ .-<span class="hljs-string">' / /
<code-line class="line-numbers-rows"></code-line> ====='</span>-.____<span class="hljs-string">'.___ \_____/___.-'</span>____.-<span class="hljs-string">'=====
<code-line class="line-numbers-rows"></code-line> '</span>=---=<span class="hljs-string">'
<code-line class="line-numbers-rows"></code-line>那么当你下次用户登录时就会显示一个佛祖图像了
<code-line class="line-numbers-rows"></code-line></span></pre></code-box>
<h4 id="tid-Rp4trW" tid="tid-Rp4trW">7./etc/issue.net(用户登录之前提示信息)<button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h4>
<p>即连接之后登录之前的提示信息</p>
<h2 id="usr目录下重要的数据文件" tid="tid-kMN745">usr目录下重要的数据文件<button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h2>
<p>/usr/local/ 用于保存用户安装软件程序信息 类似于win中的C:\Program Files (x86)</p>
<h3 id="linux安装软件的四种方式" tid="tid-y5HkGH">linux安装软件的四种方式<button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h3>
<ol>
<li>
<p>yum安装软件</p>
<p>yum安装的软件会将其依赖的软件一并下好,安装起来非常方便</p>
<code-box id="code-kAGGWH"><button boxid="code-kAGGWH" type="button" class="clipboard code-copay-btn hljs-comment" data-clipboard-action="copy" data-clipboard-target="#code-kAGGWH pre" aria-label="复制代码" style="opacity: 0; visibility: hidden;"><i class="iconfont icon-fuzhi1"></i></button><div class="code-tools" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(40, 44, 52);"><hljs-len class="code-hljs-len" style="visibility: visible;">mipsasm</hljs-len></div><pre boxid="code-kAGGWH" class="hljs mipsasm code-pre-line" style="white-space: pre;"><code-line class="line-numbers-rows"></code-line> yum <span class="hljs-keyword">install </span>-y tree vim <span class="hljs-keyword">bash-completion </span> 安装
<code-line class="line-numbers-rows"></code-line> yum reinstall -y tree vim <span class="hljs-keyword">bash-completion </span> 针对一些出问题的软件的重新安装</pre></code-box>
</li>
<li>
<p>rpm包方式安装软件</p>
<p>无法解决软件依赖问题,你叫它下啥它下啥:</p>
<code-box id="code-chmM4J"><button boxid="code-chmM4J" type="button" class="clipboard code-copay-btn hljs-comment" data-clipboard-action="copy" data-clipboard-target="#code-chmM4J pre" aria-label="复制代码" style="opacity: 0; visibility: hidden;"><i class="iconfont icon-fuzhi1"></i></button><div class="code-tools" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(40, 44, 52);"><hljs-len class="code-hljs-len" style="visibility: visible;">haml</hljs-len></div><pre boxid="code-chmM4J" class="hljs haml code-pre-line" style="white-space: pre;"><code-line class="line-numbers-rows"></code-line> rpm -ivh xxx.rpm
<code-line class="line-numbers-rows"></code-line> -<span class="ruby">i install 安装
<code-line class="line-numbers-rows"></code-line></span> -<span class="ruby">v verbose 显示详细信息
<code-line class="line-numbers-rows"></code-line></span> -<span class="ruby">h human 以⼈类更好看理解⽅式显示信息
<code-line class="line-numbers-rows"></code-line></span>
<code-line class="line-numbers-rows"></code-line> rpm -qa tree
<code-line class="line-numbers-rows"></code-line> -<span class="ruby">q query 查询
<code-line class="line-numbers-rows"></code-line></span> -<span class="ruby">a all 所有软件信息
<code-line class="line-numbers-rows"></code-line></span>
<code-line class="line-numbers-rows"></code-line> rpm -ql vim-enhanced
<code-line class="line-numbers-rows"></code-line> -<span class="ruby">l list 显示软件安装⽬录的列表信息
<code-line class="line-numbers-rows"></code-line></span>
<code-line class="line-numbers-rows"></code-line> rpm -e tree 卸载软件
<code-line class="line-numbers-rows"></code-line> -<span class="ruby">e erase 擦出==删除
<code-line class="line-numbers-rows"></code-line></span></pre></code-box>
</li>
<li>
<p>编译安装软件</p>
<p>安装软件更加灵活</p>
<p>类似于自定义安装,可以设置软件安装路径和指定软件功能信息等</p>
</li>
<li>
<p>二进制包安装软件</p>
<p>安装的软件拿来就可以直接运行,有点像可执行文件,小程序。</p>
</li>
</ol>
<h2 id="var目录下重要的数据文件" tid="tid-bw7kWK">var目录下重要的数据文件<button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h2>
<p>var目录存储一些经常发生变化的文件,主要就是log文件即日志文件</p>
<h4 id="varlogmessages" tid="tid-dp3CtE"><code>/var/log/messages</code><button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h4>
<p>服务运⾏情况信息、系统运⾏或异常信息</p>
<h4 id="varlogsecure" tid="tid-7K2X2D"><code>/var/log/secure</code><button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h4>
<p>用户登录信息保存文件,也会保存一些登录不成功的情况,我们可以检测这个文件出现的恶意登录状况做一些应对策略。</p>
<h4 id="规律的查看日志信息" tid="tid-F6mSkC">规律的查看日志信息<button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h4>
<ol>
<li>
<p>过滤工具grep</p>
<code-box id="code-FT7tcD"><button boxid="code-FT7tcD" type="button" class="clipboard code-copay-btn hljs-comment" data-clipboard-action="copy" data-clipboard-target="#code-FT7tcD pre" aria-label="复制代码" style="opacity: 0; visibility: hidden;"><i class="iconfont icon-fuzhi1"></i></button><div class="code-tools" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(40, 44, 52);"><hljs-len class="code-hljs-len" style="visibility: visible;">gradle</hljs-len></div><pre boxid="code-FT7tcD" class="hljs gradle code-pre-line" style="white-space: pre;"><code-line class="line-numbers-rows"></code-line>[..]# <span class="hljs-keyword">grep</span> <span class="hljs-string">"Failed"</span> <span class="hljs-regexp">/var/</span>log/secure ~ 过滤出日志文件中含Failed的行</pre></code-box>
</li>
<li>
<p>直接查看日志文件,可能会因为数据量过大而导致卡顿,所以必须要做切割处理</p>
<p>切割策略如下:</p>
<code-box id="code-cpterN"><button boxid="code-cpterN" type="button" class="clipboard code-copay-btn hljs-comment" data-clipboard-action="copy" data-clipboard-target="#code-cpterN pre" aria-label="复制代码" style="opacity: 0; visibility: hidden;"><i class="iconfont icon-fuzhi1"></i></button><div class="code-tools" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(40, 44, 52);"><hljs-len class="code-hljs-len" style="visibility: visible;">apache</hljs-len></div><pre boxid="code-cpterN" class="hljs apache code-pre-line" style="white-space: pre;"><code-line class="line-numbers-rows"></code-line> <span class="hljs-attribute">secure</span>-<span class="hljs-number">0</span>k > secure-<span class="hljs-number">100</span>k > ⼤⼩范围<span class="hljs-number">10</span>M > 切割secure bak<span class="hljs-number">01</span> secure
<code-line class="line-numbers-rows"></code-line> <span class="hljs-attribute">ls</span> -l /var/log/secure* # 查看默认切割策略 按天数切割</pre></code-box>
</li>
</ol>
<h2 id="proc目录重要的数据文件" tid="tid-TYbRQk">proc目录重要的数据文件<button class="cnblogs-toc-button" title="显示目录导航" aria-expanded="false"></button></h2>
<p>proc目录主要记录一些硬件的使用情况,对于真正的服务器而言,这是十分重要的一个文件夹,因为服务器的硬件参数是非常多的,而我们个人电脑上用虚拟机运行的linux系统占用的硬件就很少了</p>
<p>查看CPU信息的命令:<code>lscpu</code></p>
<code-box id="code-Fx3wf7"><button boxid="code-Fx3wf7" type="button" class="clipboard code-copay-btn hljs-comment" data-clipboard-action="copy" data-clipboard-target="#code-Fx3wf7 pre" aria-label="复制代码" style="opacity: 0; visibility: hidden;"><i class="iconfont icon-fuzhi1"></i></button><div class="code-tools" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(40, 44, 52);"><hljs-len class="code-hljs-len" style="visibility: visible;">reasonml</hljs-len></div><pre boxid="code-Fx3wf7" class="hljs reasonml code-pre-line" style="white-space: pre;"><code-line class="line-numbers-rows"></code-line> <span class="hljs-constructor">CPU(<span class="hljs-params">s</span>)</span>: <span class="hljs-number">4</span> 整个服务器有多少核⼼
<code-line class="line-numbers-rows"></code-line> <span class="hljs-constructor">Core(<span class="hljs-params">s</span>)</span> per socket: <span class="hljs-number">2</span> 每颗CPU有多少核⼼
<code-line class="line-numbers-rows"></code-line> <span class="hljs-constructor">Socket(<span class="hljs-params">s</span>)</span>: <span class="hljs-number">2</span> 服务器有⼏颗CPU</pre></code-box>
<p>查看内存信息的命令:<code>cat /proc/meminfo</code></p>
<code-box id="code-zFSjb6"><button boxid="code-zFSjb6" type="button" class="clipboard code-copay-btn hljs-comment" data-clipboard-action="copy" data-clipboard-target="#code-zFSjb6 pre" aria-label="复制代码" style="opacity: 0; visibility: hidden;"><i class="iconfont icon-fuzhi1"></i></button><div class="code-tools" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(40, 44, 52);"><hljs-len class="code-hljs-len" style="visibility: visible;">pgsql</hljs-len></div><pre boxid="code-zFSjb6" class="hljs pgsql code-pre-line" style="white-space: pre;"><code-line class="line-numbers-rows"></code-line> MemTotal: <span class="hljs-number">2030172</span> kB <span class="hljs-comment">--- 服务器的总共内存容量</span>
<code-line class="line-numbers-rows"></code-line> MemFree: <span class="hljs-number">1755372</span> kB <span class="hljs-comment">--- 服务器未使⽤的内存容量</span>
<code-line class="line-numbers-rows"></code-line> MemAvailable: <span class="hljs-number">1728900</span> kB <span class="hljs-comment">--- 服务器还可以使⽤的容量</span>
<code-line class="line-numbers-rows"></code-line> <span class="hljs-keyword">Buffers</span>: <span class="hljs-number">2076</span> kB <span class="hljs-comment">--- 缓冲</span>
<code-line class="line-numbers-rows"></code-line> Cached: <span class="hljs-number">86716</span> kB <span class="hljs-comment">--- 缓存</span></pre></code-box>
<p>实时使用情况:<code>free</code> <code>free -h</code></p>
<p>查看磁盘\挂载信息:<code>df -h</code>(命令) <code>cat /proc/mounts</code>(文件记录)</p>
<p>查看负载情况:<code>cat /proc/loadavg</code>(文件记录) <code>w</code>(命令)</p>
<code-box id="code-BKknFN"><button boxid="code-BKknFN" type="button" class="clipboard code-copay-btn hljs-comment" data-clipboard-action="copy" data-clipboard-target="#code-BKknFN pre" aria-label="复制代码" style="opacity: 0; visibility: hidden;"><i class="iconfont icon-fuzhi1"></i></button><div class="code-tools" style="background: none 0% 0% / auto repeat scroll padding-box border-box rgb(40, 44, 52);"><hljs-len class="code-hljs-len" style="visibility: visible;">livecodeserver</hljs-len></div><pre boxid="code-BKknFN" class="hljs livecodeserver code-pre-line" style="white-space: pre;"><code-line class="line-numbers-rows"></code-line><span class="hljs-number">15</span>:<span class="hljs-number">39</span>:<span class="hljs-number">53</span> up <span class="hljs-number">43</span> <span class="hljs-built_in">min</span>, <span class="hljs-number">2</span> users, <span class="hljs-built_in">load</span> <span class="hljs-built_in">average</span>: <span class="hljs-number">0.00</span>, <span class="hljs-number">0.01</span>, <span class="hljs-number">0.03</span>
<code-line class="line-numbers-rows"></code-line>当前时间 服务器运行时间 连接用户数 平均负载情况</pre></code-box>
<div> <nav id="articleDirectory" style="top: 138px; right: 61px; width: 260px;" class="articleDirectoryFixed"> <ul class="nav nav-pills"> <li class="nav-item articleDirectory-overflow"><a class="nav-link articleDirectory-overflow" href="#linnux系统常见目录及文件" goto="tid-WwZEp6" onclick="return false;">linnux系统常见目录及文件</a></li><li class="nav-item articleDirectory-overflow"><a class="nav-link articleDirectory-overflow" href="#linux目录结构" goto="tid-nJRCbQ" onclick="return false;"> linux目录结构</a></li><li class="nav-item articleDirectory-overflow"><a class="nav-link articleDirectory-overflow" href="#常见目录" goto="tid-5TnXFd" onclick="return false;"> 常见目录</a></li><li class="nav-item articleDirectory-overflow"><a class="nav-link articleDirectory-overflow active" href="#目录结构说明" goto="tid-7C2rha" onclick="return false;"> 目录结构说明</a></li><li class="nav-item articleDirectory-overflow"><a class="nav-link articleDirectory-overflow" href="#etc目录下重要的数据文件" goto="tid-t7wNh3" onclick="return false;"> etc目录下重要的数据文件</a></li><li class="nav-item articleDirectory-overflow"><a class="nav-link articleDirectory-overflow" href="#tid-XtsPai" goto="tid-XtsPai" onclick="return false;"> 1./etc/fstab (filesystem table 系统挂载信息表)</a></li><li class="nav-item articleDirectory-overflow"><a class="nav-link articleDirectory-overflow" href="#tid-Ftamz2" goto="tid-Ftamz2" onclick="return false;"> 2./etc/rc.local (此文件中只能存放linux系统命令操作信息)</a></li><li class="nav-item articleDirectory-overflow"><a class="nav-link articleDirectory-overflow" href="#tid-KPKxw6" goto="tid-KPKxw6" onclick="return false;"> 3./etc/inittab (系统启动运行级别配置文件)</a></li><li class="nav-item articleDirectory-overflow"><a class="nav-link articleDirectory-overflow" href="#tid-Ds6APK" goto="tid-Ds6APK" onclick="return false;"> 4./etc/profile (配置环境变量信息或者别名信息⽂件)</a></li><li class="nav-item articleDirectory-overflow"><a class="nav-link articleDirectory-overflow" href="#tid-Y24TGC" goto="tid-Y24TGC" onclick="return false;"> 5./etc/bashrc (设置别名信息)</a></li><li class="nav-item articleDirectory-overflow"><a class="nav-link articleDirectory-overflow" href="#tid-dmzGTB" goto="tid-dmzGTB" onclick="return false;"> 6./etc/motd(用户登录之后的提示信息)</a></li><li class="nav-item articleDirectory-overflow"><a class="nav-link articleDirectory-overflow" href="#tid-Rp4trW" goto="tid-Rp4trW" onclick="return false;"> 7./etc/issue.net(用户登录之前提示信息)</a></li><li class="nav-item articleDirectory-overflow"><a class="nav-link articleDirectory-overflow" href="#usr目录下重要的数据文件" goto="tid-kMN745" onclick="return false;"> usr目录下重要的数据文件</a></li><li class="nav-item articleDirectory-overflow"><a class="nav-link articleDirectory-overflow" href="#linux安装软件的四种方式" goto="tid-y5HkGH" onclick="return false;"> linux安装软件的四种方式</a></li><li class="nav-item articleDirectory-overflow"><a class="nav-link articleDirectory-overflow" href="#var目录下重要的数据文件" goto="tid-bw7kWK" onclick="return false;"> var目录下重要的数据文件</a></li><li class="nav-item articleDirectory-overflow"><a class="nav-link articleDirectory-overflow" href="#varlogmessages" goto="tid-dp3CtE" onclick="return false;"> /var/log/messages</a></li><li class="nav-item articleDirectory-overflow"><a class="nav-link articleDirectory-overflow" href="#varlogsecure" goto="tid-7K2X2D" onclick="return false;"> /var/log/secure</a></li><li class="nav-item articleDirectory-overflow"><a class="nav-link articleDirectory-overflow" href="#规律的查看日志信息" goto="tid-F6mSkC" onclick="return false;"> 规律的查看日志信息</a></li><li class="nav-item articleDirectory-overflow"><a class="nav-link articleDirectory-overflow" href="#proc目录重要的数据文件" goto="tid-TYbRQk" onclick="return false;"> proc目录重要的数据文件</a></li> </ul> </nav> </div><span class="articleSuffix-flg"> <br><p class="essaySuffix-eof">__EOF__</p> <div id="articleSuffix"> <div class="articleSuffix-bg"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 147.78 155.96"> <path d="M10.5,99.81a1.9,1.9,0,0,0-.53-.09,1.66,1.66,0,0,0-1.64,1.65A1.64,1.64,0,0,0,10,103a1.57,1.57,0,0,0,.87-.25l26.76,26.82.45-1.08L11.52,101.91A1.65,1.65,0,0,0,10.5,99.81Zm-.13,2a.57.57,0,0,1-.8,0,.58.58,0,0,1-.17-.41.58.58,0,0,1,.57-.57h0a.57.57,0,0,1,.56.58A.55.55,0,0,1,10.37,101.77Z" style="fill:#c5c9e0"></path><path d="M56.15,117.58H39.06l0-.09a1.65,1.65,0,0,0-1.36-1H37.5a1.65,1.65,0,1,0,1.56,2.19H55.7L92.92,156h41.44v-1.08h-41Zm-18.25.94a.56.56,0,0,1-.79,0,.58.58,0,0,1-.17-.41.57.57,0,0,1,.56-.57h0a.58.58,0,0,1,.57.58A.54.54,0,0,1,37.9,118.52Z" style="fill:#c5c9e0"></path><path d="M23.52,50.32a1.65,1.65,0,0,0,1.55-1.11H55.28l48-48.13h31.06V0H102.85l-48,48.13H25.07a1.64,1.64,0,0,0-2.09-1,1.64,1.64,0,0,0,.54,3.2Zm0-2.21a.57.57,0,0,1,0,1.13.57.57,0,1,1,0-1.13Z" style="fill:#c5c9e0"></path><polygon points="102.86 0 102.86 0 102.86 0 102.86 0" style="fill:#c5c9e0"></polygon><path d="M107.72,12.14h26.64V11.07H107.27L57.4,61H3.09a1.66,1.66,0,0,0-1.45-.86H1.52A1.65,1.65,0,1,0,2.81,63a1.59,1.59,0,0,0,.45-.87H57.85ZM2.05,62.23a.57.57,0,0,1-.8,0,.58.58,0,0,1-.17-.41.57.57,0,0,1,.56-.57h.09a.57.57,0,0,1,.32,1Z" style="fill:#c5c9e0"></path><path d="M134.36,43.22V42.14h-22.3l-9.62,9.63a1.64,1.64,0,0,0-2.19.77,1.61,1.61,0,0,0-.17.71,1.65,1.65,0,1,0,3.29,0,1.61,1.61,0,0,0-.16-.72l9.3-9.32Zm-32.64,10.6a.57.57,0,0,1,0-1.13.57.57,0,0,1,0,1.13Z" style="fill:#c5c9e0"></path><path d="M147,52.3l-9,9H111.48a1.64,1.64,0,0,0-1.61-1.33h-.14a1.65,1.65,0,1,0,1.6,2.41h27.19l9.26-9.29L147,52.3Zm-37.15,9.85a.56.56,0,0,1-.56-.57h0a.56.56,0,0,1,.56-.56h0a.57.57,0,1,1,0,1.13Z" style="fill:#c5c9e0"></path><path d="M66.79,75.35l11,11.06h56.53V85.33H78.27l-11-11.06H49.49L37.12,86.67a1.64,1.64,0,0,0-2.09,1,1.61,1.61,0,0,0-.09.54,1.65,1.65,0,0,0,3.29,0,1.68,1.68,0,0,0-.26-.89l12-12ZM36.58,88.79a.57.57,0,1,1,.57-.56A.57.57,0,0,1,36.58,88.79Z" style="fill:#c5c9e0"></path><path d="M110.61,95.55,92.8,113.4a1.62,1.62,0,1,0,.77.76l17.49-17.53h23.31V95.55ZM92.49,115.28a.56.56,0,0,1-.8,0,.58.58,0,0,1-.17-.41.57.57,0,0,1,.57-.57h0a.58.58,0,0,1,.56.58A.55.55,0,0,1,92.49,115.28Z" style="fill:#c5c9e0"></path><path d="M97.89,122.3H76.62L64.2,109.85a1.65,1.65,0,0,0-.77-2.2,1.77,1.77,0,0,0-.72-.17h-.14a1.65,1.65,0,0,0,.15,3.29,1.58,1.58,0,0,0,.71-.17l12.74,12.77H98.34l17.48-17.52h18.54v-1.08h-19ZM63.12,109.53a.56.56,0,0,1-.8,0,.58.58,0,0,1-.17-.41.57.57,0,0,1,1.14,0A.54.54,0,0,1,63.12,109.53Z" style="fill:#c5c9e0"></path> </svg> </div> <div class="articleSuffix-left"> <a data-fancybox="gallery" href="/i/l/?n=22&i=blog/2987404/202210/2987404-20221004101226772-1318373983.jpg"><img src="/i/l/?n=22&i=blog/2987404/202210/2987404-20221004101226772-1318373983.jpg"></a> </div> <div class="articleSuffix-right"> <item> <li> <b>本文作者:</b> <a href="https://www.cnblogs.com/Leethon-lizhilog" target="_blank">Leethon</a> </li> <li> <b>本文链接:</b> <a href="https://www.cnblogs.com/Leethon-lizhilog/p/17044129.html" target="_blank">https://www.cnblogs.com/Leethon-lizhilog/p/17044129.html</a> </li> <li> <b>关于博主:</b> 评论和私信会在第一时间回复。或者<a href="https://msg.cnblogs.com/msg/send/Leethon-lizhilog" target="_blank">直接私信</a>我。 </li> <li> <b>版权声明:</b> 本博客所有文章除特别声明外,均采用 <a href="https://creativecommons.org/licenses/by-nc-nd/4.0/" alt="BY-NC-SA" title="BY-NC-SA" target="_blank">BY-NC-SA</a> 许可协议。转载请注明出处! </li> <li> <b>声援博主:</b> 如果您觉得文章对您有帮助,可以点击文章右下角<strong><span style="color: #ff0000; font-size: 12pt;">【<a id="post-up" onclick="votePost(17044129,'Digg')" href="javascript:void(0);">推荐</a>】</span></strong>一下。 </li> </item> </div> <div style="clear:both"></div> </div> </span></div>
标签:文件,基础,day3,信息,---,etc,nbsp,Linux,root From: https://www.cnblogs.com/wznn125ml/p/17060938.html