Linux system installation and Centos7 configuration guide

Table of contents

1. Linux system installation

Two, centos7 environment configuration

1. Open the gateway and set a static IP

2. Modify the download source

3. vscode remote connection


1. Linux system installation

The Linux system mainly has two forms of cloud server and virtual machine to provide learning and use

  • Cloud server : charge (discount for students), simple and easy to use, can be used through Xshell connection or vscode remote connection
  • Virtual machine : free, relatively cumbersome to install, it is difficult to operate the Linux system directly through VMware, it is recommended to use vscode to remotely connect to the virtual machine

There are many versions of Linux system, the mainstream ones are ubuntu and centos

  • ubuntu : The graphical interface is better, but the terminal window is so-so, and the memory usage is larger
  • centos : You can choose a graphical interface or a black frame terminal window by yourself. The black frame terminal window occupies a small size but is inconvenient to operate. It is recommended to use a black frame and then use vscode to remotely connect and operate

The installation of VMware is directly on the official website, and the activation code can be easily found by Baidu. Pay attention to the version number of the corresponding software and activation code

I use centos7 for the Linux system, and I recommend centos (the image file size is much smaller than ubuntu), and the centos image file can also be downloaded from the official website

There are many tutorials on the Internet for VMware installation of virtual machines, so I won’t go into details. The memory of the virtual machine is recommended to be 4G, the disk size is recommended to be 40GB, and the connection method is personally recommended NAT connection

Two, centos7 environment configuration

1. Open the gateway and set a static IP

        After the centos7 virtual machine is installed, the gateway is closed by default, which means that it cannot connect to the Internet.

        So opening the centos gateway is a necessary step.

        The ip address of the virtual machine is divided into dynamic ip and static ip. The ip address of the dynamic ip will change randomly within a range every time it is turned on. The static ip will remain unchanged after setting. If you want to connect to the virtual machine remotely, it is recommended It is more convenient to set it as a static ip.

        For example, if you use vscode remote connection or database remote connection, if it is a dynamic ip, you have to re-modify the ip address every time you restart, and you cannot set secret-free operations, which is very troublesome

       Enter the command to open the network configuration file: vi /etc/sysconfig/network-scripts/ifcfg-ens33

        Restart the network card to update the configuration: service network restart

        View ip address: ip addr

2. Modify the download source

        The default download source of centos is foreign, the download speed is slow and sometimes it cannot be downloaded

        Domestic downloads include Tsinghuayuan, Aliyuan, and Huaweiyuan. These three are the best. I can’t judge which one is better.

        I’m using Aliyuan here. My idea is that I’m in Hangzhou and I’m close to Ali’s headquarters. I’ll use Aliyuan. Maybe the network speed will be faster.

        2.1 Install wget

yum list wget

yum -y install wget

        2.2 backup

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

        2.3 Download the yum source of Alibaba Cloud

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

        2.4 Clear cache

yum clean all

        2.5 Update local sources

yum makecache  

        2.6 View local sources

yum repolist

3. vscode remote connection

        3.1 vscode download Rmote-SSH plugin

        3.2 Configure config file

        Write the ip address of centos after HostName, and User is the user name, which can be a root user or an ordinary user

                 

         Save after the configuration is complete, click the arrow or create a new window for remote connection, enter the centos user password

        3.3 Set vscode password-free login

        If you do not set password-free login, you must enter login-free password every time you connect with vscode, which is very troublesome

        First find the user public key under the windows system

        Open the file id_rsa.pub with Notepad and copy the contents of the file

        Then the .ssh file in the centos system home directory: cd ~/.ssh

        Create a new file: touch authorized_keys

        Write the copied content in the id_rsa.pub file to the authorized_keys file, save and exit

        Modify authorized_keys file permissions: chomd 700 authorized_keys

        Vscode reconnects to centos remotely to complete the secret-free connection

        When the password-free login is successful, the vscode terminal will be this interface, click the + sign to create a new terminal window 

Guess you like

Origin blog.csdn.net/phoenixFlyzzz/article/details/129805499