Neurohazard
暮雲煙月,皓首窮經;森羅萬象,如是我聞。

CentOS 新建有 sudo 权限的用户

wpadmin~July 31, 2018 /System Management

CentOS create sudoer user

参考资料

centos create user with sudo privilege
https://www.digitalocean.com/community/tutorials/how-to-create-a-sudo-user-on-centos-quickstart

https://www.digitalocean.com/community/tutorials/how-to-edit-the-sudoers-file-on-ubuntu-and-centos

新建用户

1 假设新建的用户的名称为 username

adduser username
passwd username

2 使用 usermod 将该用户加入 wheel 工作组。

usermod -aG wheel username

3 测试该用户是否有 sudo 权限

su - username
sudo ls -al /root
sudo w

如果此时无法生效
可能需要修改 /etc/sudoers 文件,将 %wheel ALL=(ALL) ALL 前的注释标记去掉。
注意,修改该文件只能使用 visudo 命令。
使用其他方式打开编辑器可能导致系统出错并且无法再获取到 root 权限 (除非重装系统)。

配置网络开机自启动

sudo cat /etc/sysconfig/network-scripts/ifcfg-ens33
sudo vim /etc/sysconfig/network-scripts/ifcfg-ens33
#==========
ONBOOT=yes
#==========
sudo cat /etc/sysconfig/network-scripts/ifcfg-ens33

其他配置

其他工具

#
#
#
# 一些基本工具
wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -ivh epel-release-latest-7.noarch.rpm

sudo yum install -y net-tools
sudo yum install -y vim
sudo yum install -y lrzsz
sudo yum install -y unzip
sudo yum install -y gzip
sudo yum install -y tar
sudo yum install -y htop
sudo yum install -y mlocate
sudo updatedb
sudo yum install -y zsh
sudo yum install -y git
sudo yum install -y lsof
# oh-my-zsh
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
# ruby rvm
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
\curl -sSL https://get.rvm.io | bash -s stable
source /home/team/.rvm/scripts/rvm
# 测试 rvm 有效性
type rvm | head -n 1
# rvm 查看 可用的 ruby 版本
# https://rvm.io/rvm/install
rvm list known
rvm install ruby-2.5
rvm use 2.5
rvm use 2.5 --default
# docker
sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine
sudo yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2
sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install -y docker-ce
sudo systemctl start docker
sudo docker run hello-world
# Nmap
wget https://nmap.org/dist/nmap-7.70-1.x86_64.rpm
sudo rpm -ivh nmap-7.70-1.x86_64.rpm
sudo rpm -ivh https://nmap.org/dist/nmap-7.70-1.x86_64.rpm

Leave a Reply

Your email address will not be published. Required fields are marked *