Search code examples
iphonexcodebashjailbreakdpkg

Xcode - Passing Bash Commands With A Jailbroken Device


I'd like to know how it would be possible to execute bash commands on a jailbroken iOS device with Xcode? I'm not bothered about the code signing process because I already have a developer account.

I've tried using these 2 commands:

system("cd /var/mobile/Documents");
system("mkdir myNewFolder");

But Xcode returns "Cannot create directory, permission denied".

I know for definite that this is possible. Basically, I want to be using commands such as dpkg and apt commands.

Thanks in advance, Declan


Solution

  • In UNIX like OS's like iOS you can use the 'Sudo' command to run as root.

    To use in one line you need to use UNIX pipes like this:

    system("echo yourPassword | sudo -S yourCommand");

    You need to make sure sudo is installed on your device, not sure if it is by default.

    Some more info here: On a jailbroken iPhone, how can I run commands as root?