Kuangshen talks about linux notes. Learn Linux notes from scratch.

1. Introduction overview

Video link: Notes video link

1.1. Why should we learn Linux?

Linux has been around for so many years. In the past, it was still shouting about how it could replace Windows systems. Now this slogan has become much smaller. The development of any thing has its limitations and its ceiling. Just like building another social software to replace Tencent in China, it is basically impossible to think about it because users are already accustomed to using WeChat to communicate. It’s not that they don’t understand the technical implementation, but that the people are already used to it and want them not to use it, even if they If you don’t use your relatives and friends, you still have to use them. There is nothing you can do about it.

It is basically impossible for people who are accustomed to the Windows operating system to switch to other operating systems. It is too difficult to change the habits that a person has developed. There is no way to penetrate into the lives of ordinary people, but it does not mean that Linux has no place to play. On the server side, Linux is becoming more and more popular in the development field. Many programmers feel embarrassed if they don't know anything about Linux. Linux's status in the open source community remains unchanged.

Especially as a back-end programmer, you must master Linux, because this has become the basic threshold for you to find a job, so you have to learn it!

1.2. Introduction to Linux

The Linux kernel was originally written as a hobby by Finnish Linus Torvalds while he was a student at the University of Helsinki.

Linux is a free-to-use and freely disseminated Unix-like operating system. It is a multi-user, multi-task, multi-thread and multi-CPU operating system based on POSIX (Portable Operating System Interface) and UNIX.

Linux can run major UNIX software tools, applications and network protocols. It supports 32-bit and 64-bit hardware. Linux inherits the network-centric design philosophy of Unix and is a multi-user network operating system with stable performance.

1.3. Linux distribution

To put it simply, a Linux distribution is a package of the Linux kernel and application software.

img

Kali linux: used for security penetration testing!

The more well-known distributions currently on the market include: Ubuntu, RedHat, CentOS, Debian, Fedora, SuSE, OpenSUSE, Arch Linux, SolusOS, etc.

img

1.4. Linux application areas

Today, various Linux distributions are used in various occasions, from embedded devices to supercomputers, and have established a position in the server field. Usually servers use LAMP (Linux + Apache + MySQL + PHP) or LNMP (Linux + Nginx + MySQL + PHP) combination.

Linux is currently not only used in homes and businesses, but is also very popular in government.

  • The Brazilian federal government is world-famous for its support of Linux.
  • There are news reports that the Russian military's own Linux distribution, as the GHost project, has come to fruition.
  • India's Kerala Federation plans to promote the use of Linux in high schools across the federation.
  • In order to achieve technological independence, the People's Republic of China exclusively uses Linux in Loongson processors.
  • Some regions in Spain have developed their own Linux distributions and are widely used in the government and education fields, such as gnuLinEx in the Extremadura region and Guadalinex in the Andalusia region.
  • Portugal also uses its own Linux distribution, Caixa Mágica, for Magalh?es laptops and e-escola government software.
  • France and Germany are also beginning to gradually adopt Linux.

1.5、Linux vs Windows

img

2. Environment construction

The installation steps of Linux are relatively complicated (the operating system itself is also a software). Nowadays, cloud servers are actually quite common and the price is cheap. If you don’t want to build one directly, you can just buy one for learning!

Install CentOS (installing locally, this is not recommended. If you have no financial resources, you can consider building it locally)

Linux is an operating system, and you can also install a dual system on your computer!

Virtual machine (VMware download (charged, registration code!)

Official website download:

After the installation is complete, open the software and you will see the following interface:

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-n6aW3SOc-1680868916280) (E:\notes\typora-user-images\image-20230401173750029.png)]

Install CentOS7 on a virtual machine

1. Can be installed through mirroring! Download address: [http://mirrors.aliyun.com/centos/7/isos/x86_64/, install it after the download is complete! Installing the operating system is the same as installing software. Note: When partitioning a Linux disk, you need to pay attention to the partition name! /boot /home!

2. You can use the image I have made! (Mad God made a mirror of his own!) Use the Baidu Cloud link to download it!

Link: https://pan.baidu.com/s/1e0YEzN3BW0DDXFtMscvvVA Extraction code: 716m After copying this content, open the Baidu Netdisk mobile app for more convenient operation.

3. Install VMware virtual machine software, then open our image and use it!

What it looks like after opening:

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-pcinIzSq-1680868916280) (E:\Notes\typora-user-images\image-20230401173732870.png)]

How to use VMware:

Click the screen to enter the virtual machine, Ctrl + Alt will focus on exiting the virtual machine!

3. Get closer to the Linux system

3.1. Log in after power on

Many programs will start when booting. They are called "services" in Windows and "daemons" in Linux.

After successful startup, it will display a text login interface, which is the login interface we often see. In this login interface, the user will be prompted to enter a user name, and the user entered by the user will be passed as a parameter to the login program to verify the user. The identity and password are not displayed, just press Enter after entering!

Generally speaking, there are three ways for users to log in:

Command line login, ssh login, graphical interface login, and the highest authority account is root, which can operate everything!

3.2. Shut down

In the Linux field, it is mostly used on servers, and shutdown operations are rarely encountered. After all, there is no end to running a service on the server. Unless under special circumstances, it will be shut down as a last resort.

The shutdown command is: shutdown;

sync # 将数据由内存同步到硬盘中。
shutdown # 关机指令,你可以man shutdown 来看一下帮助文档。例如你可以运行如下命令关机:
shutdown –h 10 # 这个命令告诉大家,计算机将在10分钟后关机
shutdown –h now # 立马关机
shutdown –h 20:25 # 系统会在今天20:25关机
shutdown –h +10 # 十分钟后关机
shutdown –r now # 系统立马重启
shutdown –r +10 # 系统十分钟后重启
reboot # 就是重启,等同于 shutdown –r now
halt # 关闭系统,等同于shutdown –h now 和 poweroff

Finally, to summarize, whether you restart the system or shut down the system, you must first run the sync command to write the data in the memory to the disk.

3.3. System directory structure

1. Everything is a file 2. Root directory /, all files are mounted under this node

After logging in to the system, enter the command in the current command window:

ls /

You will see something like this:

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-9MGTXjXW-1680868916281) (E:\notes\typora-user-images\image-20230401174038032.png)]

Tree directory structure:

