一、更新base-repo源
使用国内的阿里云镜像
(1)把/etc/yum.repos.d/下面所有的源给删除掉了
(2)下载镜像
# CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
# CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
# CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# CentOS 8
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
注意如果没有安装wget,可以从下面的网址中先手动下载,通过vi命令保存到文件中:
a. 备份源文件
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
b.打开默认更新源CentOS-Base.repo
vi /etc/yum.repos.d/CentOS-Base.repo
c.清空内容
按下ESC后进入命令模式后输入
:.,$d
d.复制下载文件内容并粘贴到编辑器中
f.保存
按下ESC后进入命令模式后输入
:wq
(3)执行命令,重新生成cache
yum clean all
rm -rf /var/cache/yum/
yum makecache
参考:http://blog.chinaunix.net/uid-31410005-id-5788149.html
二、提示Failed to set locale, defaulting to C.UTF-8
执行命令
yum install glibc-langpack-en
参考:https://blog.csdn.net/zhujing16/article/details/107502403
三、提示Repository base is listed more than once in the configuration
执行命令
yum update
不行参考【https://blog.csdn.net/wy_bk/article/details/89648052】进行多余文件删除
四、提示service: command not found
在centos系统中,如果/sbin目录下没有service这个命令,就会出现
bash: service: command not found
解决步骤如下:
1、 输入
yum list | grep initscripts
会出现:
initscripts.x86_64
(其实一共有三个信息,但是后面根据版本不同,显示的信息也不同)
2、 上面给出了可安装软件的yum源版本,然后执行
yum install initscripts -y
3、 此时service命令就可用了
参考:https://blog.csdn.net/qq_14847537/article/details/78400333
五、开启ssh
wsl 通过systemctl 启动没用
在已经安装过ssh 的情况下执行命令
# /usr/sbin/sshd-keygen -A
/usr/sbin/ssh-keygen -A
nohup /usr/sbin/sshd -D &
将写好的脚本(.sh文件)放到目录 /etc/profile.d/ 下,系统启动后就会自动执行该目录下的所有shell脚本 (账号登录一次就执行)
六、提示密码太简单
使用命令强制修改
#其中password代表需要修改的新密码
echo 'password'|passwd --stdin root