Linux—镜像源的设置修改

CentOS 镜像源的修改(yum镜像源)

https://www.cnblogs.com/Tsubasa0769/p/10728161.html

Ubuntu 镜像源的修改(apt-get镜像源)

1、备份一下 Ubuntu 原来的源地址列表文件。

ubuntu@VM-0-16-ubuntu:~$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.back

2、编辑替换 sources.list 源配置文件内容,当然需要超级权限,所以要加sudo。(阿里镜像源)

ubuntu@VM-0-16-ubuntu:~$ sudo vim /etc/apt/sources.list

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

3、修改完成后保存文件,并执行下列语句。

ubuntu@VM-0-16-ubuntu:~$ sudo apt-get update    # 更新软件列表
ubuntu@VM-0-16-ubuntu:~$ sudo apt-get upgrade   # 更新已安装的包

4、如果出现以下错误:是因为上一次更新源的时候非常规中断导致的,解决方法:sudo rm /var/lib/apt/lists/lock。

E: 无法获得锁 /var/lib/apt/lists/lock - open (11: 资源暂时不可用)
E: 无法对目录 /var/lib/apt/lists/ 加锁

5、查看新版本信息

其实Ubuntu18.04版之前的任一版更改apt源为国内源方法早就有了,内容大同小异,我们应当掌握其规律了,其实每一版内容不同的地方就是版本号(或者官方一点的说:系统代号),所以我们先了解下新版本的系统代号:

ubuntu@VM-0-16-ubuntu:~$ lsb_release -c          # Ubuntu18.04 的系统代号为bionic。

Ubuntu 16.04 (LTS)代号为xenial。Ubuntu 15.10 代号为wily。Ubuntu 15.04 代号为vivid。Ubuntu 14.04 (LTS)代号为trusty。Ubuntu 12.04 (LTS)代号为precise。

强制杀死占用指定端口的所有进程

1.可以用lsof查看占用端口的进程号。

[root@localhost ~]# lsof -i:端口号

2.然后用kill杀掉占用的进程,就可以再次启动server了。

[root@localhost ~]# kill -9 进程号

3.当然上述还是有些麻烦,因此可以用下面一条命令替代。

[root@localhost ~]# kill -9 $(lsof -i:端口号 -t)            # 方法1
[root@localhost ~]# kill -9 $(lsof -i tcp:端口号 -t)        # 方法2
[root@localhost ~]# fuser -k -n tcp 端口号                  # 方法3

  

运行yum报错:No module named yum

产生原因:yum基于python写的,根据报错信息提示,是yum的python版本对应不上目前python环境的版本导致的。也就是说 有人升级或者卸载了python。

解决方式:

# 查看yum版本
[root@localhost ~]# rpm -qa | grep yum

# 查看python版本 [root@localhost
~]# whereis python
# 查找yum文件,并编辑此py文件 [root@localhost
~]# which yum # 输出为/usr/bin/yum [root@localhost ~]# vi /usr/bin/yum
# 编辑此py文件 将 #
!/usr/bin/python 改成 #!/usr/bin/python2.6,保存即可。

参考:https://blog.csdn.net/zzq900503/article/details/79551715

posted @ 2019-09-11 11:11  刘_love_田  阅读(3567)  评论(0编辑  收藏  举报