I wonder what's the exact difference between these 2 commands:1. su 2. su - . Can anyone please explain?
1 Answer
The man page describes it fairly well with the following:
-, -l, --login
Start the shell as a login shell with an environment similar
to a real login:
o clears all the environment variables except TERM
o initializes the environment variables HOME, SHELL,
USER, LOGNAME, and PATH
o changes to the target user's home directory
o sets argv[0] of the shell to '-' in order to make
the shell a login shell
I usually think about it in terms of the environment I want, in all honesty I tend to always use su -
by default.