新增用户、修改密码、修改用户权限

新增用户

[root@KVM-01 ~]# useradd test02
[root@KVM-01 ~]# passwd test02
Changing password for user test02.
New password:
BAD PASSWORD: The password fails the dictionary check - it is based on a dictionary word
Retype new password:
passwd: all authentication tokens updated successfully.

后面更改用户密码可以再次使用passwd+用户名修改用户密码

还有一种骚操作

root 模式下

[root@KVM-01 ~]# echo test02:123456|chpasswd

 给用户设置权限

正常情况下,非root用户只能对其home目录下有执行权限

[test02@KVM-01 home]$ ll
total 0
drwx------. 2 test test 83 Aug 25 00:25 test
drwx------. 2 test02 test02 102 Aug 25 09:10 test02
[test02@KVM-01 home]$

[test02@KVM-01 home]$ cd /root/
-bash: cd: /root/: Permission denied
[test02@KVM-01 home]$ umask
0002
[test02@KVM-01 home]$ 

为了让test02有权限,可以把test02加入到root所属组中解决,或者直接为test02设置特权

sudo的权限保存在sudoers中

[root@KVM-01 ~]# whereis sudoers
sudoers: /etc/sudoers /etc/sudoers.d /usr/share/man/man5/sudoers.5.gz
[root@KVM-01 ~]# ll /etc/sudoers
-r--r-----. 1 root root 4328 Nov 28 2019 /etc/sudoers  #没有可读权限,需要增加读权限
[root@KVM-01 ~]# chmod +w /etc/sudoers
[root@KVM-01 ~]# ll /etc/sudoers
-rw-r-----. 1 root root 4328 Nov 28 2019 /etc/sudoers

[root@KVM-01 ~]# vi /etc/sudoers

##
## The COMMANDS section may have other options added to it.
##
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
test02 ALL=(ALL) ALL

## Allows members of the 'sys' group to run networking, software,

 小彩蛋:

开机启用基础命令

[root@KVM-01 ~]# chkconfig libvirtd on
Note: Forwarding request to 'systemctl enable libvirtd.service'.

posted @   woshinidaye  阅读(698)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· Qt个人项目总结 —— MySQL数据库查询与断言
点击右上角即可分享
微信分享提示