I’ve mentioned it before, but Chris Siebenmann is basically the Raymond Chen of the UNIX world, and today he’s filling that role perfectly once again.
I recently read Simon Tatham’s Nitpicking the shell history scene in Tron: Legacy, where one thing that surprised Tatham was the film using ‘
login -n root‘ to becomerootinstead of ‘su‘. This surprised me because I found that perfectly ordinary, and this turns up both a bit of Unix history and a difference between modern Unixes.Plain ‘
↫ Chris Siebenmannsu‘ can let you become another user, includingroot, but what it explicitly doesn’t do by default is create a new login shell for that user. If you do ‘su root‘, the new root shell normally inherits most of your environment, your current directory, and so on. Sometimes this is what you want and sometimes you really want a new login environment, and originally in Unix how you got the latter was to run ‘login‘ from your existing shell session (and this meant that login was setuid root, like su).
Unsurprisingly, this distinction has persisted to this day in various UNIX-like operating systems, but in different ways. Some maintain the explicit distinction, while others have more or less standardised on using su for both use cases. It’s an interesting bit of UNIX archeology.

Who is gonna su me ?
Plain «su» will keep your personal env, but if you add a space and a dash after, to make «su -», you will get the root user’s env. So that’s what we typically did on AIX before sudo became the norm.
josteint,
I assumed this was pretty common knowledge
If I do
It means just use a local user privileges to do the same task
But if I do
I want to fully enter that user’s environment
Two clear choices depending on what I want to do.
So did I. But I couldn’t see it mentioned in the article, so that’s why I decided to chime in. I can’t remember to have ever used ‘login’.
Make sense, I don’t remember using login either