Here's an explanation of these directories:

  • /bin: bin is the abbreviation of Binary. This directory stores the most frequently used commands.
  • /boot: Stored here are some core files used when starting Linux, including some connection files and image files. (Do not move)
  • /dev: dev is the abbreviation of Device, which stores Linux external devices. The way to access devices in Linux is the same as the way to access files.
  • /etc: This directory is used to store all configuration files and subdirectories required for system management.
  • /home: The user's home directory. In Linux, each user has his own directory. Generally, the directory name is named after the user's account. /lib: This directory stores the most basic dynamic link shared library of the system, and its function is similar to the DLL file in Windows. (Don't move) /lost+found: This directory is usually empty. When the system is shut down illegally, some files are stored here. (Storing some files that were suddenly shut down)
  • /media: The Linux system will automatically recognize some devices, such as U disks, CD-ROM drives, etc. After recognition, Linux will mount the recognized devices to this directory.
  • /mnt: The system provides this directory to allow users to temporarily mount other file systems. We can mount the optical drive on /mnt/, and then enter this directory to view the contents of the optical drive. (We will mount some local files in this directory later)
  • /opt: This is the directory where additional software is installed for the host. For example, if you install an ORACLE database, you can put it in this directory. The default is empty.
  • /proc: This directory is a virtual directory, which is a mapping of system memory. We can obtain system information by directly accessing this directory. (Do not care)
  • /root: This directory is the user home directory of the system administrator, also known as the super privileged person.
  • /sbin: s means Super User. What is stored here is the system management program used by the system administrator. /srv: This directory stores some data that needs to be extracted after the service is started.
  • /sys: This is a big change in the Linux 2.6 kernel. A new file system sysfs that appeared in the 2.6 kernel is installed in this directory.
  • /tmp: This directory is used to store some temporary files. Files that are thrown away after use can be placed in this directory to install the package! /usr: This is a very important directory. Many user applications and files are placed in this directory, similar to the program files directory under Windows. /usr/bin: Applications used by system users.
  • /usr/sbin: More advanced management programs and system daemons used by super users.
  • Super /usr/src: The default placement directory for kernel source code.
  • /var: This directory stores things that are constantly expanding. We are accustomed to placing directories that are frequently modified in this directory. Includes various log files.
  • /run: is a temporary file system that stores information since the system started. When the system restarts, files in this directory should be deleted or cleared. /www: Stores server website-related resources, environment, and website projects

4. Commonly used basic commands

4.1. Directory management

4.1.1. Absolute path, relative path

The full name of the absolute path: C:\ProgramData\360safe\xxx.xx

For example, in the 360safe directory, the xxx.xx file corresponds to our relative configuration /xxx.xx

cd: Switch directory command! ./: Current directory cd...: Return to the previous directory (cd is preceded by two English periods)

4.1.2, ls (list directories!)

ls is probably the most commonly used in Linux!

-a parameter: all, view all files, including hidden files -l parameter lists all files, including file attributes and permissions, all Linux without hidden files can be used in combination!

4.1.3. cd command to switch directories

cd directory name (absolute paths start with /, relative paths, how to find the current directory.../.../)

4.1.4. mkdir creates directory

mkdir xxx: Create a directory mkdir -p test2/test3/test4: Create a multi-level directory

[root@kuangshen home]# mkdir test1 # 创建目录
[root@kuangshen home]# ls
install.sh kuangshen kuangstudy test1 www
[root@kuangshen home]# cd test1
[root@kuangshen test1]# cd ..
[root@kuangshen home]# mkdir test2/test3/test4 # 创建多级目录
mkdir: cannot create directory ‘test2/test3/test4’: No such file or directory
[root@kuangshen home]# mkdir -p test2/test3/test4
[root@kuangshen home]# ls
install.sh kuangshen kuangstudy test1 test2 www
[root@kuangshen home]# cd test2
[root@kuangshen test2]# ls
test3
[root@kuangshen test2]# cd test3
[root@kuangshen test3]# ls
test4
4.1.5. rmdir delete directory

rmdir xxx: Delete the directory that is not empty rmdir -p test2/test3/test4: Force the directory to be deleted

[root@kuangshen test3]# cd /home
[root@kuangshen home]# ls
install.sh kuangshen kuangstudy test1 test2 www
[root@kuangshen home]# rmdir test1
[root@kuangshen home]# ls
install.sh kuangshen kuangstudy test2 www
[root@kuangshen home]# rmdir test2
rmdir: failed to remove ‘test2’: Directory not empty
[root@kuangshen home]# rmdir -p test2
rmdir: failed to remove ‘test2’: Directory not empty
[root@kuangshen home]# rmdir -p test2/test3/test4
[root@kuangshen home]# mkdir -p test2/test3/test4
[root@kuangshen home]# rmdir test2/test3/test4
[root@kuangshen home]# ls
install.sh kuangshen kuangstudy test2 www
[root@kuangshen home]# mkdir -p test2/test3/test4
[root@kuangshen home]# ls
install.sh kuangshen kuangstudy test2 www
[root@kuangshen home]# rmdir -p test2/test3/test4
[root@kuangshen home]# ls
install.sh kuangshen kuangstudy www

rmdir can only delete empty directories. If there are files below, you need to delete the files first and recursively delete multiple directories with the -p parameter.

4.1.6, cp copy file directory

cp Original location New location If the file is duplicated, select overwrite (y) or discard (n)

[root@kuangshen home]# cp install.sh kuangstudy # 拷贝文件至目录
[root@kuangshen home]# ls
install.sh kuangshen kuangstudy www
[root@kuangshen home]# cd kuangstudy/
[root@kuangshen kuangstudy]# ls
install.sh
[root@kuangshen kuangstudy]# cd ..
[root@kuangshen home]# cp install.sh kuangstudy # 如果文件重复,就选则覆盖(y)或者 放弃(n)
cp: overwrite ‘kuangstudy/install.sh’? y
[root@aubin aubin]# cd /
[root@aubin /]# cd home 
[root@aubin home]# ls
aubin  test  test2
[root@aubin home]# cd test 
[root@aubin test]# touch test.txt
[root@aubin test]# ls
test.txt
[root@aubin home]# cp test/test.txt test2 
[root@aubin home]# cd test2
[root@aubin test2]# ls
test.txt
4.1.7, rm removes file directory

-f ignores non-existent files, no warning will appear, and forced deletion! -r delete directories recursively! -i Interactive, delete and ask whether to delete rm -rf / Delete the library and run away rm -rf / # All the files in the system will be deleted. This is how to delete the library and run away!

[aubin@aubin /]$ su
密码:
[root@aubin /]# cd /
[root@aubin /]# cd  home
[root@aubin home]# ls
aubin  test  test2
[root@aubin home]# cd test
[root@aubin test]# ls
test2  test.txt
[root@aubin test]# rm -rf test.txt
[root@aubin test]# ls
test2
[root@aubin test]# 

-f ignores non-existent files, no warning will appear, and forced deletion!

-r delete directories recursively!

-i interactive, delete and ask whether to delete

4.1.8, mv move file directory

You can also rename the folder

-f forces -u to replace only updated files mv install.sh kuangstudy moves files mv kuangstudy kuangstudy2 renames the folder

[root@aubin test]# cd ..
[root@aubin home]# ls
aubin  test  test2
[root@aubin home]# cd test2
[root@aubin test2]# ls
test.txt
[root@aubin test2]# cd ..
[root@aubin home]# mkdir test3
[root@aubin home]# ls
aubin  test  test2  test3
[root@aubin home]# mv test2/test.txt test3
[root@aubin home]# cd test3
[root@aubin test3]# ls
test.txt
[root@aubin test3]# cd ..
[root@aubin home]# mv test3 test4
[root@aubin home]# ls
aubin  test  test2  test4
[root@aubin home]# 

4.2. Basic attributes

Ten letters; 1 type

4.2.1. Understand file attributes

The Linux system is a typical multi-user system. Different users are in different positions and have different permissions. In order to protect the security of the system, the Linux system has different regulations on the permissions of different users to access the same file (including directory files).

In Linux, we can use the ll or ls -l command to display the attributes of a file and the user and group to which the file belongs, such as:

[root@aubin home]# ls -ll
总用量 4
drwx------. 16 aubin aubin 4096 3月  22 18:20 aubin
drwxr-xr-x.  2 root  root    35 3月  22 18:31 test
drwxr-xr-x.  2 root  root     6 3月  22 18:33 test2
drwxr-xr-x.  2 root  root    22 3月  22 18:33 test4

In the example, the first attribute of the root file is represented by "d". "d" in Linux means that the file is a directory file.

In Linux, the first character indicates whether the file is a directory, file, link file, etc.:

  1. When it is [d], it is a directory
  2. When it is [-], it is a file
  3. When it is [l], it is expressed as a link (link file)
  4. If it is [b], it means that it is an interface device that can be stored in the device file (random access device)
  5. If it is [c], it means the serial port device in the device file, such as keyboard and mouse (one-time reading device)

The attributes of each file are determined by the 10 characters in the first part on the left (as shown below):

img

They are represented by numbers 0-9 from left to right.

Bit 0 determines the file type, and bits 1-3 determine the owner (the owner of the file) who has permissions on the file. Bits 4-6 determine that the group (users in the same group of the owner) has permissions for the file, and bits 7-9 determine that other users have permissions for the file.

in:

Bits 1, 4, and 7 indicate read permission. If it is represented by the "r" character, it has read permission. If it is represented by the "-" character, it does not have read permission;

The 2nd, 5th, and 8th bits indicate write permission. If the "w" character is used, it means there is write permission. If the "-" character is used, it means there is no write permission;

The 3rd, 6th, and 9th digits represent executable permissions. If it is represented by the "x" character, it has execution permission. If it is represented by the "-" character, it does not have execution permission.

A file has a specific owner, which is the user who owns the file.

At the same time, in Linux systems, users are classified by groups, and a user belongs to one or more groups.

Users other than the file owner can be divided into users in the same group as the file owner and other users.

Therefore, the Linux system stipulates different file access permissions based on the file owner, users in the file owner's group, and other users.

In the above example, the test file is a directory file, and the owner and group are both root.

4.2.2. Modify file attributes

1. chgrp: Change the file group

chgrp [-R] 属组名 文件名

-R: Change the file group recursively, that is, when changing the group ownership of a directory file, if you add the -R parameter, the group ownership of all files in the directory will be changed.

2. chown: Change the file owner, and you can also change the file group at the same time.

chown [–R] 属主名 文件名
chown [-R] 属主名:属组名 文件名

3. chmod: Change 9 attributes of the file (must be mastered)

You do not have permission to operate this file!

chmod [-R] xyz 文件或目录

There are two ways to set Linux file attributes, one is numbers (numbers are commonly used), and the other is symbols.

There are nine basic permissions for Linux files. The three identities of owner/group/others each have their own read/write/execute permissions.

Let’s review the data just mentioned above: the permission characters of the file are: "-rwxrwxrwx", these nine permissions are in groups of three! Among them, we can use numbers to represent each permission. The score comparison table for each permission is as follows:

r:4    w:2    x:1   #对应数值

可读可写不可执行 rw- 6
可读可写不课执行 rwx 7

chomd  777  文件赋予所有用户可读可执行!

The three permissions (r/w/x) scores of each identity (owner/group/others) need to be accumulated. For example, when the permissions are: [-rwxrwx—], the score is:

owner = rwx = 4+2+1 = 7 group = rwx = 4+2+1 = 7 others= — = 0+0+0 = 0

chmod 770 filename
4.2.3. View file content

We will often use file viewing!

Use the following command on Linux systems to view the contents of the file:

cat displays the file content starting from the first line. It is used to read articles or read configuration files. The cat name is used.

tac is displayed starting from the last line. It can be seen that tac is cat written backwards!

[root@aubin test]# echo 'hwt' >> test.txt
[root@aubin test]# cat test.txt
hwt
[root@aubin test]# echo 'aa' >> test.txt
[root@aubin test]# cat test.txt
hwt
aa
[root@aubin test]# tac test.txt
hwt
aa

When nl is displayed, the line number is output! When looking at the code, I want the line number to be displayed! Commonly used

[root@aubin test]# nl test.txt
     1	hwt
     2	aa

more displays the file content page by page, with the remaining content (space means turning pages, enter means looking down one line, :f line number)

less is similar to more, but what's better than more is that it can turn pages forward! (The space is used to turn the page, pageDown, and pageUp keys represent turning the page! Exit the q command, search for the string/character to be queried, search downwards, use ? for the string to be queried, n to search for the next one, N to search! )

head only looks at the first few lines and uses the -n parameter to control how many lines are displayed!

[root@aubin test]# head -n 1 test.txt
hwt

tail only looks at the tail lines -n parameter to check how many lines!

[root@aubin test]# tail -n 1 test.txt
aa

You can use man [command] to view the usage documentation of each command, such as: man cp.

Network configuration directory: cd /etc/sysconfig/network-scripts

Use the ifconfig command to view the network configuration!

4.2.4, Linux link

Expansion: The concept of Linux links (just understand it!)

There are two types of links in Linux: hard links and soft links!

**Hard link:**A-B, assuming B is a hard link to A, then they both point to the same file! A file is allowed to have multiple paths. Users can use this mechanism to establish hard links to some important files to prevent accidental deletion!

Soft link : Similar to the shortcut under Windows, the deleted source file cannot be accessed by the shortcut!

Create connection ln command!

The touch command creates a file!

echo input string, can also be input into a file!

[root@kuangshen home]# touch f1 # 创建一个f1文件
[root@kuangshen home]# ls
f1 install.sh kuangshen www
[root@kuangshen home]# ln f1 f2 # 创建一个硬链接 f2
[root@kuangshen home]# ls
f1 f2 install.sh kuangshen www
[root@kuangshen home]# ln -s f1 f3 # 创建一个软链接(符号连接) f3
[root@kuangshen home]# ls
f1 f2 f3 install.sh kuangshen www
[root@kuangshen home]# ll
total 28
-rw-r--r-- 2 root root 0 Mar 24 20:17 f1
-rw-r--r-- 2 root root 0 Mar 24 20:17 f2
lrwxrwxrwx 1 root root 2 Mar 24 20:18 f3 -> f1
-rw-r--r-- 1 root root 20078 Mar 4 16:48 install.sh
drwxr-xr-x 2 root root 4096 Mar 23 21:25 kuangshen
drwxrw---x 2 www www 4096 Mar 23 12:46 www
[root@kuangshen home]# echo "i love kuangshen" >>f1 # 给f1文件中写入一些字符串!
[root@kuangshen home]# ls
f1 f2 f3 install.sh kuangshen www
[root@kuangshen home]# clear
[root@kuangshen home]# ll
total 36
-rw-r--r-- 2 root root 17 Mar 24 20:19 f1
-rw-r--r-- 2 root root 17 Mar 24 20:19 f2
lrwxrwxrwx 1 root root 2 Mar 24 20:18 f3 -> f1
-rw-r--r-- 1 root root 20078 Mar 4 16:48 install.sh
drwxr-xr-x 2 root root 4096 Mar 23 21:25 kuangshen
drwxrw---x 2 www www 4096 Mar 23 12:46 www
[root@kuangshen home]# cat f1 # 查看f1
i love kuangshen
[root@kuangshen home]# cat f2 # 查看f2
i love kuangshen
[root@kuangshen home]# cat f3 # 查看f3
i love kuangshen

After deleting f1, check the difference between f2 and f3

After deleting f1, check the difference between f2 and f3

[root@kuangshen home]# rm -rf f1
[root@kuangshen home]# ls
f2 f3 install.sh kuangshen www
[root@kuangshen home]# cat f2 # f2 硬链接还在
i love kuangshen
[root@kuangshen home]# cat f3 # f3(软连接、符号连接)快捷方式失效!
cat: f3: No such file or directory

4.3. Vim editor

4.3.1. What is Vim editor

im can achieve the same functions as IDE through some plug-ins!

Vim is a text editor developed from vi. It is particularly rich in functions that facilitate programming, such as code completion, compilation, and error jumping, and is widely used among programmers. Especially in Linux, you must be able to use Vim (view content, edit content, save content!)

To put it simply, vi is an old-fashioned word processor, but its functions are already very complete, but there is still room for improvement.

vim can be said to be a very useful tool for program developers.

All Unix Like systems will have a built-in vi document editor, but other document editors may not exist.

Even vim's official website ( http://www.vim.org ) itself says that vim is a program development tool rather than a word processing software.

vim keyboard diagram:

img

4.3.2. Three usage modes

Basically vi/vim is divided into three modes, namely command mode (Command mode), input mode (Insert mode) and bottom line command mode (Last line mode). The functions of these three modes are:

**Command mode:** The user has just started vi/vim and entered the command mode.

Keystrokes in this state will be recognized by Vim as commands instead of entering characters. For example, if we press i at this time, we will not enter a character. i is treated as a command.

The following are some commonly used commands:

i Switch to input mode to enter characters. x Delete the character at the current cursor position. : Switch to bottom line command mode to enter commands on the bottom line. If it is in edit mode, you need to exit edit mode first! ESC If you want to edit text: Start Vim, enter command mode, press i to switch to input mode.

Command mode only has some of the most basic commands, so you still have to rely on the bottom line command mode to enter more commands.

**Input mode:** Press i in command mode to enter input mode.

In input mode, the following keys are available:

Character keys and Shift combination, input characters ENTER, carriage return key, line feed BACK SPACE, backspace key, delete the character before the cursor DEL, delete key, delete the character after the cursor Direction keys, move the cursor in the text HOME/END, move the cursor Page Up/Page Down to the beginning/end of the line, Insert to turn the page up/down, switch the cursor to the input/replacement mode, the cursor will become a vertical bar/underline ESC, exit the input mode, switch to the command mode. Bottom line command mode: in In command mode, press: (English colon) to enter the bottom line command mode. The cursor has moved to the bottom, and you can enter some bottom line commands here!

**Bottom line command mode:** Single or multi-character commands can be entered, and there are many available commands.

In bottom line command mode, the basic commands are (the colon has been omitted): wq

  • q Exit the program w Save the file
  • Press the ESC key to exit the bottom line command mode at any time.
  • Simply put, we can think of these three modes as the icons below:

img

4.3.3. Complete demonstration instructions

To create or edit a file, press i to enter the editing mode, write the content, exit the editing mode after writing, esc, and enter the bottom line command mode after exiting: wq Save and exit!

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-J9OvL1C1-1680868916282) (E:\notes\typora-user-images\image-20230401234420160.png)]

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-WmSORGQX-1680868916282) (E:\notes\typora-user-images\image-20230401234437350.png)]

