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

推荐订阅源

WordPress大学
WordPress大学
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
Cloudbric
Cloudbric
P
Palo Alto Networks Blog
T
Threatpost
T
Tor Project blog
T
Tenable Blog
AWS News Blog
AWS News Blog
Project Zero
Project Zero
L
LangChain Blog
Cyberwarzone
Cyberwarzone
Engineering at Meta
Engineering at Meta
雷峰网
雷峰网
C
CERT Recently Published Vulnerability Notes
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Security Latest
Security Latest
云风的 BLOG
云风的 BLOG
I
Intezer
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
MongoDB | Blog
MongoDB | Blog
aimingoo的专栏
aimingoo的专栏
K
Kaspersky official blog
Jina AI
Jina AI
N
News | PayPal Newsroom
T
The Blog of Author Tim Ferriss
D
DataBreaches.Net
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
Recorded Future
Recorded Future
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Secure Thoughts
TaoSecurity Blog
TaoSecurity Blog
P
Privacy & Cybersecurity Law Blog
P
Proofpoint News Feed
MyScale Blog
MyScale Blog
IT之家
IT之家
Forbes - Security
Forbes - Security
The Hacker News
The Hacker News
Last Week in AI
Last Week in AI
T
Threat Research - Cisco Blogs
Y
Y Combinator Blog

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

 •