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.
Just type su
without the -
to become root but without it being a login shell.
-
, exactly as suggested in this answer. That way you stay in your current directory
– Chris Davies
Nov 11 '22 at 17:07
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.
man su
in this case. – Chris Davies Nov 11 '22 at 16:13cd
command or do you not know how to get the path to your user's directory? – terdon Nov 11 '22 at 17:21