Score:-2

Permission denied when using sudo

kz flag
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.

vidarlo avatar
om flag
`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**.
cn flag
RHEL uses sudo? Thought it uses the old "root" design? Nevertheless: RHEL is not Ubuntu.
hr flag
... 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)
Terrance avatar
id flag
A simple way would be to use the `tee` command. `echo "export CATALINA_HOME" /usr/local/tomcat10-server | sudo tee -a /root/.bashrc`
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.