News for hackers. Stuff that matters.
Re:The Meaning of 'su' by mrb on Sunday February 24, 2013 @10:55PM (#5277241)
To all people who type "sudo su - root": the much simpler "sudo -i" accomplishes the same (-i launches an interactive shell).
Re:The Meaning of 'su' by kelnos on Monday February 25, 2013 @01:36AM (#5277641)
The "-i" option actually means "simulate Initial login" -- the idea being -i will drop you into a shell as if you'd logged in as the user in a fresh session. -s will also give you an interactive shell, but doesn't mess with the environment.

(And both -i and -s can also not give you an interactive shell, if you give it a command to run. The point is that it will run the command in the shell rather than just fork()ing and exec()ing like a bare sudo invocation would do.)

Re:The Meaning of 'su' by etanol on Monday February 25, 2013 @06:00AM (#5278316)
Read carefully: "sudo -i" to replace "sudo su - root". You should check the "su" manpage and look for the -/-l/--login option.
Re:The Meaning of 'su' by kelnos on Friday March 01, 2013 @06:45PM (#5307683)
I'm not objecting to that. I'm objecting to the (perhaps unintended) assertion that "sudo -i" means "give me an interactive shell". It does happen to give you an interactive shell (assuming you don't specify a command), but as a side effect. "-s" gives you an interactive shell too, but the semantics are different.
Re:The Meaning of 'su' by Osiris on Sunday February 24, 2013 @11:44PM (#5277347)
I thought "sudo -s" was the correct way to drop into a root user shell.
Re:The Meaning of 'su' by ralph on Monday February 25, 2013 @04:40AM (#5278083)
No, unless one understands the subtleties, it may be best to use -i.

    $ sudo -s
    $ pwd
    /home/ralph
    $ exit
    $ sudo -i
    root@orac:~# pwd
    /root
    root@orac:~# logout
    $
    $ sudo strace -fe execve sudo -s
    execve("/usr/bin/sudo", ["sudo", "-s"], [/* 16 vars */]) = 0
    execve("/bin/bash", ["/bin/bash"], [/* 16 vars */]) = 0
    ...
    $ exit
    $ sudo strace -fe execve sudo -i
    execve("/usr/bin/sudo", ["sudo", "-i"], [/* 16 vars */]) = 0
    execve("/bin/bash", ["-bash"], [/* 16 vars */]) = 0
    ...
    root@orac:~# logout
    $
Re:The Meaning of 'su' by theblazehen on Monday February 25, 2013 @02:25AM (#5277768)
What is the difference between that and sudo bash
Re:The Meaning of 'su' by alexkus on Monday February 25, 2013 @05:13AM (#5278163)
One side effect of "sudo bash" is that when you exit that shell your local user's .bash_history file gets overwritten by one owned by root (and un{read/write}able by the local user), and so your local user loses the bash history functionality from that point on.