Linux 之疑难杂症

简单记录一些 linux 常见问题及其解决办法

1. xxx is not in the sudoers file. This incident will be reported

该用户不在 sudo 用户组内,无法执行 sudo 命令且此操作将被记录

解决办法:

  1. 使用 visudo 编辑 sudo 配置文件

  2. 找到该行:

     root ALL=(ALL) ALL
    
  3. 在改行下插入新行, 为指定用户授予权限:

     xxx  ALL=(ALL) ALL
    
  4. 保存并退出即可生效

2. 配置 Ali 软件源

2.1 Ubuntu

  1. 备份

     sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
    
  2. 修改软件源文件

     sudo vim /etc/apt/sources.list
    
  3. 修改内容为:

     ###### Ali source 20190909 ######
     deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
     deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
     deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
     deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
     deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
     deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
     deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
     deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
     deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
     deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
     #################################
    
  4. 试试是否生效,试试就逝世

     apt-get update
    

2.2 CentOS

1、改名备份原源文件

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

2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/

```bash
# 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
```

3、生成缓存,试试是否生效,试试就逝世

```bash
yum makecache
```
正在加载今日诗词....

Access Statistics

Table of Contents