xcode 在越狱的 iPhone 上,如何以 root 身份运行命令?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8516370/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
On a jailbroken iPhone, how can I run commands as root?
提问by Adnan Siddiq
I want to login as a root using system
call in Xcode. I try this code without success:
我想使用system
Xcode 中的调用以root 身份登录。我尝试此代码但没有成功:
System("su");
System("alpine");
or
或者
System("su root");
System("alpine");
or
或者
System("su root alpine");
When I google it I came to know that this is done using NSTask
or NSPipe
.
Can anybody tell me how it possible to run multiple system
commands using NSTask
and NSPipe
?
当我谷歌它时,我开始知道这是使用NSTask
or完成的NSPipe
。谁能告诉我如何system
使用NSTask
and运行多个命令NSPipe
?
Please give me some hints about this or another method to do this. I am using this application on jailbroken iPhone.
请给我一些有关此方法或其他方法的提示。我在越狱的 iPhone 上使用这个应用程序。
Some more details are here.
更多细节在这里。
回答by Dimme
If you want to launch something as root you may use sudo
.
如果你想以 root 身份启动一些东西,你可以使用sudo
.
Example of it's usage in one line with the password:
它与密码在一行中的用法示例:
echo <password> | sudo -S <command>