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

推荐订阅源

C
CXSECURITY Database RSS Feed - CXSecurity.com
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
博客园_首页
博客园 - 【当耐特】
小众软件
小众软件
A
About on SuperTechFans
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Martin Fowler
Martin Fowler
M
MIT News - Artificial intelligence
Vercel News
Vercel News
爱范儿
爱范儿
Google DeepMind News
Google DeepMind News
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
T
Threatpost
人人都是产品经理
人人都是产品经理
H
Help Net Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
L
LINUX DO - 热门话题
B
Blog
F
Full Disclosure
P
Proofpoint News Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
Threat Research - Cisco Blogs
L
LangChain Blog
博客园 - Franky
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Project Zero
Project Zero
I
InfoQ
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The Cloudflare Blog
V
Vulnerabilities – Threatpost
云风的 BLOG
云风的 BLOG
C
Cyber Attacks, Cyber Crime and Cyber Security
C
Check Point Blog
K
Kaspersky official blog
WordPress大学
WordPress大学
腾讯CDC
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Securelist
T
Tenable Blog
N
News and Events Feed by Topic
The GitHub Blog
The GitHub Blog
W
WeLiveSecurity
Stack Overflow Blog
Stack Overflow Blog
O
OpenAI News
Blog — PlanetScale
Blog — PlanetScale
量子位
Simon Willison's Weblog
Simon Willison's Weblog
T
Tor Project blog
P
Proofpoint News Feed

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

 •