0

How can I switch from user to root? In my terminal I typed in

su - 

and it took me to the root directory, so I need to go back to the user directory.

AdminBee
  • 22,803
YINMII
  • 3

2 Answers2

3

Just type su without the - to become root but without it being a login shell.

  • Thanks for your response but the question is how can I return to my user home directory after becoming root? – YINMII Nov 11 '22 at 17:02
  • @YINMII you don't use -, exactly as suggested in this answer. That way you stay in your current directory – Chris Davies Nov 11 '22 at 17:07
0

It turns out that the requirement is not to change directory, but to exit the root shell. (Which implicitly reverts to the caller's directory.)

You can do this with the exit command. A quick alternative at the start of a new line is Ctrl d.

Chris Davies
  • 116,213
  • 16
  • 160
  • 287