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

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
T
Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
H
Hackread – Cybersecurity News, Data Breaches, AI and More
I
Intezer
C
Cyber Attacks, Cyber Crime and Cyber Security
The Register - Security
The Register - Security
量子位
Security Latest
Security Latest
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
C
CXSECURITY Database RSS Feed - CXSecurity.com
MyScale Blog
MyScale Blog
J
Java Code Geeks
Apple Machine Learning Research
Apple Machine Learning Research
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
Spread Privacy
Spread Privacy
Jina AI
Jina AI
博客园 - 【当耐特】
P
Palo Alto Networks Blog
Last Week in AI
Last Week in AI
SecWiki News
SecWiki News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
G
GRAHAM CLULEY
宝玉的分享
宝玉的分享
Hacker News - Newest:
Hacker News - Newest: "LLM"
T
The Blog of Author Tim Ferriss
V
Vulnerabilities – Threatpost
有赞技术团队
有赞技术团队
T
Tor Project blog
H
Hacker News: Front Page
A
Arctic Wolf
NISL@THU
NISL@THU
A
About on SuperTechFans
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
V
V2EX
N
News and Events Feed by Topic
Webroot Blog
Webroot Blog
Know Your Adversary
Know Your Adversary
P
Privacy International News Feed
I
InfoQ
D
Docker
L
LINUX DO - 最新话题
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
U
Unit 42

噜啦 - 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权限

 •