Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I echo $CATALINA_HOME I get a blank line, but when I ls $CATALINA_HOME I correctly get a listing of the directory. Why can't I echo it? I am running Ubuntu 11.04.

share|improve this question
up vote 6 down vote accepted

Because ls $CATALINA_HOME is expanding $CATALINA_HOME to the empty string and accordingly simply doing ls (or ls . to be pedantic). Either you're in the correct directory already or you're not getting what you think you are.

share|improve this answer
Ah! Of course. Turns out I am not getting what I thought I was. I have a regular Tomcat setup - any idea why these environment variables aren't being set? Or maybe they are just set for a tomcat user/group? Because it seems to be working correctly, I was just curious. – skaz Jul 1 '11 at 2:12
I would guess they're set right by whatever starts up Tomcat, but not for anything else. But I don't know Tomcat so it's just a guess. – geekosaur Jul 1 '11 at 2:19
Great! Thanks! – skaz Jul 1 '11 at 2:20

There is no environment variable $CATALINA_HOME unless you defined it beforehand. You can see that the output of ls will always display the current directory (that is not necessarily your home directory!) if invoked with an empty or undefinded variable:


The current user's home directory is stored in $HOME:

echo $HOME

The current user name is stored in $USER:

echo $USER

Only invoking ls with $HOME will always list the contents of the current user's home directory.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.