Linux study notes super detailed 0 basics (medium)

Vi/Vim editor

Everything is a file under Linux. Vi editor and Vim editor can directly edit and operate text files. There is no big difference. Vim has color distinction and is more beautiful. Vim file path + file name can enter the general mode, the general mode It is a read-only file and cannot be manipulated.

Three modes of Vim editor

vim click to enter the file

i Click i to enter edit mode

esc exit edit mode

:w To save the changed content, you need to enter the command mode, click: and then click w, write

u If you don't want to write, you can press u to undo the edited content

:q Exit the three modes and switch to the directory

Commonly used editing commands under vim

In normal mode:

dw deletes a word, move the cursor to a certain word position, it will delete the characters behind the beginning of this character, if you want to delete a complete word, you need to move the cursor to the first position of the word.

edit mode:

command mode:

: or / Enter the command mode and perform an editing operation on the entire document.

Network configuration and system management operations

Use ifconfig to view the IP under Linux, and you can ping the IP of the virtual machine under the host.

You can see the IP of my host:

The IP under my virtual machine is:

It can be seen that the two are not in the same network segment, but they can communicate with each other. What is the reason?

This is to talk about the network connection mode in the virtual machine, as shown in the figure below, the virtual machine provides three network connection modes.

Bridge mode:

The mode in which the virtual machine is directly connected to the external physical network, and the host acts as a bridge. In this mode, the virtual machine can directly access the external network and is visible to the external network.

NAT mode:

The virtual machine and the host build a private network, and convert the IP through the virtual network address translation device, and the virtual machine shares the host IP

The external network can be accessed, but the virtual machine cannot be accessed from the external network.

The following is the virtual network card built by the host to access the virtual machine

VMnet1 is a host-only network card. The virtual machine only shares a dedicated network with the host and cannot communicate with the outside world.

View the virtual machine hostname:

Modify the host name of the virtual machine, the first method needs to restart the server after modification

After the modification in the following way, it will take effect in real time.

I did not modify the host name, it is still ubuntu, and then I pinged the virtual machine on the host to see the following results:

Add in C:\Windows\System32\drivers\etc\host under the windows host:

Then go to ping ubuntu:

Linux system administration

进程:计算机中,一个正在执行的程序或者命令就是一个进程

服务:启动之后一直存在常驻的进程,一般叫做服务

基本语法:

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

Guess you like

Origin blog.csdn.net/m0_56366502/article/details/128547613