4.3.4. Vim button description

In addition to i, Esc, and :wq in the simple example above, there are actually many keys that can be used in vim.

Part 1: Cursor movement, copy and paste, search and replace, etc. available in general mode

How to move the cursor
h or left arrow key (←) Move the cursor one character to the left
j or down arrow key (↓) Move the cursor down one character
k or up arrow key (↑) Move the cursor up one character
l or right arrow key (→) Move the cursor one character to the right
[Ctrl] + [f] Move the screen "down" by one page, equivalent to the [Page Down] button (commonly used)
[Ctrl] + [b] Move the screen "up" one page, equivalent to the [Page Up] button (commonly used)
[Ctrl] + [d] Move the screen "down" by half a page
[Ctrl] + [u] Move the screen "up" half a page
+ Move the cursor to the next line of non-space characters
- Move the cursor to the previous line of non-space characters
n< space> That n represents "number", such as 20. After pressing the number and then pressing the space bar, the cursor will move n characters of this line to the right.
0 or function key [Home] This is the number "0": move to the front character of this line (commonly used)
$ or function key [End] Move to the last character of this line (commonly used)
H Move the cursor to the first character on the top line of the screen
M Move the cursor to the first character of the line in the center of the screen
L Move the cursor to the first character of the bottom line of the screen
G Move to the last line of this file (commonly used)
Mr n is a number. Move to line n of this file. For example, 20G will be moved to the 20th line of this file (can be used with:set nu)
gg Moving to the first line of this file is equivalent to 1G! (commonly used)
n< Enter> n is a number. Move the cursor down n lines (commonly used)
Search and replace
/word Look for a string named word under the cursor. For example, if you want to search for the string vbird in a file, just enter /vbird! (commonly used)
?word Search for a string named word above the cursor.
n This n is the English button. Represents the action of repeating the previous search. For example, if we just executed /vbird to search downward for the string vbird, then after pressing n, the search will continue downward for the next string named vbird. If ?vbird is executed, then pressing n will continue to search upward for the string named vbird!
N This N is the English button. Just the opposite of n, it is "reverse" to perform the previous search action. For example, after /vbird, pressing N means "up" to search for vbird.
Delete, copy and paste
x, X In a line of words, x is to delete one character backward (equivalent to the [del] key), and X is to delete one character forward (equivalent to [backspace], that is, the backspace key) (commonly used)
nx n is a number, delete n characters backward continuously. For example, I want to delete 10 characters in a row, "10x".
dd Delete the entire row where the cursor is located (commonly used)
n.d n is a number. Delete n lines downward where the cursor is located, for example, 20dd deletes 20 lines (commonly used)
d1G Delete all data from the cursor to the first line
dG Delete all data from the cursor to the last line
d$ Delete from the cursor position to the last character of the line
d0 That is the 0 of the number. Delete where the cursor is, to the first character of the line.
yy Copy the row where the cursor is (commonly used)
nyy n is a number. Copy n lines downward where the cursor is located, for example, 20yy means copying 20 lines (commonly used)
y1G Copy all data from the cursor row to the first row
yG Copy all data from the cursor row to the last row
y0 Copy the character where the cursor is located to all the data at the beginning of the line
y$ Copy all data from the character where the cursor is to the end of the line
p, P p means to paste the copied data on the line below the cursor, and P means to paste it on the line above the cursor! For example, my cursor is currently on row 20, and 10 rows of data have been copied. After pressing p, the 10 rows of data will be pasted after the original 20 rows, that is, starting from the 21st row. But what if you press P? Then the original line 20 will be pushed to line 30. (commonly used)
J Combine the data of the line under cursor and the next line into the same line
c Repeatedly delete multiple data, for example, delete 10 rows downward, [10cj]
u Undo the previous action. (commonly used)
[Ctrl]+r Redo the previous action. (commonly used)

