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

Something similar to this Q&A, I know that cd will change current working directory in terminal to a new directory like this:

cd /path/to/new_directory

But I wonder how can I change current working directory only by typing for example:


followed by Enter, of course. Nothing more.

share|improve this question
up vote 5 down vote accepted

I just find out that by activating autocd shell option, using the following command:

shopt -s autocd


a command name that is the name of a directory is executed as if it were the argument to the cd command

(from man bash, somewhere at the line 5131).

So it will actually let me use any directory as a command and will cd to it:


To make the change permanently, add the following line to the end of your ~/.bashrc file:

shopt -s autocd
share|improve this answer

This is the default behavior for zsh with the Grml config. zsh is an advanced shell, it has a lot of improvements over bash, the default shell in Ubuntu.

To install zsh, type:

sudo apt-get install zsh

To grab the Grml configuration, run this from your home directory:

wget -O .zshrc
wget -O .zshrc.local

Then run zsh to start it. If you like it, you can make it your default shell by running the following command:

chsh -s /usr/bin/zsh
share|improve this answer
I tagged my Q with bash, so I'm not really interested in zsh. Anyway, +1 for your nice and clear answer. – Radu Rădeanu Jul 8 '14 at 18:59
You don't really need to grab that Grml configuration. The equivalent of shopt -s autocd from bash in zsh is setopt auto_cd. – Radu Rădeanu Jul 8 '14 at 19:06
@RaduRădeanu Thanks for the info. I usually recommend the Grml config because it has all the settings people are usually looking for. If you're into fine-tuning your shell, you'll probably end up trying to mimic the zsh/grml behavior. After using it for 2 minutes, going back to bash is like the step back from bash to sh. (Your experience may differ.) – kraxor Jul 8 '14 at 19:52

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.