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

推荐订阅源

博客园 - 【当耐特】
Help Net Security
Help Net Security
P
Proofpoint News Feed
J
Java Code Geeks
爱范儿
爱范儿
Last Week in AI
Last Week in AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
F
Full Disclosure
Google DeepMind News
Google DeepMind News
H
Help Net Security
G
Google Developers Blog
Jina AI
Jina AI
Vercel News
Vercel News
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
L
Lohrmann on Cybersecurity
S
Schneier on Security
Microsoft Azure Blog
Microsoft Azure Blog
IT之家
IT之家
Security Archives - TechRepublic
Security Archives - TechRepublic
阮一峰的网络日志
阮一峰的网络日志
N
News and Events Feed by Topic
GbyAI
GbyAI
B
Blog
O
OpenAI News
博客园_首页
Cisco Talos Blog
Cisco Talos Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Hacker News: Ask HN
Hacker News: Ask HN
TaoSecurity Blog
TaoSecurity Blog
腾讯CDC
MongoDB | Blog
MongoDB | Blog
M
MIT News - Artificial intelligence
C
Cybersecurity and Infrastructure Security Agency CISA
Cyberwarzone
Cyberwarzone
Webroot Blog
Webroot Blog
Simon Willison's Weblog
Simon Willison's Weblog
Y
Y Combinator Blog
C
Cisco Blogs
A
Arctic Wolf
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Exploit Database - CXSecurity.com
Security Latest
Security Latest
AI
AI
W
WeLiveSecurity
aimingoo的专栏
aimingoo的专栏
The Register - Security
The Register - Security
Project Zero
Project Zero
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
Netflix TechBlog - Medium
Blog — PlanetScale
Blog — PlanetScale

噜啦 - linux

CentOS 6 安装 htop nload Linux脚本报错syntax error near unexpected token '$'\r'' CentOS 6、7 一键更换内核安装锐速 - 噜啦 Centos 修改SSH端口为其他端口 - 噜啦
Centos 添加用户并授予root权限 - 噜啦
博主: 噜啦 · 2019-02-07 · via 噜啦 - linux
  • 发布时间:
  • 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权限

 •