为普通用户添加root权限

普通用户的权限低得可怜,直接用root用户又危险,为普通用户添加root权限就显得很重要了。在这里用户为:yunge

  1. 切换到root用户
su

su命令切换到root用户,否则修改不了配置文件。

2.进入/etc/sudoers文件

visudo  或者  vim /etc/sudoers

命令visudo就是vim /etc/sudoers的缩写。

3.修改/etc/sudoers文件

这一步有点复杂。

(1)显示行号

首先按: [Shift]+: 进入命令模式,输入:set nu,再按[Enter]确认。

(2)调到大概91行

在键盘上按:91,再按[Shift]+g,切换到91行:root ALL=(ALL) ALL

centos7 配置atguigu用户具有root权限 centos 设置root账户_centos


(3)复制张贴修改

按:yy,再按:p

centos7 配置atguigu用户具有root权限 centos 设置root账户_root权限_02


按:i 修改:

centos7 配置atguigu用户具有root权限 centos 设置root账户_root权限_03

4.退出
按: [Shift]+ : ,输入:wq,再按:[enter]

为普通用户添加root权限。

更换yum源

刚装好的yum源是国外的,下载速度慢,内容少。将yum源更换为国内的很有必要,在这里选择163的yum源作为范例。

  1. 备份
    yum源配置文件为:/etc/yum.repos.d/CentOS-Base.repo
cd /etc/yum.repos.d
mv CentOS-Base.repo CentOS-Base.repo.backup

2.利用wegt下载yum源
当前目录还是:/etc/yum.repos.d

wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

3.运行yum makecache生成缓存

yum makecache

说明:yum makecache 是 将服务器上的软件包信息 现在本地缓存,以提高 搜索 安装软件的速度。

4.更新系统

yum -y update

到此就可以看到速度飞快啦。

系统防火墙配置

对于新手玩centos,暂时关闭防火墙可以减少一些不必要的麻烦。centos7中的防火墙是:firewalld

  1. 查看
    systemctl status firewalld.service
    或者service firewalld status
    (说明 systemctl 和service 是服务管理器,status是查看的意思)
    结果为:
  2. centos7 配置atguigu用户具有root权限 centos 设置root账户_root权限_04

  3. 关闭firewalld
service firewalld stop   或者
systemctl stop firewalld.service

上面命令只能关闭当前登陆的firewalld,重启后还是自启动的。下面是关闭自启动命令。

systemctl disable firewalld.service

查看firewalld是否自启动

systemctl is-enabled firewalld.service

结果为:disable

系统SELinux设置

SELinux为安全访问系统,对于普通用户完全是透明的,只有系统管理员才需要考虑。为了学习方便,关闭为好。

  1. 查看SELinux状态
sestatus|grep SELinux

结果:

centos7 配置atguigu用户具有root权限 centos 设置root账户_centos_05

2.关闭SELinux
SELinux配置文件:/etc/selinux/config

在root用户下执行下面命令:

vim /etc/selinux/config

下面即为文件内容:

centos7 配置atguigu用户具有root权限 centos 设置root账户_yum源_06


按:i,vim由一般模式进入编辑(插入)模式,将

SELINUX=enforcing 改为:SELINUX=disabled

基础环境修改就这样啦。