惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
Google DeepMind News
Google DeepMind News
V
V2EX
B
Blog RSS Feed
有赞技术团队
有赞技术团队
博客园 - Franky
美团技术团队
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
腾讯CDC
云风的 BLOG
云风的 BLOG
L
LangChain Blog
GbyAI
GbyAI
The Cloudflare Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
C
Check Point Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Stack Overflow Blog
Stack Overflow Blog
博客园 - 【当耐特】
The Register - Security
The Register - Security
大猫的无限游戏
大猫的无限游戏
D
Docker
Vercel News
Vercel News
Blog — PlanetScale
Blog — PlanetScale
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 司徒正美
人人都是产品经理
人人都是产品经理
雷峰网
雷峰网
阮一峰的网络日志
阮一峰的网络日志
P
Proofpoint News Feed
N
Netflix TechBlog - Medium
博客园_首页
A
About on SuperTechFans
J
Java Code Geeks
量子位
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
MongoDB | Blog
MongoDB | Blog
Recent Announcements
Recent Announcements
G
Google Developers Blog
小众软件
小众软件
博客园 - 叶小钗
WordPress大学
WordPress大学
博客园 - 聂微东
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
F
Full Disclosure
Jina AI
Jina AI
H
Help Net Security

噜啦 - centos

CentOS 手动升级/安装内核 - 噜啦 Centos 更换为163/阿里云源 - 噜啦 Centos6 安装Python2.7.6 - 噜啦 CentOS 6、7 一键更换内核安装锐速 - 噜啦
Centos 添加用户并授予root权限 - 噜啦
博主: 噜啦 · 2019-02-07 · via 噜啦 - centos
  • 发布时间:
  • 2177 次浏览
  • 991字数
  • 分类: Linux笔记本
  1. 首页
  2. 正文  

使用root权限并不安全,接下来写一下为 Centos 添加用户并授予其 root 权限的方法,记录一下,以免忘记

禁止ROOT账号登陆

vi /etc/ssh/sshd.conf

找到

PermitRootLogin no

将其改为no

没有的话添加这一行



添加用户

adduser xxx (添加用户名为xxx的用户)
passwd xxx (为xxx设置密码)

授予ROOT权限

修改 /etc/passwd 文件,把用户ID修改为 0 ,命令如下:

vi  /etc/passwd 

找到

root:x:0:0:root:/root:/bin/bash

按照格式添加:

666:x:0:500:250:/home/666:/bin/bash

其中:

666代表用户名
x表示密码,但是这里不显示,已经放到shadow
第一个0,表示用户id,后一个表示用户组id
后面哪个250是对该用户的描述,可以乱写,哈哈
/root表示用户目录,新添加的用户位于/home/用户名
/bin/bash表示该用户登录linux时用的shell。

将 sudoers 文件的权限设置为可写,默认为只读

chmod -v u+w /etc/sudoers
vi /etc/sudoers

找到

## Allow root to run any commands anywhere
root    ALL=(ALL)       ALL

按格式添加:

xxx    ALL=(ALL)       ALL 

xxx为你添加的用户名
保存,退出
删除 sudoers 的可写权限

chmod -v u-w /etc/sudoers

使用666账号登陆,在命令前加 sudo 就是使用root权限了

赞赏作者

如果觉得我的文章对你有用,请随意赞赏

Centos 添加用户并授予root权限

 •