1

This question already has an answer here:

I am studying the Linux command line. But the book which I'm reading says that su -l(-) username is starting a new shell session and loading the environment of the user I want to change to, but su doesn't.

When I was root user, I entered the command su testuser, so I am testuser. But after that, I entered echo "$USER", and it says testuser. It means that it loads testuser's environment, doesn't it? Is there something wrong?

And what does "starts a new shell session" mean exactly? Does shell have a mechanism like login, logout?

marked as duplicate by muru, Scott, Archemar, roaima, Jenny D Feb 4 '16 at 9:12

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.

  • Just run 'env' instead of 'echo $USER' – njboot Feb 4 '16 at 6:57
3

su gives you root permissions but it does not change the PATH variable and current working directory. so you can't execute files in /usr/sbin folder.

su- changes the PATH too... and root's home becomes your current working directory. you become proper root and can execute all commands.

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