-2
sudo echo “export CATALINA_HOME” /usr/local/tomcat10-server >> /root/.bashrc

Im using this code in the terminal as instructions from my software engineering teacher and I keep getting the error permission denied even when using sudo. Can someone please help and figure out what's wrong. Im using RHEL on a virtual machine.

  • `sudo` is not an magical wand. Redirects happen under your user anyway; only `echo` is running as root. The redirect is done by your shell, not by echo. In addition, RHEL is off topic on Ask **Ubuntu**. – vidarlo Sep 02 '23 at 19:46
  • RHEL uses sudo? Thought it uses the old "root" design? Nevertheless: RHEL is not Ubuntu. – Rinzwind Sep 02 '23 at 20:06
  • ... see also [How to solve "permission denied" when using sudo with redirection in Bash?](https://askubuntu.com/questions/230476/how-to-solve-permission-denied-when-using-sudo-with-redirection-in-bash) – steeldriver Sep 02 '23 at 20:08
  • A simple way would be to use the `tee` command. `echo "export CATALINA_HOME" /usr/local/tomcat10-server | sudo tee -a /root/.bashrc` – Terrance Sep 02 '23 at 22:55

0 Answers0