Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This question already has an answer here:

I see that su - makes the shell a login shell from su --help. I'm curious what the differences are between this and a normal su command.

I know there seems to be a difference in the paths, any other differences or is that pretty much the only difference?

share|improve this question

marked as duplicate by Daniel Beck Apr 9 '13 at 21:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

4 Answers 4

AFAIK su - simulates a fresh login, so triggers everything related to logging in, while su simply switches the user to root.

share|improve this answer

difference i usually meet is difference in environment variables. su - change environment, su don't. For example: "su -" can give different PATH, accessing other tools, Can give other HOME with different configuration ( ~/.ssh !/.Xauthority etc)

share|improve this answer

A login shell sources ~/.profile if it exists. Therefore, it really depends, what do you have in your ~/.profile?

Usually these are environment variable differences, such as the PATH, or the prompt (PS1 environment variable) but obviously there can be other differences.. It really depends on what you put in your shell config scripts.

share|improve this answer

from man su

   -, -l, --login
          make the shell a login shell

so the next question is what is a login shell, and how it differs from a non-login shell.

In man bash under INVOCATION you can read a long and pedantic section, that boils down to something like: login shell runs the profile file(s) (e.g. /etc/profile and ~/.bash_profile) while the interactive non-login shell runs the bashrc files.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.