Part 2: Description of available buttons for switching from general mode to editing mode

Enter edit mode for input or replace
i, I Enter input mode (Insert mode): i means "input from the current cursor position", I means "start input from the first non-space character on the current line". (commonly used)
a, A Enter the input mode (Insert mode): a means "start inputting from the next character where the cursor is currently located", A means "start inputting from the last character on the line where the cursor is located". (commonly used)
the, the Enter input mode (Insert mode): This is the uppercase and lowercase version of the English letter o. o means "Enter a new line on the next line where the current cursor is located"; O means enter a new line on the line above the current cursor! (commonly used)
r, R Enter Replace mode: r will only replace the character where the cursor is located once; R will always replace the text where the cursor is located until ESC is pressed; (commonly used)
[Esc] Exit edit mode and return to normal mode (commonly used)

Part 3: Description of available buttons for switching from general mode to command line mode

Command line storage, exit and other commands
:w Write edited data to hard disk file (commonly used)
:w! If the file attribute is "read-only", the file is forced to be written. However, whether you can write it or not depends on your file permissions on the file!
:q Exit vi (commonly used)
:q! If you have modified the file and do not want to save it, use ! to force the exit without saving the file.
Pay attention, the exclamation point (!) in vi often means "force"~
:wq Save and leave. If it is: wq!, it is forced to save and leave (commonly used)
ZZ This is a capital Z! If the file has not been modified, then leave without saving. If the file has been modified, save and then leave!
:w [filename] Save the edited data as another file (similar to Save As)
:r [filename] In the edited data, read data from another file. That is, add the file content "filename" to the end of the line where the cursor is located.
:n1,n2 w [filename] Store the contents of n1 to n2 into the file filename.
:! command Temporarily leave vi and execute command in command line mode to display the results! For example, ":! ls /home" can be used to view the file information output by ls under /home in vi!
:set no Display the line number. After setting, the line number of the line will be displayed in the prefix of each line.
:set nine Contrary to set nu, it cancels the line number!

