maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Maemo 5 / Fremantle (https://talk.maemo.org/forumdisplay.php?f=40)
-   -   Root vs sudo gainroot (https://talk.maemo.org/showthread.php?t=68151)

mdziaf 2011-01-10 16:01

Root vs sudo gainroot
 
Hi there,

I am trying to root my friend's N900 to install preenv. The following describes the method I used and the problem I faced trying while trying to root the device.

1. I installed the rootsh application on the N900
2. Restarted the phone (don't know if it was necessary but did it anyways)
3. Opened XTerminal, and typed in
Code:

sudo gainroot
A password prompt was given. Tried typing "user" and 12345 and a few others but still wasn't right.

However, if I close and reopen Xterminal, and type in
Code:

root
no password prompt was given. but doing an apt-get install would give "unable to lock the admin directory"

I'm quite new to the linux world, but theres a few questions that is on my mind.
  • Shouldn't the rootsh remove the password prompt when sudo gainroot is typed?
  • Shouldn't the two codes (sudo gainroot) and (root) be the same?
  • Why does one asks for a password and the other doesn't?
  • Is the "Unable to lock the admin directory related to the fact that we weren't (in my definition) "fully rooted?



I also tried uninstalling rootsh through the app manager but it returned stating that rootsh was unable to uninstall. Any help and explanation is appreciated. Thanx :)


__
First thread, and 2nd post in forum :o, I hope I was clear about my query. I've also searched the forums, tried doing a
Code:

sudo passwrd root
, tried uninstalling rootsh, tried quite a few variety of password recommendations but to no avail.

ziggadebo 2011-01-10 16:12

Re: Root vs sudo gainroot
 
Quote:

Originally Posted by mdziaf (Post 916965)
Hi there,

I am trying to root my friend's N900

fnar fnar....sry very childish but always makes me laugh out loud.

michaaa62 2011-01-10 16:16

Re: Root vs sudo gainroot
 
Warning, wild guess ahead: Did you install some other root-enabling package like sudser, open-ssh or other before, so that sudo gets modified somehow to ask for a password?

funkmunk 2011-01-10 16:18

Re: Root vs sudo gainroot
 
@michaaa62

I probably feel he installed open ssh because that is the only one that asks for a password i think.

mdziaf 2011-01-10 16:20

Re: Root vs sudo gainroot
 
Quote:

Originally Posted by funkmunk (Post 916980)
@michaaa62

I probably feel he installed open ssh because that is the only one that asks for a password i think.

actually no..my girlfriend's N900 is new. Got it 3 days ago..

aligatro 2011-01-10 16:24

Re: Root vs sudo gainroot
 
try sudo su. And sudo gainroot only works when your phone is in RD mode.

Mentalist Traceur 2011-01-10 16:24

Re: Root vs sudo gainroot
 
I'm guessing he has that other root package already installed. I never get sudo gainroot asking for a password.

Either way, only difference is root puts you in the /root directory. You can probably just use "root", then run "passwd root" (without the sudo, since you'd be root already) that way.

But I wouldn't be doing that for another person's N900, unless they've made it very clear that they're okay with you doing it.

- Edit -

"sudo gainroot" works just fine without RD mode. Just installing rootsh enables it.

sjgadsby 2011-01-10 16:25

Re: Root vs sudo gainroot
 
Quote:

Originally Posted by aligatro (Post 916984)
try sudo su. And sudo gainroot only works when your phone is in RD mode.

Or if you install rootsh.

Quote:

Originally Posted by mdziaf (Post 916965)
1. I installed the rootsh application on the N900


mdziaf 2011-01-10 16:26

Re: Root vs sudo gainroot
 
Quote:

Originally Posted by aligatro (Post 916984)
try sudo su. And sudo gainroot only works when your phone is in RD mode.

okay will give that a shot.
just out of curiosity,what do you mean by the phone is in RD mode?

aligatro 2011-01-10 16:27

Re: Root vs sudo gainroot
 
Quote:

Originally Posted by mdziaf (Post 916988)
okay will give that a shot.
just out of curiosity,what do you mean by the phone is in RD mode?

Service mode. Or debugging mode

mdziaf 2011-01-10 16:31

Re: Root vs sudo gainroot
 
Quote:

Originally Posted by Mentalist Traceur (Post 916985)
I'm guessing he has that other root package already installed. I never get sudo gainroot asking for a password.

Either way, only difference is root puts you in the /root directory. You can probably just use "root", then run "passwd root" (without the sudo, since you'd be root already) that way.

But I wouldn't be doing that for another person's N900, unless they've made it very clear that they're okay with you doing it.

- Edit -

"sudo gainroot" works just fine without RD mode. Just installing rootsh enables it.

again, i doubt my girlfriend has any programs that requires root packages installed. She has only found out about Angry birds when I told her the day she got the phone (3days ago)...

I am also confused to why it is prompting a password..it didnt happen on my n900 when I did mine..

mdziaf 2011-01-10 16:35

Re: Root vs sudo gainroot
 
[QUOTE=Either way, only difference is root puts you in the /root directory. You can probably just use "root", then run "passwd root" (without the sudo, since you'd be root already) that way.
[/QUOTE]

so what you are saying is that if i typed in root and then passwd root, it should give me the same effect as typing in sudo gainroot?

im sorry if this is a stupid question, but if root just puts me to the root folder, then what does sudo gainroot actually do?

anapospastos 2011-01-10 16:37

Re: Root vs sudo gainroot
 
First type root. After you 're root type passwd root and change the root password.

mdziaf 2011-01-10 16:51

Re: Root vs sudo gainroot
 
Thank you for the suggestion. I will update you guys how it goes. the N900 in question has gone to sleep (its wayyyyy past midnight here now).

geneven 2011-01-10 17:11

Re: Root vs sudo gainroot
 
The command "root" just runs "sudo gainroot", last I heard.

If you type

cat /usr/bin/root in the terminal, you can see exactly what typing "root" does. Try it.

Error messages like "unable to lock the admin directory" often just mean that you have app mgr open in some other window and you've forgotten about it.

zimon 2011-01-10 17:19

Re: Root vs sudo gainroot
 
Quote:

Originally Posted by Mentalist Traceur (Post 916985)
Either way, only difference is root puts you in the /root directory. You can probably just use "root", then run "passwd root" (without the sudo, since you'd be root already) that way.

There are other differences also.
For example with "root" /root/.profile is run and you can for example have different $PATH than "normal" user.

Mentalist Traceur 2011-01-10 17:50

Re: Root vs sudo gainroot
 
Quote:

Originally Posted by mdziaf (Post 916999)
so what you are saying is that if i typed in root and then passwd root, it should give me the same effect as typing in sudo gainroot?

im sorry if this is a stupid question, but if root just puts me to the root folder, then what does sudo gainroot actually do?

I should've clarified.

Both "sudo gainroot" and "root" elevate that X-Terminal window to the root user. But, if you run "sudo gainroot", you become the root user, but you stay in the same directory you had terminal pointed to before.

So, say you type "cd /usr/bin". If you type "sudo gainroot", you will become the root user, and that X-Term window will still be in /usr/bin. However, if you instead type "root", it will make you root user, then it will do what zimon says (which I didn't know about), but it will change the directory you're in to "/root". So if you're in /usr/bin and type "sudo gainroot", the visible end result is you get root access, and the directory you're in is still /usr/bin. If you're in /usr/bin, and type "root", the visible end result (unless you have custom stuff in /root/.profile) is you end up in the folder /root, and get root access.

For this reason, I use "sudo gainroot", because I've never needed/wanted to fiddle with the $PATH settings to point me somewhere else, and if I'm gaining root access, I usually have already navigated to the directory I want to be in - which means having to renavigate there from /root is at least one more extra command. Whenever I need something in my path, I just move or symlink it into one of the four directories that are in the standard paths. (/bin, /sbin, /usr/bin, /usr/sbin), so it works out for me.

But it's a matter of personal preference. If there's something you can do more effectively by changing /root/.profile, then "root" is good for you.

Anyway, if you say she hasn't installed anything else herself that would give root access, I really don't know why sudo gainroot keeps asking for a password. It SHOULD be something you can edit in /etc/sudoers though...

Question, did you install rootsh from Extras? Or the one in Extras-Devel? (Both are almost the same, but have some key differences... which might be why you're having sudo gainroot ask for a password.) If you're not sure, see if you can run "rootsh passwd root", or "rootsh [other command requiring root permissions]". I believe that functionality was in the Extras version of rootsh, but was removed from the version that's in devel now.

anapospastos already answered the other part of your question. "root" will make you root user (while changing your directory to /root, which doesn't actually do anything other than possibly make you have to type a couple more cd commands or use different relative paths when running commands) [and runs the root/.profile, but that's irrelevant to this], and then passwd root will let you change the root password, without asking you for that password like "sudo" will.

FRuMMaGe 2011-01-10 17:57

Re: Root vs sudo gainroot
 
Quote:

Originally Posted by mdziaf (Post 916965)
However, if I close and reopen Xterminal, and type in
Code:

root
no password prompt was given. but doing an apt-get install would give "unable to lock the admin directory"

The lock error is because you still had app manager opened :)

mdziaf 2011-01-11 05:56

Re: Root vs sudo gainroot
 
Quote:

Originally Posted by Mentalist Traceur (Post 917058)
I should've clarified.

Both "sudo gainroot" and "root" elevate that X-Terminal window to the root user. But, if you run "sudo gainroot", you become the root user, but you stay in the same directory you had terminal pointed to before.

So, say you type "cd /usr/bin". If you type "sudo gainroot", you will become the root user, and that X-Term window will still be in /usr/bin. However, if you instead type "root", it will make you root user, then it will do what zimon says (which I didn't know about), but it will change the directory you're in to "/root". So if you're in /usr/bin and type "sudo gainroot", the visible end result is you get root access, and the directory you're in is still /usr/bin. If you're in /usr/bin, and type "root", the visible end result (unless you have custom stuff in /root/.profile) is you end up in the folder /root, and get root access.

For this reason, I use "sudo gainroot", because I've never needed/wanted to fiddle with the $PATH settings to point me somewhere else, and if I'm gaining root access, I usually have already navigated to the directory I want to be in - which means having to renavigate there from /root is at least one more extra command. Whenever I need something in my path, I just move or symlink it into one of the four directories that are in the standard paths. (/bin, /sbin, /usr/bin, /usr/sbin), so it works out for me.

But it's a matter of personal preference. If there's something you can do more effectively by changing /root/.profile, then "root" is good for you.

Anyway, if you say she hasn't installed anything else herself that would give root access, I really don't know why sudo gainroot keeps asking for a password. It SHOULD be something you can edit in /etc/sudoers though...

Question, did you install rootsh from Extras? Or the one in Extras-Devel? (Both are almost the same, but have some key differences... which might be why you're having sudo gainroot ask for a password.) If you're not sure, see if you can run "rootsh passwd root", or "rootsh [other command requiring root permissions]". I believe that functionality was in the Extras version of rootsh, but was removed from the version that's in devel now.

anapospastos already answered the other part of your question. "root" will make you root user (while changing your directory to /root, which doesn't actually do anything other than possibly make you have to type a couple more cd commands or use different relative paths when running commands) [and runs the root/.profile, but that's irrelevant to this], and then passwd root will let you change the root password, without asking you for that password like "sudo" will.

Thank you for the clarification regarding root and sudo gainroot. From what i understand, I shouldn't have a problem trying to do a apt-get install command when if I type in either right?

But why is it that I am unable to download and install preenv, after typing root. It gives "unable to lock the admin directory".

@FruMMAGe, We have restarted the phone, and opened up only xterminal without opening the app manager and is till gave the same "unable to lock the admin directory"

Again many thanx for the explanation and help :)

Char 2011-01-11 07:35

Re: Root vs sudo gainroot
 
it's probably apt-worker trying to update
run killall apt-worker, (after running root) and apt-get should work

Rob1n 2011-01-11 08:38

Re: Root vs sudo gainroot
 
Quote:

Originally Posted by mdziaf (Post 916965)
However, if I close and reopen Xterminal, and type in
Code:

root
no password prompt was given. but doing an apt-get install would give "unable to lock the admin directory"

Is it actually changing user? Do you get the # prompt instead of the $ prompt?

mdziaf 2011-01-11 09:26

Re: Root vs sudo gainroot
 
Quote:

Originally Posted by Rob1n (Post 917605)
Is it actually changing user? Do you get the # prompt instead of the $ prompt?

I did get the # prompt instead of the $ sign last time I tried it.

Rob1n 2011-01-11 10:26

Re: Root vs sudo gainroot
 
Quote:

Originally Posted by mdziaf (Post 917628)
I did get the # prompt instead of the $ sign last time I tried it.

Okay, so that's working at least.

The "sudo gainroot" shouldn't be asking for a password though, so the next thing to do is check whether the sudoers entry is correct - what's the result of running (as root) the following?:
Code:

grep gainroot /etc/sudoers.d/01sudo
As for the lock error, you can try checking for applications holding the lock file. You'll need to be root, and have lsof installed (not sure whether it's standard or not - it's in the Nokia SSU repository though), then run:
Code:

lsof /var/lib/dpkg/lock
If that doesn't list anything, I'd also suggest checking rootfs space (df -h /) - it may well be unable to lock the file if there's no rootfs space free.

mdziaf 2011-01-11 10:35

Re: Root vs sudo gainroot
 
Quote:

Originally Posted by Rob1n (Post 917649)
Okay, so that's working at least.

The "sudo gainroot" shouldn't be asking for a password though, so the next thing to do is check whether the sudoers entry is correct - what's the result of running (as root) the following?:
Code:

grep gainroot /etc/sudoers.d/01sudo
As for the lock error, you can try checking for applications holding the lock file. You'll need to be root, and have lsof installed (not sure whether it's standard or not - it's in the Nokia SSU repository though), then run:
Code:

lsof /var/lib/dpkg/lock
If that doesn't list anything, I'd also suggest checking rootfs space (df -h /) - it may well be unable to lock the file if there's no rootfs space free.

Ok I will get my girlfriend to do that when she comes back..will update you..appreciate the help :)

mdziaf 2011-01-11 13:33

Re: Root vs sudo gainroot
 
Quote:

Originally Posted by Rob1n (Post 917649)
Okay, so that's working at least.

The "sudo gainroot" shouldn't be asking for a password though, so the next thing to do is check whether the sudoers entry is correct - what's the result of running (as root) the following?:
Code:

grep gainroot /etc/sudoers.d/01sudo

Running the code gives me the following:
Code:

BusyBox v1.10.2 (Debian 3:1.10.2.legal-1osso30+0m5) built-in shell (ash)
Enter 'help' for a list of built-in commands.

Nokia-N900-51-1:~# grep gainroot /etc/sudoers.d/01sudo
user ALL = NOPASSWD: /usr/sbin/gainroot
Nokia-N900-51-1:~#


Rob1n 2011-01-11 14:22

Re: Root vs sudo gainroot
 
Quote:

Originally Posted by mdziaf (Post 917793)
Running the code gives me the following:
Code:

BusyBox v1.10.2 (Debian 3:1.10.2.legal-1osso30+0m5) built-in shell (ash)
Enter 'help' for a list of built-in commands.

Nokia-N900-51-1:~# grep gainroot /etc/sudoers.d/01sudo
user ALL = NOPASSWD: /usr/sbin/gainroot
Nokia-N900-51-1:~#


That's okay anyway - it specifies NOPASSWD so it shouldn't be asking for any password. What about:
Code:

grep gainroot /etc/sudoers
If that only gives the exact same result, can you post the contents of /usr/sbin/gainroot (cat /usr/sbin/gainroot)?

mdziaf 2011-01-11 14:30

Re: Root vs sudo gainroot
 
Quote:

Originally Posted by Rob1n (Post 917833)
That's okay anyway - it specifies NOPASSWD so it shouldn't be asking for any password. What about:
Code:

grep gainroot /etc/sudoers
If that only gives the exact same result, can you post the contents of /usr/sbin/gainroot (cat /usr/sbin/gainroot)?

Rob1n, I appreciate your help with this matter. but I I wont run the code, as when I tried apt-get install preenv, we were able to download and install the application. Since this was the original aim to root the N900, I feel theres no need to delve deeper into the problem.

Again many thanx to everyone for your help :D Appreciate it a lot :D

Char 2011-01-11 18:14

Re: Root vs sudo gainroot
 
Quote:

Originally Posted by mdziaf (Post 917838)
Rob1n, I appreciate your help with this matter. but I I wont run the code, as when I tried apt-get install preenv, we were able to download and install the application. Since this was the original aim to root the N900, I feel theres no need to delve deeper into the problem.

Again many thanx to everyone for your help :D Appreciate it a lot :D

so the problem WAS probably apt-worker


All times are GMT. The time now is 01:08.

vBulletin® Version 3.8.8