Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

I don't know when this started happening but now, every time I cd to a directory it echoes the path right before it changes directories. This happens when I log into a server but doesn't happen on my local machine. The server is running Linux. My local machine is running Mac OS X.

I searched the Google as well as looked at the bash man page but I couldn't find anything. My .bashrc/.bash_profile doesn't have anything related to 'cd' (that I know of).

How do I modify this "feature"?

share|improve this question
up vote 8 down vote accepted

The shell auto-echoes because CDPATH is defined as an environment variable. If you UNSET CDPATH the default cd behavior will appear again.

share|improve this answer
It's more than just an echo feature. check out – DaveParillo Jan 3 '10 at 0:51
THANK YOU. Spent hours trying to figure out why a java program that was being called by a node.js script wasn't running. Turned out there was a shell script there somewhere and because my CDPATH was exported in my profile, output of $(cd directory && pwd) printed out /path/to/directory /path/to/directory. – Igor Zevaka Feb 20 '14 at 4:14

The above answer suggesting to unset CDPATH is probably the best. However, if you want CDPATH to remain active while cd-ing you can also use in your scripts something like:

cd /path/to/wherever > /dev/null

share|improve this answer

Another option is to more permanently override the builtin cd with a bash function. I've found something like this effective when placed in your ~/.profile (or similar) file:

function cd() {
    if [ -z "$*" ]; then 
    builtin cd "${destination}" >/dev/null && ls
  • This preserves the use of cd without arguments to return to your home directory.
  • The >/dev/null is responsible for swallowing the folder name being echoed. (That echoing of the folder name is what breaks scripts that use FOO=$(cd $SOMEVAR && pwd) to save a full path to a variable.)
  • And finally; as written this function performs an automatic ls after changing directories. (Remove the && ls to stop that.)
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.