su命令 1 2 #su--c"touch/tmp/test.txt"user1 @当前用户是root使用user1的身份创建一个text.txt文件
su命令
1 2 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
sudo:让普通用户临时拥有root的权限去执行命令
1 |
|
找到##allow root to run any commands anywhere
增加一条:user2 ALL=(ALL) ALL
当然也可以自定义命令:
user2 ALL=(ALL) /usr/bin/ls,/usr/bin/mv,/usr/bin/cat
1 |
|
1 |
|
1 |
|
1 |
|
以及针对组,也可以进行一次性对组进行授权管理,然后把用户加入到某个组
限制root远程登录
1 |
|
输入“/” 输入root 查找
1 |
|
1 |
|
然后再次使用其它终端去连接就不可以登录
当然有时候我们是不允许直接让某个用户知道root的密码,但是还想着让他能切换到root下面执行命令!如何做呢?(慎重操作!!!)
1 2 |
|
1 2 |
|