【WSL2】CENTOS7 安装与配置

该博客记录了在CentOS7系统中如何更换为阿里云YUM源,备份并恢复源文件,安装EPEL仓库,以及安装SSH和Git的过程。在尝试使用阿里云源时遇到网络问题,最终换回原有源。同时,展示了系统内核版本和执行一些基础命令的状态。
摘要由CSDN通过智能技术生成

centos7 管理员运行

在这里插入图片描述

解压缩 vhdx

-在这里插入图片描述

centos 7

在这里插入图片描述

[root@LAPTOP-DFV9CMRA ~]# uname -a
Linux LAPTOP-DFV9CMRA 5.15.57.1-microsoft-standard-WSL2 #1 SMP Wed Jul 27 02:20:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
[root@LAPTOP-DFV9CMRA ~]#

yum repolist 查看源列表:

[root@LAPTOP-DFV9CMRA ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.bupt.edu.cn
 * extras: mirrors.bupt.edu.cn
 * updates: mirrors.bupt.edu.cn
base                                                                                             | 3.6 kB  00:00:00
extras                                                                                           | 2.9 kB  00:00:00
updates                                                                                          | 2.9 kB  00:00:00
(1/4): base/7/x86_64/group_gz                                                                    | 153 kB  00:00:00
(2/4): extras/7/x86_64/primary_db                                                                | 250 kB  00:00:00
(3/4): base/7/x86_64/primary_db                                                                  | 6.1 MB  00:00:02
(4/4): updates/7/x86_64/primary_db                                                               |  17 MB  00:00:36
repo id                                                 repo name                                                 status
base/7/x86_64                                           CentOS-7 - Base                                           10,072
extras/7/x86_64                                         CentOS-7 - Extras                                            516
updates/7/x86_64                                        CentOS-7 - Updates                                         4,156
repolist: 14,744
[root@LAPTOP-DFV9CMRA ~]#

执行命令备份源

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

替换阿里源

[root@LAPTOP-DFV9CMRA ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
[root@LAPTOP-DFV9CMRA ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2523  100  2523    0     0  21906      0 --:--:-- --:--:-- --:--:-- 21939
[root@LAPTOP-DFV9CMRA ~]#

重建缓存,感觉阿里云的地址更慢啊。

[root@LAPTOP-DFV9CMRA ~]# yum makecache
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                             | 3.6 kB  00:00:00
extras                                                                                           | 2.9 kB  00:00:00
updates                                                                                          | 2.9 kB  00:00:00
(1/6): extras/7/x86_64/filelists_db                                                              | 277 kB  00:00:09
base/7/x86_64/other_db         FAILED                                                 ] 130 kB/s | 3.1 MB  00:02:18 ETA
http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/ecaab5cc3b9c10fefe6be2ecbf6f9fcb437231dac3e82cab8d9d2cf70e99644d-other.sqlite.bz2: [Errno 14] curl#7 - "Failed to connect to 2401:b180:4100::2: Network is unreachable"
Trying other mirror.
extras/7/x86_64/other_db       FAILED
http://mirrors.aliyuncs.com/centos/7/extras/x86_64/repodata/5ed35184b6160999eff67a1ce6f909e9c507535aafeea94489e2bc7a23bc9fd5-other.sqlite.bz2: [Errno 14] curl#7 - "Failed to connect to 2401:b180:4100::2: Network is unreachable"
Trying other mirror.
base/7/x86_64/other_db         FAILED
http://mirrors.cloud.aliyuncs.com/centos/7/os/x86_64/repodata/ecaab5cc3b9c10fefe6be2ecbf6f9fcb437231dac3e82cab8d9d2cf70e99644d-other.sqlite.bz2: [Errno 14] curl#6 - "Could not resolve host: mirrors.cloud.aliyuncs.com; Unknown error"
Trying other mirror.
(2/6): extras/7/x86_64/other_db                                                                  | 149 kB  00:00:01
updates/7/x86_64/other_db      FAILED                                                 ] 198 kB/s | 5.0 MB  00:01:20 ETA
http://mirrors.aliyuncs.com/centos/7/updates/x86_64/repodata/46ffde52a82e78929ad08ae00ca7ea499be798e2ed9d46236d970d93febd9bef-other.sqlite.bz2: [Errno 14] curl#7 - "Failed to connect to 2401:b180:4100::2: Network is unreachable"
Trying other mirror.
(3/6): updates/7/x86_64/other_db                                                                 | 1.1 MB  00:00:18
(4/6): base/7/x86_64/other_db                                                                    | 2.6 MB  00:00:32
(5/6): base/7/x86_64/filelists_db                                                                | 7.2 MB  00:02:11
(6/6): updates/7/x86_64/filelists_db                                                             | 9.4 MB  00:03:14
Metadata Cache Created
[root@LAPTOP-DFV9CMRA ~]#
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup.aliyun

换回来

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

[root@LAPTOP-DFV9CMRA ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup.aliyun
[root@LAPTOP-DFV9CMRA ~]# mv /etc/yum.repos.d/CentOS-Base.repo.backup /etc/yum.repos.d/CentOS-Base.repo
[root@LAPTOP-DFV9CMRA ~]# yum makecache
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.bupt.edu.cn
 * extras: mirrors.bupt.edu.cn
 * updates: mirrors.bupt.edu.cn
base                                                                                             | 3.6 kB  00:00:00
extras                                                                                           | 2.9 kB  00:00:00
updates                                                                                          | 2.9 kB  00:00:00
Metadata Cache Created
[root@LAPTOP-DFV9CMRA ~]#
[root@LAPTOP-DFV9CMRA ~]#  yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.njupt.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
repo id                                                 repo name                                                 status
base/7/x86_64                                           CentOS-7 - Base                                           10,072
extras/7/x86_64                                         CentOS-7 - Extras                                            516
updates/7/x86_64                                        CentOS-7 - Updates                                         4,156
repolist: 14,744
[root@LAPTOP-DFV9CMRA ~]#

yum install epel-release -y

[root@LAPTOP-DFV9CMRA ~]# yum install epel-release -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.sjtu.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
 Package                          Arch                       Version                   Repository                  Size
========================================================================================================================
Installing:
 epel-release                     noarch                     7-11                      extras                      15 k

Transaction Summary
========================================================================================================================
Install  1 Package

Total download size: 15 k
Installed size: 24 k
Downloading packages:
warning: /var/cache/yum/x86_64/7/extras/packages/epel-release-7-11.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for epel-release-7-11.noarch.rpm is not installed
epel-release-7-11.noarch.rpm                                                                     |  15 kB  00:00:00
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-9.2009.0.el7.centos.x86_64 (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : epel-release-7-11.noarch                                                                             1/1
  Verifying  : epel-release-7-11.noarch                                                                             1/1

Installed:
  epel-release.noarch 0:7-11

Complete!
[root@LAPTOP-DFV9CMRA ~]#

yum list | grep epel-release

[root@LAPTOP-DFV9CMRA ~]# yum list | grep epel-release
epel-release.noarch                      7-11                          @extras
epel-release.noarch                      7-14                          epel
[root@LAPTOP-DFV9CMRA ~]#

内核

[root@LAPTOP-DFV9CMRA ~]# uname -r
5.15.57.1-microsoft-standard-WSL2
[root@LAPTOP-DFV9CMRA ~]#

git

yum install git -y

在这里插入图片描述

yum install psmisc 【 安装killall命令】

在这里插入图片描述

make

yum -y install gcc automake autoconf libtool make

在这里插入图片描述

安装g++

yum install gcc gcc-c++ pcre pcre-devel openssl openssl-devel bzip2 -y

在这里插入图片描述

PCRE

cd /usr/local/src
wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
tar -zxvf pcre-8.43.tar.gz
cd pcre-8.43/
./configure
make && make install

ssh

yum install openssh-server openssh


在这里插入图片描述

cat /etc/ssh/sshd_config

#port --代表端口号

#permitRootLogin --允许root用户登录

[root@LAPTOP-DFV9CMRA ~]#
[root@LAPTOP-DFV9CMRA ~]# ls
anaconda-ks.cfg  original-ks.cfg
[root@LAPTOP-DFV9CMRA ~]# ls
anaconda-ks.cfg  original-ks.cfg
[root@LAPTOP-DFV9CMRA ~]# cat /etc/ssh/sshd_config
#       $OpenBSD: sshd_config,v 1.100 2016/08/15 12:32:04 naddy Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/bin:/usr/bin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

# If you want to change the port on a SELinux system, you have to tell
# SELinux about this change.
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key

# Ciphers and keying
#RekeyLimit default none

# Logging
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#PubkeyAuthentication yes

# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile      .ssh/authorized_keys

#AuthorizedPrincipalsFile none

#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PasswordAuthentication yes

# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
#KerberosUseKuserok yes

# GSSAPI options
GSSAPIAuthentication yes
GSSAPICleanupCredentials no
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
#GSSAPIEnablek5users no

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
# WARNING: 'UsePAM no' is not supported in Red Hat Enterprise Linux and may cause several
# problems.
UsePAM yes

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation sandbox
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#ShowPatchLevel no
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path
#Banner none

# Accept locale-related environment variables
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS

# override default of no subsystems
Subsystem       sftp    /usr/libexec/openssh/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
#       X11Forwarding no
#       AllowTcpForwarding no
#       PermitTTY no
#       ForceCommand cvs server
[root@LAPTOP-DFV9CMRA ~]#

wscp

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

等风来不如迎风去

你的鼓励是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值