In the terminal You use cd ../../........ to get to wherever you want,

But I am lazy, I am wondering if it is possible to automatically cd into the directories if the command is simply the directory.

The terminals obviously know it's the directory because you get the output of

$ ../
bash: ../: Is a directory

So is it possible to hijack this message to automatically cd into that directory?

  • lol that is lazy. Just be careful some direcotires and executables share the same name, that's why typing cd is better.
    – coteyr
    May 20, 2013 at 23:07
  • 1
    laziness is a virtue
    – valbaca
    Jul 1, 2016 at 23:25

1 Answer 1


Add shopt -s autocd to your ~/.bashrc.

Also, you might want to run man shopt in terminal for more useful options.

  • Yes. This Works perfectly. I can also use cd foldername in order to change directory in the common way but, how can I remove such functionality and revert to default? Thanks in advance. May 20, 2013 at 23:23
  • shopt -u autocd -- read the link man.
    – coteyr
    May 20, 2013 at 23:38
  • 1
    info bash --index-search='shopt' or Gnu Bash Reference - Shopt
    – LantzR
    May 20, 2013 at 23:51
  • this prints out cd -- /directory/path is there a way to silence that?
    – Fuseteam
    Feb 21, 2020 at 14:12
  • @Fuseteam You can use the full cd command and not get output. There is a good reason that this shopt shortcut prints output -- so you don't end up running irrevocable commands after having changed dirs accidentally.
    – demure
    Feb 22, 2020 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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