Leo Zhang
菩提本无树,明镜亦非台!

 1) 备份原有镜像源文件

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

 

2) 下载阿里云镜像源文件

curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

# 或者使用wget(但需要预先安装yum -y install wget)

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

 

3) 重新生成缓存

yum clean all && yum makecache
 
# 根据需要选择是否更新软件
yum -y update

 

 


Linux使用root权限

1)普通用户免密切换root设置

a. 以root用户登录shell终端,执行 vim /etc/sudoers 命令,找到如下所示位置:
##Same thing without a password
# %wheel ALL=(ALL) NOPASSWD: ALL

 

b. 在下方添加一行类似的数据,例如用户名称为tempuser,则添加内容为:
tempuser ALL=(ALL) NOPASSWD: ALL

 

c. 保存之后,在普通用户下输入sudo -s命令就可以直接免密切换到root账户了
 

2)普通用户切换root方式

a.通过su - 命令,输入密码切换至root
b.直接使用 sudo + 命令 使用root权限
c. 通过sudo su命令无密切换至root
d. 通过sudo bash 命令切换至root
e. 当默认bash被限制了,我们可以通过先切换至sh,然后拷一份新的bash,这样就可以跳过限制了。
[wenruo@k8s-master ~]$ sudo sh
sh-4.2# cp /bin/bash /bin/bash2
sh-4.2# exit
exit
[wenruo@k8s-master ~]$ sudo bash2
[root@k8s-master wenruo]#

 

 

posted on 2022-09-07 10:30  LeoZhanggg  阅读(342)  评论(0编辑  收藏  举报