CentOS 7中添加一个新用户并授权
来源:互联网 发布:pua倪网络课程 百度云 编辑:程序博客网 时间:2024/06/05 15:08
创建新用户
创建一个用户名为:linuxidc
[root@localhost ~]# adduser linuxidc
为这个用户初始化密码,linux会判断密码复杂度,不过可以强行忽略:
[root@localhost ~]# passwd linuxidc更改用户 zhangbiao 的密码 。新的 密码:无效的密码: 密码未通过字典检查 - 过于简单化/系统化重新输入新的 密码:passwd:所有的身份验证令牌已经成功更新。
授权
个人用户的权限只可以在本home下有完整权限,其他目录要看别人授权。而经常需要root用户的权限,这时候sudo可以化身为root来操作。我记得我曾经sudo创建了文件,然后发现自己并没有读写权限,因为查看权限是root创建的。
新创建的用户并不能使用sudo命令,需要给他添加授权。
sudo命令的授权管理是在sudoers文件里的。可以看看sudoers:
[root@localhost ~]# sudoersbash: sudoers: 未找到命令...[root@localhost ~]# whereis sudoerssudoers: /etc/sudoers /etc/sudoers.d /usr/libexec/sudoers.so /usr/share/man/man5/sudoers.5.gz
找到这个文件位置之后再查看权限:
[root@localhost ~]# ls -l /etc/sudoers-r--r----- 1 root root 4251 9月 25 15:08 /etc/sudoers
是的,只有只读的权限,如果想要修改的话,需要先添加w权限:
[root@localhost ~]# chmod -v u+w /etc/sudoersmode of "/etc/sudoers" changed from 0440 (r--r-----) to 0640 (rw-r-----)
然后就可以添加内容了,在下面的一行下追加新增的用户:
[root@localhost ~]# vim /etc/sudoers## Allow root to run any commands anywher root ALL=(ALL) ALL linuxidc ALL=(ALL) ALL #这个是新增的用户
wq保存退出,这时候要记得将写权限收回:
[root@localhost ~]# chmod -v u-w /etc/sudoersmode of "/etc/sudoers" changed from 0640 (rw-r-----) to 0440 (r--r-----)
这时候使用新用户登录,使用sudo:
[linuxidc@localhost ~]$ sudo cat /etc/passwd[sudo] password for linuxidc: We trust you have received the usual lecture from the local SystemAdministrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility.
第一次使用会提示你,你已经化身超人,身负责任。而且需要输入密码才可以下一步。如果不想需要输入密码怎么办,将最后一个ALL修改成NOPASSWD: ALL。
转自:http://blog.csdn.net/ggxiaobai/article/details/53504989
阅读全文
0 0
- CentOS 7中添加一个新用户并授权
- CentOS 7中添加一个新用户并授权
- 在centos 中添加一个新用户,并授权
- CentOS 7中创建新用户并授权
- [Linux学习--用户管理]centos中添加一个新用户,并授权
- CentOS 添加新用户并授权Root权限
- 在centos7中添加一个新用户,并授权
- 在centos7中添加一个新用户,并授权
- 在centos7中添加一个新用户,并授权
- Oracle 创建新用户,并授权
- mysql创建新用户并授权
- sql 创建新用户并授权
- Oracle 创建新用户,并授权
- mysql 创建新用户并授权
- Centos 建立一个新用户
- Ubuntu中给mysql添加新用户并分配权限
- Ubuntu 中创建新用户并添加 sudo 权限
- mysql开辟新用户并授权相应权限
- Interecting Lines
- poj1463 Strategic game(树形dp)
- 日常问题总结 三
- 46-从1加到n 不用乘除和循环语句
- 【CPE】外接话机基本通话及第三方通话状态机处理流程
- CentOS 7中添加一个新用户并授权
- Kotlin-49.JavaScript模块(JavaScript Module)
- 4412驱动实验之04 Makefile 编译
- 今天太晚了 明天开始写
- Openwrt.wifi.脚本分析之/sbin/wifi
- java多线程相关
- github使用
- linux用户空间与内核空间—高端内存详解
- 安装Scala-2.11.7——集群学习日记