yum命令安装软件教程(使用yum安装软件的命令)

yum命令安装软件教程(使用yum安装软件的命令)Lin ux nbsp 红帽认证 nbsp IT 技术 nbsp 运维工程师 1000 人技术交流 nbsp 备注 公众号 更快通过 一 Linux 软件包管理器 yum 在 Linux 中常见的软件安装方式有 yum apt rpm 安装包安装 源码安装 其中 centos 默认是用 yum ubuntu 默认是用 apt 1 什么是软件包

大家好,我是讯享网,很高兴认识大家。



Lin ux | 红帽认证 | IT技术 | 运维工程师

👇1000人技术交流 备注【公众号】更快通过


讯享网

一,Linux 软件包管理器 yum

在Linux中常见的软件安装方式有:yum/apt,rpm安装包安装,源码安装。其中,centos默认是用yum,ubuntu默认是用apt。

1. 什么是软件包

在Linux下安装软件,一个通常的办法是下载到程序的源代码,并进行编译, 得到可执行程序。

但是这样太麻烦了, 于是有些人把一些常用的软件提前编译好, 做成软件包(可以理解成windows上的安装程序)放在一个服务器上, 通过包管理器可以很方便的获取到这个编译好的软件包, 直接进行安装。

软件包和软件包管理器, 就好比 “App” 和 “应用商店” 这样的关系。

yum(Yellow dog Updater, Modified)是Linux下非常常用的一种包管理器。主要应用在Fedora,RedHat,Centos等发行版上。

讯享网

2. 如何安装软件

通过 yum,我们可以通过很简单的一条命令完成 gcc 的安装。

讯享网sudo yum install -y lrzsz

(1) yum 会自动找到都有哪些软件包需要下载。

(2) -y 可以避免在下载安装过程中每次询问我们是否安装。

(3) lrzsz这个工具用于windows机器和远端的 Linux 机器通过 XShell 传输文件,安装完毕之后可以通过拖拽的方式将文件上传过去。

注意事项:

1、安装软件时由于需要向系统目录中写入内容, 一般需要 sudo 或者切到 root 账户下才能完成。2、yum安装软件只能一个装完了再装另一个。正在yum安装一个软件的过程中, 如果再尝试用yum安装另外一个软件, yum会报错。3、如果 yum 报错, 请自行百度。

3. 如何卸载软件

仍然是一条命令:

讯享网sudo yum remove lrzsz

二,Linux编辑器-vim使用

1. vim的基本概念

vim是一个多模式的编辑器。我们目前使用vim能接触到的有五种模式:命令/正常/普通模式,插入模式,底行模式,visual block模式。但是重点掌握前三种模式。

1.1 命令/正常/普通模式

控制屏幕光标的移动,字符、字或行的删除,移动复制某区段及进入插入模式下,或者到底行模式。

1.2 插入模式

讯享网只有在插入模式下,才可以做文字输入,按「Esc」键可回到命令行模式。该模式是我们后面用的最频繁的编辑模式。

1.3 底行模式

文件保存或退出,也可以进行文件替换,找字符串,列出行号等操作。在命令模式下,shift+: 即可进入该模式。要查看你的所有模式:打开vim,底行模式直接输入 :help vim-modes

五种模式的切换如下图:

(1) 进入vim,在系统提示符号输入vim及文件名称后,就进入vim全屏幕编辑画面:

