侧边栏壁纸
博主头像
Linux学习记录博主等级

我们因为好奇而所获得的一切,最终会因为骄傲而全然玷污

  • 累计撰写 45 篇文章
  • 累计创建 13 个标签
  • 累计收到 9 条评论

目 录CONTENT

文章目录

从WSL入门LINUX:一、SHELL脚本自动换源

Frank
2020-07-09 / 0 评论 / 0 点赞 / 3 阅读 / 2071 字

1、创建并编辑脚本文件(个人比较顺手nano,vim不会用)

nano updatesrc.sh

2、脚本内容如下:(脚本为阿里源,版本ubuntu20.04,其他源替换即可)

#! /bin/bash

cp /etc/apt/sources.list /etc/apt/sources.list.bak

echo #阿里云源 > /etc/apt/sources.list

echo deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse >> /etc/apt/sources.list

echo deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse >> /etc/apt/sources.list

echo deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse >> /etc/apt/sources.list

echo deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse >> /etc/apt/sources.list

echo deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse >> /etc/apt/sources.list

echo deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse >> /etc/apt/sources.list

echo deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse >> /etc/apt/sources.list

echo deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse >> /etc/apt/sources.list

echo deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse >> /etc/apt/sources.list

echo deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse >> /etc/apt/sources.list
apt update

apt upgrade

PS:> 代表覆盖文件内容并新增;

>>代表追加到尾部。

因为脚本后面带有更新,所以稍等片刻等待执行完毕,中途会需要按Y确认。

3、赋予脚本执行权限:

chmod +x updatesrc.sh

PS:有关LINUX执行脚本区别参考:https://blog.csdn.net/u012336923/article/details/50474692

4、执行脚本:(以管理员方式执行)

sudo ./updatesrc.sh

0

评论区