What is up with sudo--how come it never works?

Discussion in 'Jailbreaks and iOS Hacks' started by Riemann Zeta, Dec 9, 2008.

  1. Riemann Zeta macrumors 6502a

    Joined:
    Feb 12, 2008
    #1
    I did the JB protocol on my iPhone 3G, installed mobile terminal and all of the BSD layer, along with sudo. However, whenever I try to use a command with the form "sudo XXX -X" in terminal, I get an error. The system prompts for a password, to which I reply 'alpine' but then it fails, claiming that user "mobile" is not in the sudoers file. Comically, it then says that "this attempted illegal access incident will be reported" (I'm shaking in my boots of my iPhone logging my 'leet haX0ring skillz).

    The paradox here is that in order to add a user name to /etc/sudoers, one must be able to edit the file with sudo (sudo nano /etc/sudoers), which gets us to a catch-22. What gives? I don't really feel like messing with SSH, so is there any way of getting sudo to work using the mobile terminal alone?
     
  2. DUMBDOG macrumors newbie

    Joined:
    Oct 29, 2008
    #2
    I may be wrong but I think the command you have to use on mobile terminal is

    Code:
    su 
    and then enter your password. "alpine" by default. that gives me sudo access when using mobile terminal.
     
  3. longshotalpha macrumors newbie

    Joined:
    Jul 6, 2008
    #3
    You can think of sudo as a protection mechanism that allows you to run a single command as root while preventing you from staying logged in as root. There are two users on the iphone, "mobile" and "root". Both by default use alpine as password. If you want to use sudo, you will need to first log in as root , 'su -l root' and enter the default password, 'alpine'. You are now logged in as root and everything you do from now on will be as root. This can be bad especially if you walk away from your computer.

    Now add the following to the /etc/sudoers file using your favorite text editor (vi, nano, etc).

    'mobile ALL=(ALL) ALL'

    Save the file and exit out of root. Now the account 'mobile' can use the sudo command like 'sudo rm -r /.' J/k, don't do this command! However, I would recommend changing your default passwords so that someone doesn't screw with you.
     
  4. Riemann Zeta thread starter macrumors 6502a

    Joined:
    Feb 12, 2008
    #4
    Thanks, adding mobile to sudoers with that syntax worked perfectly--I can now use sudo from mobile instead of having to always logoff then login as root. Killer tip man. Thankfully I know enough unix not to go borking things with sudo rm -r / ;).
     

Share This Page