4.4. Account management

Usually when you are in a company, you should not be using a root account!

4.4.1. Introduction

The Linux system is a multi-user, multi-tasking, time-sharing operating system. Any user who wants to use system resources must first apply for an account from the system administrator, and then enter the system as this account.

On the one hand, the user's account can help the system administrator track the users using the system and control their access to system resources; on the other hand, it can also help the user organize files and provide security protection for the user.

Each user account has a unique username and respective password.

After the user enters the correct user name and password when logging in, he or she can enter the system and his/her home directory.

To realize the management of user accounts, the work to be completed mainly includes the following aspects:

Add, delete and modify user accounts. Management of user passwords. Management of user groups.

4.4.2. Management of user accounts

The management of user accounts mainly involves the addition, modification and deletion of user accounts.

Adding a user account means creating a new account in the system, and then assigning resources such as user number, user group, home directory, and login shell to the new account.

Owner, group

4.4.3. Add user useradd

useradd - option username

Parameter Description:

  • Options:

    • -c comment Specifies a comment description.

    • The -d directory specifies the user's home directory. If this directory does not exist, use the -m option at the same time to create the home directory.

    • -g usergroup specifies the user group to which the user belongs.

    • -G user group, user group specifies additional groups to which the user belongs.

    • -m The user directory is automatically created if it does not exist.

    • -s Shell file specifies the user's login shell.

    • -u user number specifies the user number of the user. If the -o option is also present, the identification number of other users can be reused.

  • username :

    • Specify the login name for the new account.
