会发生什么,当我sudo的庆典-c? [英] What happens when I sudo bash -c?

查看:115
本文介绍了会发生什么,当我sudo的庆典-c?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 sudo的庆典-c'some_command将运行 some_command 具有相同的特权sudo的。

我很困惑,发生了什么?它是否在bash运行 some_command 作为须藤(同 sudo的庆典),然后再切换回我的当前用户?为什么我不能在bash的一个实例,就像我会当我运行留下了sudo的权限 sudo的庆典

我试着运行男人庆典,它描述了 -c 选项(下面引用)。
不过,我挣扎着一块介绍如何与运行时,我观察到的行为 sudo的庆典-c'some_command


  

如果有-c选项present,那么命令将从第一个非选项参数command_string读取。如果有参数之后
                   在command_string,他们被分配到的位置参数,以$ 0起始。



解决方案

须藤切换用户,然后执行庆典 ,它传递的其他参数。 庆典运行为新的用户运行后在参数命令 -c

I know that sudo bash -c 'some_command' will run some_command with the same privileges as sudo.

I'm confused as to what's happening? Does it run some_command in bash as sudo (same as sudo bash) then switch back to my current user? Why am I not left in an instance of bash with sudo privileges like I would when I run sudo bash?

I tried running man bash and it describes the -c option (quoted below). However, I am struggling to piece how the description relates to the behaviour I observed when running sudo bash -c 'some_command'

If the -c option is present, then commands are read from the first non-option argument command_string. If there are arguments after the command_string, they are assigned to the positional parameters, starting with $0.

解决方案

sudo switches users and then executes bash, passing it the other arguments. bash running as the new user runs the command in the argument after -c.

这篇关于会发生什么,当我sudo的庆典-c?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