Vi/Vim编辑器
在Linux下一切皆文件,Vi编辑器和Vim编辑器是可以直接对文本文件进行编辑和操作,没什么大区别,vim有颜色区分更美观,vim 文件路径+文件名即可进入一般模式,一般模式就是只读文件,不可进行操作。
Vim编辑器的三种模式

vim点击进入文件
i 点击i进入编辑模式
esc 退出编辑模式
:w 保存更改的内容需要进入命令模式,点击: 然后点击w,写入
u 不想写入可以按u 撤回编辑的内容
:q 退出三种模式 切换到目录下
vim下常用的编辑命令
一般模式下:


dw删除一个单词,把光标移到某个单词位置,会删除这个字符开始的后面的字符,想删除完整的单词,要把光标移动到单词的第一个位置。
编辑模式:

命令模式:
:或者/ 进入命令模式,对整体的文档进行一个编辑操作。


网络配置和系统管理操作
Linux下使用ifconfig查看IP,在主机下ping虚拟机的IP是可以ping通的。
可以看到我主机的IP:

我虚拟机下的IP是:

可见二者不在同一网段,但是却能互相通信这是什么原因呢?

这就要说一下虚拟机里的网络连接模式了,如下图虚拟机提供了三种网络连接方式。

桥接模式:
虚拟机直接连接外部物理网络的模式,主机起到了一个网桥的作用,这种模式下,虚拟机可以直接访问外部网络,并且对外部网络是可见的。

NAT模式:
虚拟机和主机构建一个专用网络,并通过虚拟网络地址转换设备对IP进行转换,虚拟机通过共享主机IP
可以访问外部网络,但是外部网络无法访问虚拟机。

下面这个就是主机构建的虚拟网卡用来访问虚拟机

VMnet1则是仅主机模式的网卡,虚拟机只与主机共享一个专用网络,与外部无法通信
查看虚拟机主机名:

修改虚拟机主机名,第一种方式修改后要重启服务器

下面这种方式修改后,实时生效。

我没有修改主机名,还是ubuntu,然后这时在主机ping虚拟机看到结果如下:

在windows主机下C:\Windows\System32\drivers\etc\host中添加:

然后再去ping ubuntu:

Linux系统管理
进程:计算机中,一个正在执行的程序或者命令就是一个进程
服务:启动之后一直存在常驻的进程,一般叫做服务
基本语法:
Cetos6:
service 服务名 start/stop/restart/status
系统启动的时候需要某些系统服务,直到系统关闭,系统服务才会关闭,执行这些系统服务的进程被叫做:daemon守护进程。守护进程和系统服务不做区分。

Centos7:
Systemctl start/stop/restart/status 服务名

Linux的运行级别

Centos7运行级别简化为:
multi-user.target :多用户有网 无图形界面
graphical.target :多用户有网 有图形界面
查看当前运行级别:systemctl get=default
修改当前运行级别:systemctl set-default TARGET.target TARGET = “multi”或者”graphical”
关机(一分钟后执行):shutdown
取消关机:shutdown -c
立即关机:shutdown now
指定时间关机(n分钟后):shutdown n
指定时间关机(18:00):shutdown 18:00
shutdown之所以会在一分钟后关机,主要是系统先执行了sync操作
sync:数据由内存同步到硬盘上。在Linux写入数据的时候会先写入到buffer缓冲区中,然后等缓冲区满了以后才会写入硬盘,提高写入效率但是也会造成安全隐患使数据未及时保存,sync就是立刻将buffer的内容写入硬盘。
halt:停机关闭系统,但不断电,数据有可能保存着
poweroff:断电关机
reboot:重启,等同于shutdown -r now