[root@centos7 home]# useradd -m hwt2
[root@centos7 home]# ls
hwt  hwt2  hwt.txt

Understand the essence: everything in Linux is a file. To add a user here is to write the user's information into a certain file!

/etc/passwd

4.4.4. Delete user userdel

userdel -r qinjiang When deleting a user, delete his directory page together!

[root@centos7 home]# userdel -r hwt2
4.4.5. Modify user usermod

Modify the user usermod and modify the user corresponding to the modified content.

[root@centos7 home]# usermod -d /home/233 qinjiang
修改完毕之后查看配置文件即可!

After the modification is completed, view the configuration file!

4.4.6. Switch users

root user

  1. The command to switch users is: su username [username is your username]

  2. To switch from an ordinary user to a root user, you can also use the command: sudo su

  3. Enter exit or logout in the terminal or use the shortcut ctrl+d to return to the original user. In fact, ctrl+d is also the exit command executed.

[root@centos7 home]# su hwt
[hwt@centos7 home]$ 
  1. When switching users, if you want to use the new user's working environment after switching users, you can add - between su and username, for example: [su - root]

$ means ordinary user # means super user, that is, the root user. After some friends buy a server on Alibaba Cloud, the host name is a random string!

4.4.7. User password settings

We usually create users through root! Need to configure password!

The password you enter on Linux will not be displayed. You can just enter it normally. It is not a system problem!

In a company, you generally don't have root permissions on the company's servers, they are all assigned accounts!

If you are a super user:

passwd username:
new password:
re password:

If you are a normal user:

passwd
(current) UNIX password:   # 输当前用用户密码
new password: # 密码不能太过于简单!
re password:
4.4.8. User password management

Root, for example, Zhang San resigned! Freeze this account. Once frozen, this person will not be able to log in to the system!

The format of the command is:

passwd 选项 用户名

Available options:

  • -l locks the password, that is, disables the account.
  • -u Password unlock.
  • -d causes the account to have no password.
  • -f forces the user to change their password the next time they log in.

If the default username is used, modify the current user's password.

passwd -l qinjiang # 锁定之后这个用户就不能登录了!
passwd -d qinjiang # 没有密码也不能登录!

In a company, you generally don't have access to the root user! As a developer you generally can’t get it!

Everyone must master these basic commands! But you can use it to learn when you play it yourself! Linux is a multi-user system!

4.5. User group management

Owner, group

每个用户都有一个用户组,系统可以对一个用户组中的所有用户进行集中管理(开发、测试、运维、root)。不同Linux 系统对用户组的规定有所不同,如Linux下的用户属于与它同名的用户组,这个用户组在创建用户时同时创建。

用户组的管理涉及用户组的添加、删除和修改。组的增加、删除和修改实际上就是对/etc/group文件的更新。

4.5.1、创建用户组

groupadd

创建完用户组后可以得到一个组的id,这个id是可以指定的! -g 520, 如果不指定就是自增1

[root@centos7 home]# groupadd hwt2
[root@centos7 home]# cat /etc/group
4.5.2、删除用户组

groupdel

[root@centos7 home]# groupdel hwt2
[root@centos7 home]# cat /etc/group
4.5.3、修改用户组

修改用户组的权限信息和名字 groupmod -g -n

常用的选项有:

  • -g GID 为用户组指定新的组标识号。
  • -o 与-g选项同时使用,用户组的新GID可以与系统已有用户组的GID相同。
  • -n新用户组 将用户组的名字改为新名字
# 此命令将组hwt的组标识号修改为102。
[root@centos7 home]# groupmod -g 102 hwt
# 将组hwt的标识号改为10000,组名修改为hwt2。
[root@centos7 home]# groupmod -g 10000 -n hwt2  hwt
4.5.4、切换用户组

如果一个用户同时属于多个用户组,那么用户可以在用户组之间切换,以便具有其他用户组的权限。

用户可以在登录后,使用命令newgrp切换到其他用户组,这个命令的参数就是目的用户组。例如:

登录当前用户 qinjiang
$ newgrp root
4.5.5、文件的查看
/etc/passwd

4.5.5、拓展:文件的查看!(了解即可) /etc/passwd

用户名:口令(登录密码,我们不可见):用户标识号:组标识号:注释性描述:主目录:登录Shell
这个文件中的每一行都代表这一个用户,我们可以从这里看出这个用户的主目录在哪里,可以看到属于哪一个组!

登录口令:把真正的加密后的用户口令字存放到**/etc/shadow**文件中,保证我们密码的安全性!

用户组的所有信息都存放在**/etc/group**文件中。

拓展:用户文件解析
/etc/passwd 用户文件
/etc/shadow 用户密码文件

4.6、磁盘管理

4.6.1、磁盘空间使用量

Linux磁盘管理好坏直接关系到整个系统的性能问题。

Linux磁盘管理常用命令为 df、du。

  • df (列出文件系统整体的磁盘使用量)

  • du(检查磁盘空间使用量!)

df

df命令参数功能:检查文件系统的磁盘空间占用情况。可以利用该命令来获取硬盘被占用了多少空间,目前还剩下多少空间等信息。

语法:

df [-ahikHTm] [目录或文件名]

