centos创建子用户
2024-10-10 18:01:52
#adduser 用户名
#passwd 用户名
设置自己的密码即可
授权
个人用户的权限只可以在本home下有完整权限,其他目录要看别人授权。而经常需要root用户的权限,这时候sudo可以化身为root来操作。我记得我曾经sudo创建了文件,然后发现自己并没有读写权限,因为查看权限是root创建的。
新创建的用户并不能使用sudo命令,需要给他添加授权。
sudo命令的授权管理是在sudoers文件里的。可以看看sudoers:
[root@localhost ~]# sudoers
bash: sudoers: 未找到命令...
[root@localhost ~]# whereis sudoers
sudoers: /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/sudoers
mode 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/sudoers
mode 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 System
Administrator. 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
。
最新文章
- python 基础之数据类型
- asp.net“服务器应用程序不可用” 解决方法
- linux中Apache更Nginx环境配置教程
- Linux的网卡由eth0变成了eth1,如何修复 (转载)
- poj2月题解
- iOS 中UI控件的各种对齐方式总结
- CSS和CSS3中的伪元素和伪类(总结)
- 如何应对“改变现状”的失败";
- CodeSmith使用总结--下拉列表和文件夹对话框属性
- linux 查看某进程或程序的网卡流量(转)
- 顺序栈和链式栈(C++实现)
- MySQL 基础命令
- Linux 虚存的性能问题
- Hadoop大数据挖掘从入门到进阶实战
- JS--编码规范
- Tomcat中acceptCount,maxConnections、maxThreads的含义及关系
- oracle query
- 【Linux】Linux中Swap与Memory内存简单介绍
- feature map 大小以及反卷积的理解
- P2513 [HAOI2009]逆序对数列
热门文章
- SPOJ8222/NSUBSTR:Substrings——题解
- BZOJ2795/2890/3647 [Poi2012]A Horrible Poem 【字符串hash】
- bzoj 3673&;3674 可持久化并查集&;加强版(可持久化线段树+启发式合并)
- 如何让浏览器在访问链接时不要带上referer
- Java日期时间实用工具类
- bzoj 1132 [POI2008]Tro 几何
- 文件上传文件的权限--lnmp 环境配置,尤其整个项目复制过来动~~~
- 图论:最短路-SPFA
- 2015/9/5 Python基础(9):条件和循环
- [洛谷P1941] 飞扬的小鸟