I have a deploy user that has
sudo cd into the directory, but I can list it like:
sudo ls /root
How can I
cd into the folder, or is that not possible?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
It is not possible, because
sudo runs a single command as root; your shell is still owned by your user.
What you can do is to open a new shell as root, by running
sudo -i or
sudo -s. From
-i, --login Run the shell specified by the target user's password data- base entry as a login shell.
-s, --shell Run the shell specified by the SHELL environment variable if it is set or the shell specified by the invoking user's pass- word database entry. If a command is specified, it is passed to the shell for execution via the shell's -c option. If no command is specified, an interactive shell is executed.
Either of these will give you a new shell, with root privileges, where you can freely change directory and run new commands as root.