选项与参数:

  • -a :列出所有的文件系统,包括系统特有的 /proc 等文件系统;
  • -k :以 KBytes 的容量显示各文件系统;
  • -m :以 MBytes 的容量显示各文件系统;
  • -h :以人们较易阅读的 GBytes, MBytes, KBytes 等格式自行显示;
  • -H :以 M=1000K 取代 M=1024K 的进位方式;
  • -T :显示文件系统类型, 连同该 partition 的 filesystem 名称 (例如 ext3) 也列出;
  • -i :不用硬盘容量,而以 inode 的数量来显示

测试:

# 将系统内所有的文件系统列出来!
# 在 Linux 底下如果 df 没有加任何选项
# 那么默认会将系统内所有的 (不含特殊内存内的文件系统与 swap) 都以 1 Kbytes 的容量来列出来!
[root@centos7 home]# df
文件系统                   1K-块    已用     可用 已用% 挂载点
devtmpfs                  914568       0   914568    0% /dev
tmpfs                     931496       0   931496    0% /dev/shm
tmpfs                     931496   10668   920828    2% /run
tmpfs                     931496       0   931496    0% /sys/fs/cgroup
/dev/mapper/centos-root 49250820 6341956 42908864   13% /
/dev/sda1                1038336  173488   864848   17% /boot
tmpfs                     186300      44   186256    1% /run/user/0

# 将容量结果以易读的容量格式显示出来
[root@centos7 home]# df -h
文件系统                 容量  已用  可用 已用% 挂载点
devtmpfs                 894M     0  894M    0% /dev
tmpfs                    910M     0  910M    0% /dev/shm
tmpfs                    910M   11M  900M    2% /run
tmpfs                    910M     0  910M    0% /sys/fs/cgroup
/dev/mapper/centos-root   47G  6.1G   41G   13% /
/dev/sda1               1014M  170M  845M   17% /boot
tmpfs                    182M   44K  182M    1% /run/user/0

# 将系统内的所有特殊文件格式及名称都列出来
[root@centos7 home]# df -aT
文件系统                类型               1K-块    已用     可用 已用% 挂载点
sysfs                   sysfs                  0       0        0     - /sys
proc                    proc                   0       0        0     - /proc
devtmpfs                devtmpfs          914568       0   914568    0% /dev
securityfs              securityfs             0       0        0     - /sys/kernel/security

# 将 /etc 底下的可用的磁盘容量以易读的容量格式显示
[root@centos7 home]# df -h /etc
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   47G  6.1G   41G   13% /

du

Linux du命令也是查看使用空间的,但是与df命令不同的是Linux du命令是对文件和目录磁盘使用的空间的查看,还是和df命令有一些区别的,这里介绍Linux du命令。

语法:

du [-ahskm] 文件或目录名称

选项与参数:

  • -a :列出所有的文件与目录容量,因为默认仅统计目录底下的文件量而已。
  • -h :以人们较易读的容量格式 (G/M) 显示;
  • -s :列出总量而已,而不列出每个各别的目录占用容量;
  • -S :不包括子目录下的总计,与 -s 有点差别。
  • -k :以 KBytes 列出容量显示;
  • -m :以 MBytes 列出容量显示;

测试:

# 只列出当前目录下的所有文件夹容量(包括隐藏文件夹):
# 直接输入 du 没有加任何选项时,则 du 会分析当前所在目录的文件与目录所占用的硬盘空间。
[root@centos7 home]# du
0	./hwt/.mozilla/extensions/{
    
    ec8030f7-c20a-464f-9b0e-13a3a9e97384}
0	./hwt/.mozilla/extensions
0	./hwt/.mozilla/plugins
0	./hwt/.mozilla/firefox/mgoelv6b.default-default/storage/permanent/chrome/idb/3870112724rsegmnoittet-es.files
0	./hwt/.mozilla/firefox/mgoelv6b.default-default/storage/permanent/chrome/idb/3561288849sdhlie.files
4.6.2、挂载磁盘或文件

Mac 或者想使用Linux 挂载我们的一些本地磁盘或者文件!

挂载:mount

mount [-t 文件系统] [-L Label名] [-o 额外选项] [-n] 装置文件名 挂载点

测试:

# 将 /dev/hdc6 挂载到 /mnt/hdc6 上面!
[root@centos7 home]# mkdir /mnt/hdc6
[root@centos7 home]# mount /dev/hdc6 /mnt/hdc6
[root@centos7 home]# df
Filesystem           1K-blocks     Used Available Use% Mounted on
/dev/hdc6              1976312     42072   1833836   3% /mnt/hdc6

卸载:umount -f [挂载位置] 强制卸载

umount [-fn] 装置文件名或挂载点

选项与参数:

  • -f :强制卸除!可用在类似网络文件系统 (NFS) 无法读取到的情况下;
  • -n :不升级 /etc/mtab 情况下卸除。

卸载/dev/hdc6

[root@www ~]# umount /dev/hdc6

除了这个之外,以后我们安装了JDK ,其实可以使用java中的一些命令来查看信息!

4.7、进程管理

Linux中一切皆文件

(文件:读写执行(查看,创建,删除,移动,复制,编辑),权限(用户、用户组)。系统:(磁盘,进程))

对于我们开发人员来说,其实Linux更多偏向于使用即可!

4.7.1、基本概念

1、在Linux中,每一个程序都是有自己的一个进程,每一个进程都有一个id号! 2、每一个进程呢,都会有一个父进程! 3、进程可以有两种存在方式:前台!后台运行! 4、一般的话服务都是后台运行的,基本的程序都是前台运行的!

4.7.2、命令

ps 查看当前系统中正在执行的各种进程的信息!

ps -xx :

-a 显示当前终端运行的所有的进程信息(当前的进程一个) -u 以用户的信息显示进程 -x 显示后台运行进程的参数!

ps -aux 查看所有的进程
ps -aux|grep mysql
| 在Linux这个叫做管道符 A|B
grep 查找文件中符合条件的字符串!

对于我们来说,这里目前只需要记住一个命令即可 ps -xx|grep 进程名字! 过滤进程信息!

ps -ef:可以查看到父进程的信息

ps -ef|grep mysql # 看父进程我们一般可以通过目录树结构来查看!
进程树!
pstree -pu
-p 显示父id
-u 显示用户组
[root@centos7 home]# ps -aux
USER        PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root          1  0.0  0.3 193980  7140 ?        Ss   4月01   0:08 /usr/lib/systemd/sys
root          2  0.0  0.0      0     0 ?        S    4月01   0:00 [kthreadd]
root          4  0.0  0.0      0     0 ?        S<   4月01   0:00 [kworker/0:0H]
root          6  0.0  0.0      0     0 ?        S    4月01   0:00 [ksoftirqd/0]

