Skip to content

Commit a748707

Browse files
committed
更新了文档和资源
1 parent fb7baa2 commit a748707

File tree

2 files changed

+70
-15
lines changed

2 files changed

+70
-15
lines changed

Day31-35/res/vim-diff.png

78.5 KB
Loading

Day31-35/玩转Linux操作系统.md

+70-15
Original file line numberDiff line numberDiff line change
@@ -413,27 +413,27 @@ Linux系统的命令通常都是如下所示的格式:
413413
414414
```Shell
415415
416-
[root@iZwz97tbgo9lkabnat2lo8Z ~]# cat 1.txt
416+
[root@iZwz97tbgo9lkabnat2lo8Z ~]# cat foo.txt
417417
grape
418418
apple
419419
pitaya
420-
[root@iZwz97tbgo9lkabnat2lo8Z ~]# cat 2.txt
420+
[root@iZwz97tbgo9lkabnat2lo8Z ~]# cat bar.txt
421421
100
422422
200
423423
300
424424
400
425-
[root@iZwz97tbgo9lkabnat2lo8Z ~]# paste 1.txt 2.txt
425+
[root@iZwz97tbgo9lkabnat2lo8Z ~]# paste foo.txt bar.txt
426426
grape 100
427427
apple 200
428428
pitaya 300
429429
400
430-
[root@iZwz97tbgo9lkabnat2lo8Z ~]# paste 1.txt 2.txt > 3.txt
431-
[root@iZwz97tbgo9lkabnat2lo8Z ~]# cut -b 4-8 3.txt
430+
[root@iZwz97tbgo9lkabnat2lo8Z ~]# paste foo.txt bar.txt > hello.txt
431+
[root@iZwz97tbgo9lkabnat2lo8Z ~]# cut -b 4-8 hello.txt
432432
pe 10
433433
le 20
434434
aya 3
435435
0
436-
[root@iZwz97tbgo9lkabnat2lo8Z ~]# cat 3.txt | tr '\t' ','
436+
[root@iZwz97tbgo9lkabnat2lo8Z ~]# cat hello.txt | tr '\t' ','
437437
grape,100
438438
apple,200
439439
pitaya,300
@@ -662,16 +662,16 @@ Linux系统的命令通常都是如下所示的格式:
662662
663663
### 编辑器vim
664664
665-
1. 启动vim。
665+
1. 启动vim。可以通过`vi`或`vim`命令来启动vim,启动时可以指定文件名来打开一个文件,如果没有指定文件名,也可以在保存的时候指定文件名。
666666
667667
```Shell
668668
669669
[root@iZwz97tbgo9lkabnat2lo8Z ~]# vim guess.py
670670
```
671671
672-
2. 命令模式、编辑模式和末行模式:启动vim进入的是命令模式,在命令模式下输入英文字母`i`会进入编辑模式,屏幕下方出现`-- INSERT --`提示;在编辑模式下按下`Esc`会回到命令模式,此时如果输入英文`:`会进入末行模式,在末行模式下输入`q!`可以在不保存当前工作的情况下强行退出vim,如果希望执行保存退出,则应该在末行模式下输入`wq`
672+
2. 命令模式、编辑模式和末行模式:启动vim进入的是命令模式(也称为Normal模式),在命令模式下输入英文字母`i`会进入编辑模式(Insert模式),屏幕下方出现`-- INSERT --`提示;在编辑模式下按下`Esc`会回到命令模式,此时如果输入英文`:`会进入末行模式,在末行模式下输入`q!`可以在不保存当前工作的情况下强行退出vim;在命令模式下输入`v`会进入可视模式(Visual模式),可以用光标选择一个区域再完成对应的操作
673673
674-
3. 退出vim:在命令模式下输入`:` 进入末行模式,输入wq可以实现保存退出;如果想放弃编辑的内容输入`q!`强行退出,这一点刚才已经提到过了;在命令模式下也可以直接输入`ZZ`实现保存退出。
674+
3. 保存和退出vim:在命令模式下输入`:` 进入末行模式,输入`wq`可以实现保存退出;如果想放弃编辑的内容输入`q!`强行退出,这一点刚才已经提到过了;在命令模式下也可以直接输入`ZZ`实现保存退出。如果只想保存文件不退出,那么可以在末行模式下输入`w`;可以在`w`后面输入空格再指定要保存的文件名
675675
676676
4. 光标操作。
677677
@@ -715,17 +715,18 @@ Linux系统的命令通常都是如下所示的格式:
715715
716716
```Shell
717717
718-
[root@iZwz97tbgo9lkabnat2lo8Z ~]# vim -d 1.txt 2.txt 3.txt
718+
[root@iZwz97tbgo9lkabnat2lo8Z ~]# vim -d foo.txt bar.txt
719719
```
720+
![](./res/vim-diff.png)
720721
721722
- 打开多个文件。
722723
723724
```Shell
724725
725-
[root@iZwz97tbgo9lkabnat2lo8Z ~]# vim 1.txt 2.txt 3.txt
726+
[root@iZwz97tbgo9lkabnat2lo8Z ~]# vim foo.txt bar.txt hello.txt
726727
```
727728
728-
启动vim后只有一个窗口显示的是1.txt,可以在末行模式中输入`ls`查看到打开的三个文件,也可以在末行模式中输入`b <num>`来显示另一个文件,例如可以用`:b 2`来显示2.txt
729+
启动vim后只有一个窗口显示的是foo.txt,可以在末行模式中输入`ls`查看到打开的三个文件,也可以在末行模式中输入`b <num>`来显示另一个文件,例如可以用`:b 2`将bar.txt显示出来,可以用`:b 3`将hello.txt显示出来
729730
730731
- 拆分和切换窗口。
731732
@@ -742,7 +743,7 @@ Linux系统的命令通常都是如下所示的格式:
742743
743744
`:inoremap __main if __name__ == '__main__':`
744745
745-
> 说明:如果希望映射的快捷键每次启动vim时都能生效,需要将映射写到用户主目录下的.vimrc文件中。
746+
> 说明:上面例子2的`inoremap`中的`i`表示映射的键在编辑模式使用, `nore`表示不要递归,这一点非常重要,否则如果键对应的内容中又出现键本身,就会引发递归(相当于进入了死循环)。如果希望映射的快捷键每次启动vim时都能生效,需要将映射写到用户主目录下的.vimrc文件中。
746747
747748
- 录制宏。
748749
@@ -800,15 +801,59 @@ Dependency Installed:
800801
nginx-mod-mail.x86_64 1:1.12.2-2.el7
801802
nginx-mod-stream.x86_64 1:1.12.2-2.el7
802803
Complete!
804+
[root@iZwz97tbgo9lkabnat2lo8Z ~]# yum info nginx
805+
Loaded plugins: fastestmirror
806+
Loading mirror speeds from cached hostfile
807+
Installed Packages
808+
Name : nginx
809+
Arch : x86_64
810+
Epoch : 1
811+
Version : 1.12.2
812+
Release : 2.el7
813+
Size : 1.5 M
814+
Repo : installed
815+
From repo : epel
816+
Summary : A high performance web server and reverse proxy server
817+
URL : http://nginx.org/
818+
License : BSD
819+
Description : Nginx is a web server and a reverse proxy server for HTTP, SMTP, POP3 and
820+
: IMAP protocols, with a strong focus on high concurrency, performance and low
821+
: memory usage.
803822
[root@iZwz97tbgo9lkabnat2lo8Z ~]# nginx -v
804823
nginx version: nginx/1.12.2
805824
```
806825
807-
下面以MySQL为例,演示如何使用rpm安装软件。
826+
下面以MySQL为例,演示如何使用rpm安装软件。要安装MySQL需要先到[MySQL官方网站](https://www.mysql.com/)下载对应的[RPM文件](https://dev.mysql.com/downloads/mysql/),当然要选择和你使用的Linux系统对应的版本。MySQL现在是Oracle公司旗下的产品,在MySQL被收购后,MySQL的作者重新制作了一个MySQL的分支MariaDB,可以通过yum进行安装。如果要安装MySQL需要先通过yum删除`mariadb-libs`这个可能会跟MySQL底层库冲突的库,然后还需要安装一个名为`libaio`的依赖库。
808827
809828
```Shell
810829
811-
830+
[root@iZwz97tbgo9lkabnat2lo8Z mysql]# ls
831+
mysql-community-client-5.7.22-1.el7.x86_64.rpm
832+
mysql-community-common-5.7.22-1.el7.x86_64.rpm
833+
mysql-community-libs-5.7.22-1.el7.x86_64.rpm
834+
mysql-community-server-5.7.22-1.el7.x86_64.rpm
835+
[root@iZwz97tbgo9lkabnat2lo8Z mysql]# yum -y remove mariadb-libs
836+
[root@iZwz97tbgo9lkabnat2lo8Z mysql]# yum -y install libaio
837+
[root@iZwz97tbgo9lkabnat2lo8Z mysql]# rpm -ivh mysql-community-common-5.7.22-1.el7.x86_64.rpm
838+
warning: mysql-community-common-5.7.22-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
839+
Preparing... ################################# [100%]
840+
package mysql-community-common-5.7.22-1.el7.x86_64 is already installed
841+
[root@iZwz97tbgo9lkabnat2lo8Z mysql]# rpm -ivh mysql-community-libs-5.7.22-1.el7.x86_64.rpm
842+
warning: mysql-community-libs-5.7.22-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
843+
Preparing... ################################# [100%]
844+
package mysql-community-libs-5.7.22-1.el7.x86_64 is already installed
845+
[root@iZwz97tbgo9lkabnat2lo8Z mysql]# rpm -ivh mysql-community-client-5.7.22-1.el7.x86_64.rpm
846+
warning: mysql-community-client-5.7.22-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
847+
Preparing... ################################# [100%]
848+
package mysql-community-client-5.7.22-1.el7.x86_64 is already installed
849+
[root@iZwz97tbgo9lkabnat2lo8Z mysql]# rpm -ivh mysql-community-server-5.7.22-1.el7.x86_64.rpm
850+
warning: mysql-community-server-5.7.22-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
851+
Preparing... ################################# [100%]
852+
package mysql-community-server-5.7.22-1.el7.x86_64 is already installed
853+
[root@iZwz97tbgo9lkabnat2lo8Z mysql]# mysqld --version
854+
mysqld Ver 5.7.22 for Linux on x86_64 (MySQL Community Server (GPL))
855+
[root@iZwz97tbgo9lkabnat2lo8Z mysql]# mysql --version
856+
mysql Ver 14.14 Distrib 5.7.22, for Linux (x86_64) using EditLine wrapper
812857
```
813858
814859
#### 下载解压配置环境变量
@@ -858,6 +903,16 @@ git version: a20ecd3e3a174162052ff99913bc2ca9a839d618
858903
OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
859904
allocator: tcmalloc
860905
modules: none
906+
build environment:
907+
distmod: rhel70
908+
distarch: x86_64
909+
target_arch: x86_64
910+
[root@iZwz97tbgo9lkabnat2lo8Z ~]# mongo --version
911+
MongoDB shell version v3.6.5
912+
git version: a20ecd3e3a174162052ff99913bc2ca9a839d618
913+
OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
914+
allocator: tcmalloc
915+
modules: none
861916
build environment:
862917
distmod: rhel70
863918
distarch: x86_64

0 commit comments

Comments
 (0)