Learn the Linux vim text editor like this

vim text editor

➢ Command mode: Control the movement of the cursor, and can copy, paste, delete and search the text.
➢ Input mode: normal text input.
➢ Last line mode: Save or exit the document, and set the editing environment
insert image description here
Some of the most commonly used commands in the command mode.
insert image description here
The last line mode is mainly used to save or exit files, and to set the working environment of the Vim editor. It also allows users to execute external Linux commands or jump to a specific number of lines in the written document. To switch to last-line mode, enter a colon in command mode. Commonly used commands in the last line mode are shown in Table 4-2.
insert image description here

1. Write a simple document

The first step in writing a script document is to give the document a name, here it is named practice.txt. If the document exists, it is opened. If it does not exist, a temporary input file is created, as shown.
insert image description here
After opening the practice.txt document, the command mode of the Vim editor is entered by default. At this time, only commands in this mode can be executed, and text content cannot be entered at will. We need to switch to input mode to be able to write documents.

You can use the 3 keys a, i, o to switch from command mode to input mode. Among them, the a key and the i key are to switch to the input mode at the position behind the cursor and the current position of the cursor respectively, and the o key is to create a blank line under the cursor. At this time, you can press the a key to enter the input mode of the editor. mode, as shown in Figure 4-3.
insert image description here
After writing, if you want to save and exit, you must first press the Esc key on the keyboard to return to the command mode from the input mode, and then enter ":wq!" to switch to the last line mode to complete the save and exit operation, as shown in the figure.
insert image description here
Check the result:
insert image description here
Continue to append and write. by typing o
insert image description here

2. Configure the host name

Most hostnames are stored in the /etc/hostname file, modify the content of the /etc/hostname configuration file to “linuxprobe.com”, the steps are as follows.

1. Use the Vim editor to modify the /etc/hostname host name file.
2. Add "linuxprobe.com" after deleting the original host name. Note that after using the Vim editor to modify the hostname file, you must execute the ":wq!" command in the last line mode to save and exit the document.
3. Save and exit the document, and then use the hostname command to check whether the modification is successful.

vim /etc/hostname
hostname

3. Configure network card information

Now there is a network card device called ifcfg-ens160, which is configured to start automatically at boot, and the IP address, subnet, gateway and other information are manually specified, and the steps are as follows.

1. First switch to the /etc/sysconfig/network-scripts directory (the configuration file of the network card is stored).
2. Use the Vim editor to modify the network card file ifcfg-ens160, write the following configuration parameters item by item and save and exit. Since the hardware and architecture of each device is different, use the ifconfig command to confirm the default name of each network card.
3. Restart the network service and test whether the network is connected.

cd /etc/sysconfig/network-scripts/
vim ifcfg-ens160

Restart the command of the network card device, and then use the ping command to test whether the network can be connected. Since the ping command does not terminate automatically in the Linux system, you need to manually press the Ctrl+C key combination to forcibly terminate the process.

nmcli connection reload ens160
ping 192.168.10.10

4. Configure the software warehouse

Enter the directory where the network card configuration file is located, then edit the network card configuration file, and fill in the following information:
TYPE=Ethernet
BOOTPROTO=static
NAME=ens160
ONBOOT=yes
IPADDR=192.168.122.255
NETMASK=255.255.255.0
GATEWAY=192.168.122.1
DNS1=192.168.174.1

Execute the command to restart the network card device, and then use the ping command to test whether the network is connected. Since the ping command does not terminate automatically in the Linux system, you need to manually press the Ctrl+C key combination to forcibly end the process.

nmcli connection reload ens160
ping 192.168.122.255

5. Configure the software warehouse

The general steps to build and configure the software warehouse are as follows
1. Enter the /etc/yum.repos.d/ directory (because this directory stores the configuration files of the software warehouse).
2. Use the Vim editor to create a new configuration file named rhel8.repo (the file name is optional, but the suffix must be .repo), write the following configuration parameters item by item, save and exit.
➢ Warehouse name: a unique identification name that should not conflict with other software warehouses.
➢ Descriptive information: It can be some introductory words, which is easy to identify the usefulness of the software warehouse.
➢ Warehouse location: the way to obtain the software package, which can be downloaded using FTP or HTTP, or it can be a local file (the file parameter needs to be added later).
➢ Whether to enable: Set whether this source is available; 1 is available, 0 is disabled.
➢ Verification: Set whether the source verifies the file; 1 means verification, 0 means no verification.
➢ Public key location: If the verification function is enabled in the above parameters, this is the location of the public key file. If it is not enabled, omit it
. 3. Mount the CD according to the warehouse location filled in the configuration parameters, and write the CD mount information into the /etc/fstab file.
4. Use the "dnf install httpd -y" command to check whether the software repository is available.

After entering the /etc/yum.repos.d directory, create a configuration file for the software warehouse:

cd /etc/yum.repos.d/
vim rhel8.repo

After creating the mount point, perform the mount operation, and set it to automatically mount after booting:

mkdir -p /media/cdrom
mount /dev/cdrom /media/cdrom

Try to use the dnf command in the software warehouse to install the Web service. The package name is httpd. After installation, "Complete!" appears, which means the configuration is correct:

dnf install httpd -y

Guess you like

Origin blog.csdn.net/AdamCY888/article/details/131295215