结束进程:杀掉进程,等价于window结束任务!

kill -9 进程的id

但是啊,我们平时写的一个Java代码死循环了,可以选择结束进程!杀进程

kill -9 进程的id

表示强制结束该进程!

将Java程序打包发布的时候讲解! nohup ,代表后台执行程序

5、环境安装

安装软件一般有三种方式:

rpm(Jdk:在线发布一个SringBoot项目!) 解压缩(tomcat,启动并通过外网访问,发布网站) yum在线安装(docker:直接安装运行跑起来docker就可以!)!

5.1、JDK安装

我们开发java程序必须要的环境! 1、下载JDK rpm。去oralce 官网下载即可! 2、安装java环境

# 检测当前系统是否存在java环境! java -version
# 如果有的话就需要卸载
# rpm -qa|grep jdk # 检测JDK版本信息
# rpm -e --nodeps jdk_
# 卸载完毕后即可安装jdk
# rpm -ivh rpm包
# 配置环境变量!

如果存在可以提前卸载:

安装:

配置环境变量: /etc/profile 在文件的最后面增加java的配置和 window安装环境变量一样!

JAVA_HOME=/usr/java/jdk1.8.0_221-amd64
CLASSPATH=%JAVA_HOME%/lib;%JAVA_HOME%/jre/lib
#PATH=$JAVA_HOME/bin;$JAVA_HOME/jre/bin   这行和下面的PATH不需要
export PATH CLASSPATH JAVA_HOME

让这个配置文件生效! source /etc/profile 我们来发布一个项目试试!

# 开启防火墙端口

firewall-cmd --zone=public --add-port=9000/tcp --permanent

# 重启防火墙

systemctl restart firewalld.service

# 查看所有开启的端口,如果是阿里云,需要配置安全组规则!

firewall-cmd --list-ports

5.2、Tomcat 安装

ssm war 就需要放到tomcat 中运行!

1、下载tomcat。官网下载即可 tomcat9 apache-tomcat-9.0.22.tar.gz

2、解压这个文件

tar -zxvf apache-tomcat-9.0.22.tar.gz

3、启动tomcat测试! ./xxx.sh 脚本即可运行

# 执行 ./startup.sh
# 停止 ./shotdown.sh

如果防火墙8080 端口开了并且阿里云安全组也开放了这个时候就可以直接访问远程了!

# 查看firewall服务状态

systemctl status firewalld

# 开启、重启、关闭、firewalld.service服务

# 开启

service firewalld start

# 重启

service firewalld restart

# 关闭

service firewalld stop

# 查看防火墙规则

firewall-cmd --list-all # 查看全部信息
firewall-cmd --list-ports # 只看端口信息

# 开启端口

开端口命令:firewall-cmd --zone=public --add-port=8080/tcp --permanent
重启防火墙:systemctl restart firewalld.service
命令含义:
--zone #作用域
--add-port=80/tcp #添加端口,格式为:端口/通讯协议

--permanent #永久生效,没有此参数重启后失效

上传完毕的项目直接购买自己的域名,备案解析过去即可!1年级都会做!

域名解析后,如果端口是80 - http 或者 443-https 可以直接访问,如果是 9000 8080,就需要通过Apcahe或者Nginx做一下反向代理即可,配置文件即可,十分之简单,大家如果想要上线自己的网站,到目前为止,那么你可以如愿以偿了!

5.3、Docker(yum安装)

联网的情况下 yum install -y yum 源

官网安装参考手册:[https://docs.docker.com/engine/install/centos/]

我们现在是在Linu下执行,一定要联网 ,yum 在线安装!

  1. 检测CentOS 7

    [root@root home]# cat /etc/redhat-release
    CentOS Linux release 7.9.2009 (Core)
    
  2. 云安装gcc相关

    yum -y install gcc
    yum -y install gcc-c++
    
  3. 卸载旧版本

    yum -y remove docker docker-common docker-selinux docker-engine
    # 官网版本
    yum remove docker \
                docker-client \
                docker-client-latest \
                docker-common \
                docker-latest \
                docker-latest-logrotate \
                docker-logrotate \
                docker-engine
    
  4. 安装需要的软件包

    yum install -y yum-utils device-mapper-persistent-data lvm2
    
  5. 设置stable镜像仓库

    # 错误
    yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    ## 报错
    [Errno 14] curl#35 - TCP connection reset by peer
    [Errno 12] curl#35 - Timeout
     
    # 正确推荐使用国内的
    yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
    
  6. 更新yum软件包索引

    yum makecache fast
    
  7. 安装Docker CE

    yum -y install docker-ce docker-ce-cli containerd.io
    
  8. 启动docker

    systemctl start docker
    
  9. 测试

    docker version
     
    docker run hello-world
    

宝塔面板安装:【【狂神说Java】服务器购买及宝塔部署环境说明】https://www.bilibili.com/video/BV177411K7bH?vd_source=fc3cd85ae71adf3029479673754f6dff

docker-engine

官网版本

yum remove docker
docker-client
docker-client-latest
docker-common
docker-latest
docker-latest-logrotate
docker-logrotate
docker-engine




4. 安装需要的软件包

```bash
yum install -y yum-utils device-mapper-persistent-data lvm2
```

5. 设置stable镜像仓库

```bash
# 错误
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
## 报错
[Errno 14] curl#35 - TCP connection reset by peer
[Errno 12] curl#35 - Timeout
 
# 正确推荐使用国内的
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
```

6. 更新yum软件包索引

```bash
yum makecache fast
```

7. 安装Docker CE

```bash
yum -y install docker-ce docker-ce-cli containerd.io
```

8. 启动docker

```dockerfile
systemctl start docker
```

9. 测试

```dockerfile
docker version
 
docker run hello-world
```





宝塔面板安装:【【狂神说Java】服务器购买及宝塔部署环境说明】https://www.bilibili.com/video/BV177411K7bH?vd_source=fc3cd85ae71adf3029479673754f6dff

Guess you like

Origin blog.csdn.net/qq_44624801/article/details/130019571