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

I am using Ubuntu 11.10 and in terminal I want to enter the following folder:

cd Milano, Torino (Jan)-Compressed

And it does not work! How should I write the command cd to enter this directory?

share|improve this question
up vote 30 down vote accepted

That command is ambiguous because spaces are normally used to separate arguments. cd does not know what you want to do but you have two possibilities to solve it:

Either you "mask" the spaces (and all other special characters) so that the terminal knows you mean the space as a character and not as a separator:

cd Milano\,\ Torino\ \(Jan\)-Compressed

Or you put your folder name or path into quotes:

cd "Milano, Torino (Jan)-Compressed"
share|improve this answer
Or use single quotes ('Milano, Torino (Jan)-Compressed'), if you don't want environment variables ($VARNAME) to be expanded and commands enclosed in backticks or $() to be run (or if there are double-quotes in the filename). – Eliah Kagan Jul 10 '12 at 13:52

Write it as

cd 'Milano, Torino (Jan)-Compressed'

Otherwise it treats Milano, as the folder name. This happens because of the spaces in the name of the folder.

Alternatively escape a few of the special characters...

cd Milano\,\ Torino\ \(Jan\)-Compressed/
share|improve this answer
You can also use Tab for auto-completion inside the double quotes to auto-escape double-quotes within the filename. – htorque Feb 5 '12 at 12:06
Note that double quotes won't help you cd into a directory named $money, for example. You'd need to write '$money' or \$money. – Dietrich Epp Feb 5 '12 at 20:22
I think generally single quotes are more explicit, and a better standard. Both work, but single quotes work more often and say "exactly as you see it". – isaaclw Feb 5 '12 at 21:50
@isaaclw Thanks, I agree! Edited. – Prateek Feb 6 '12 at 14:14

A little tip tab completion :)

  1. Just type the first letter e.g cd Mi and press Tab. Terminal will help you completing the rest words.

Another way drag and drop

  1. If you can see the directory and if you want to access it using terminal, just type: cd first and then drag and drop the directory on the terminal and hit enter.
share|improve this answer
Got to love tab completion <3 – Rinzwind Feb 5 '12 at 15:39
While the accepted answer is technically correct, in practice you're going to want tab-completion so you don't have to do all that escaping. – phasetwenty Feb 9 '12 at 21:32
@Achu, but sometimes even the tab completion itself doesn't work for directories containing especial characters i.e. -, etc, so the suggested method would be cd -- '-foo-/'. but still we can use tab completion inside the quotation ;) – Amir Jan 10 '14 at 14:05

To open a folder containing a space surround it in quotes like cd "Some Directory" or escape the space with a backslash, like: cd /home/kudic/Radna\ površina.

share|improve this answer
Or escape the space with a backslash, like: cd /home/kudic/Radna\ površina – Timo Jul 10 '12 at 13:43
Great point! I forgot to mention that. I normally use quotes out of habit, but the backslash is actually better to use in the long run. – Corey Whitaker Jul 10 '12 at 13:45
Or use single quotes ('Radna površina'), if you don't want environment variables ($VARNAME) to be expanded and commands enclosed in backticks or $() to be run (or if there are double-quotes in the filename). – Eliah Kagan Jul 10 '12 at 13:49

If this directory is in your home folder then type:

cd "Milano, Torino (Jan)-Compressed"

else give absolute path:

cd "/…/…/Milano, Torino (Jan)-Compressed"

if there is a double quote in file name then escape that with \"

share|improve this answer
If you start a path with a leading forward slash, it goes from root. You might want to remove that. – isaaclw Feb 5 '12 at 21:52
@isaaclw That is why he filed it as an absolute path :P – user13091 Feb 6 '12 at 1:16
Ah, that's three dots, indicating a "variable" folder. I assumed it was two dots, indicating "parent folder". Apologies. – isaaclw Feb 6 '12 at 3:43

Another option although not the best in this case is to use wildcards. You can try:

cd *Torino*

It is best to use this method when there is a distinct word or phrase in the name of a directory not shared by others. For example I have mount points /media/DataSSD and /media/DataHDD. Autocompletion doesn't work until I type nearly half of the name so to get to my HDD partition I just type

cd /media/*HD*

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.