讯享网\(</span> vim test.c</span></code></pre></section><p style="margin-left: 8px;margin-right: 8px;line-height: 1.75em;"><span style="font-size: 15px;letter-spacing: 1px;">不过有一点要特别注意,就是你进入vim之后,是处于[正常模式],你要切换到[插入模式]才能够输入文字。</span><br /></p><p style="margin-left: 8px;margin-right: 8px;line-height: 1.75em;"><span style="font-size: 15px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 1px;">(2) [正常模式]切换至[插入模式]</span></p><section class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"><li></li><li></li><li></li></ul><pre class="code-snippet__js"><code><span class="code-snippet_outer">输入a:是从光标当前位置开始输入文字。</span></code><code><span class="code-snippet_outer">输入i:光标所在位置的下一个位置开始输入文字。</span></code><code><span class="code-snippet_outer">输入o:是插入新的一行,从行首开始输入文字。</span></code></pre></section><p style="margin-left: 8px;margin-right: 8px;line-height: 1.75em;"><span style="font-size: 15px;letter-spacing: 1px;">(3) [插入模式]切换至[正常模式]</span><span style="font-size: 15px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 1px;"></span></p><p style="margin-left: 8px;margin-right: 8px;line-height: 1.75em;"><span style="font-size: 15px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 1px;">目前处于[插入模式],就只能一直输入文字,如果发现输错了字,想用光标键往回移动,将该字删除,可以先按一下「ESC」键转到[正常模式]再删除文字。当然,也可以直接删除。</span></p><p style="margin-left: 8px;margin-right: 8px;line-height: 1.75em;"><span style="font-size: 15px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 1px;">(4) [正常模式]切换至[底行模式]</span></p><section class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"><li></li></ul><pre class="code-snippet__js" data-lang="bash"><code><span class="code-snippet_outer">「<span class="code-snippet__built_in">shift</span> + ;」, 其实就是输入「:」</span></code></pre></section><p style="margin-left: 8px;margin-right: 8px;line-height: 1.75em;"><span style="font-size: 15px;letter-spacing: 1px;">(5) 退出vim及保存文件,在[正常模式]下,按一下「:」冒号键进入「底行模式」,例如:</span></p><section class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"><li></li><li></li><li></li></ul><pre class="code-snippet__js" data-lang="perl"><code><span class="code-snippet_outer">: w (保存当前文件)</span></code><code><span class="code-snippet_outer">: w<span class="code-snippet__string">q (输入「wq」,存盘并退出vim)</span></span></code><code><span class="code-snippet_outer">: <span class="code-snippet__keyword">q</span>! (输入<span class="code-snippet__keyword">q</span>!,不存盘强制退出vim)</span></code></pre></section><p style="margin-left: 8px;margin-right: 8px;line-height: 1.75em;"><span style="font-size: 15px;letter-spacing: 1px;">所以,在任何模式下想要回命令模式,直接无脑 [Esc]。</span><span style="font-size: 15px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 1px;"></span></p><p style="margin-left: 8px;margin-right: 8px;line-height: 1.75em;"><span style="color: rgb(0, 82, 255);"><strong><span style="color: rgb(0, 82, 255);font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 1px;font-size: 18px;">三,vim命令模式命令集</span></strong></span></p><p style="margin-left: 8px;margin-right: 8px;line-height: 1.75em;"><span style="color: rgb(0, 82, 255);"><strong><span style="color: rgb(0, 82, 255);font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 1px;font-size: 16px;">1. 移动光标</span></strong></span></p><p style="margin-left: 8px;margin-right: 8px;line-height: 1.75em;"><span style="font-size: 15px;font-family: mp-quote, -apple-system-font, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 1px;">vim可以直接用键盘上的按键来上下左右移动,但正规的vim是用小写英文字母 [h],[j],[k],[l],分别控制光标左,下,上,右移一格</span></p><section class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul><pre class="code-snippet__js" data-lang="cs"><code><span class="code-snippet_outer">[<span class="code-snippet__meta">shift+g = G</span>]:定位到文本的末尾</span></code><code><span class="code-snippet_outer">[<span class="code-snippet__meta">n+shift+g</span>]:定位到文本的第n行</span></code><code><span class="code-snippet_outer">[<span class="code-snippet__meta">gg</span>]:定位到文本的最开始</span></code><code><span class="code-snippet_outer">[<span class="code-snippet__meta">\)]:移动到光标所在行的“行尾”-[ ^]:移动到光标所在行的“行首”[w]:以单词为单位,向后跳[e] :以单词为单位,向前跳[ctrl + b]:屏幕往“后”移动一页[ctrl + f] :屏幕往“前”移动一页

2. 删除字符

[x]:每按一次,删除光标所在位置的一个字符[n+x]:删除n个字符。例如,[6x]表示删除光标所在位置的”后面(包含自己在内)”6个字符[dd]:删除光标所在行[n+dd]:从光标所在行开始删除n[X]:大写的X,每按一次,删除光标所在位置的“前面”一个字符[n+X]:例如,[20X]表示删除光标所在位置的“前面”20个字符

3. 复制

讯享网[yy]:复制光标所在行到缓冲区[n+yy]:复制n行。例如,「6yy」表示拷贝从光标所在的该行“往下数”6行文字。[p]:将缓冲区内的字符贴到光标所在位置。注意:所有与“y”有关的复制命令都必须与“p”配合才能完成复制与粘贴功能。[yw]:将光标所在之处到字尾的字符复制到缓冲区中。[n+yw]:复制n个字到缓冲区

4. 替换

[r]:替换光标所在处的字符。[R]:批量替换。替换光标所到之处的字符,直到按下[ESC]键为止。

5. 撤销上一次操作

讯享网[u]:如果您误执行一个命令,可以马上按下[u],回到上一个操作。按多次“u”可以执行多次回复。[ctrl + r] :撤销的恢复

6. 注释和去注释

注释:ctrl+v –&gt; hjkl(光标定位) –&gt;shift+i –&gt; //(双斜杠) –&gt; Esc去注释:ctrl+v –&gt; hjkl –&gt; d

7. 跳至指定的行

讯享网[ctrl + g]:列出光标所在行的行号。[n+G]:例如,[15G],表示移动光标至文章的第15行行首。

8. 更改

[cw]:更改光标所在处的字到字尾处[c+n+w]:例如,[c3w]表示更改3个字

四,vim底行模式命令集

在使用底行模式之前,请记住先按[ESC]键确定您已经处于命令模式,再按[:]冒号即可进入底行模式。

1. 列出行号

讯享网[set nu/set nonu]:设置/取消行号。

2. 查找字符

[ / + 关键字]:先按 [/] 键,再输入您想寻找的字符,如果第一次找的关键字不是您想要的,可以==一直按 [n]==会往后寻找到您要的关键字为止。[? + 关键字]:先按 [?] 键,再输入您想寻找的字符,如果第一次找的关键字不是您想要的,可以一直按 [n] 会往前寻找到您要的关键字为止。

3. 保存文件

讯享网[w]:在冒号后输入字母[w]就可以将文件保存起来

4. 离开vim

[q]:按[q]就是退出,如果无法离开vim,可以在[q]后跟一个 [!] 强制离开vim[wq]:一般建议离开时,搭配 [w] 一起使用,这样在退出的时候还可以保存文件。[!ls][!ll][!pwd]:直接跳回目录并执行该命令。

5. 不退出vim,对代码进行编译执行

讯享网!gcc code.c -o hello.txt! https://mp.weixin..com/hello.txt

6. 分屏

[vs + 文件名]:在vim中分屏打开指定文件。看光标判断字在哪个文件里。[ctrl + ww]:分屏时光标跳到另一个屏幕

课程咨询添加:HCIE666CCIE

↑或者扫描上方二维码↑


你有什么想看的技术点和内容

可以在下方留言告诉小盟哦!

小讯
上一篇 2025-05-23 07:05
下一篇 2025-04-13 22:30

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/141073.html