Reply
Thread Tools
Posts: 3,617 | Thanked: 2,412 times | Joined on Nov 2009 @ Cambridge, UK
#11
Splitting things down - the "sudo" command means it runs the gainroot script (/usr/sbin/gainroot) as root. Passing the "--use-su" script tells that to then run "su -" which changes the login environment to that of the root user (changes home directory, etc).
 

The Following 2 Users Say Thank You to Rob1n For This Useful Post:
Posts: 557 | Thanked: 370 times | Joined on Apr 2010
#12
On a similar note, does anyone have the rootsh script? Really, really miss that command. I hate having to pipe to sudo gainroot.
 
pelago's Avatar
Posts: 2,121 | Thanked: 1,540 times | Joined on Mar 2008 @ Oxford, UK
#13
I've been wondering about this for a while, too. I had looked at /usr/bin/root but couldn't quite understand the difference. Can anyone explain what practical difference there is to "changes the login environment to that of the root user (changes home directory, etc)."? Or in other words, which is better to use, "sudo gainroot" or "root"? If the answer is "it depends on the situation", which situations would be better to use one or the other?

http://wiki.maemo.org/Root_access would be a good place to document this long-term.
 
Posts: 3,617 | Thanked: 2,412 times | Joined on Nov 2009 @ Cambridge, UK
#14
Originally Posted by pelago View Post
I've been wondering about this for a while, too. I had looked at /usr/bin/root but couldn't quite understand the difference. Can anyone explain what practical difference there is to "changes the login environment to that of the root user (changes home directory, etc)."? Or in other words, which is better to use, "sudo gainroot" or "root"? If the answer is "it depends on the situation", which situations would be better to use one or the other?
A quick look at the environment variables in the different states would suggest that doing "sudo gainroot" does not run the profile/bashrc scripts.

I would say that generally you're better using "root". The only downside I'm aware of is that your current directory is changed, whereas with "sudo gainroot" it isn't - so if you're trying to do something in a specific directory and find you need root access then "sudo gainroot" would be easier.
 

The Following 3 Users Say Thank You to Rob1n For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 13:04.