This question already has an answer here:

i have a directory name with ISO&Emulator having some Important Files. and this directory is in different partition, and partition not showing in my FileManager(Nautilus). so i mount my partition and access it from terminal, but i can't get into directory because of its name.

when i tried to change directory:

cd ISO&Emulator


[1] 1635
bash: Emulator: command not found
bash: cd: ISO: No such file or directory
[1]+  Exit 1

its taking directory name as a command. any ways for access this directory from terminal?

how to fix this?

marked as duplicate by muru command-line Oct 3 '17 at 22:51

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 3
    cd 'ISO&Emulator' – doug Oct 3 '17 at 19:45
  • 6
    It is a good idea to avoid (remove if already there) special characters in directory names and file names. There are workarounds, but these characters can cause a lot of extra problems. – sudodus Oct 3 '17 at 20:06

You should quote the file or directory name, that contains special characters, when you using it:

cd 'ISO&Emulator'
cd "ISO&Emulator"

Or escape (or quote) just the special character:

cd ISO\&Emulator    
cd ISO'&'Emulator  
cd ISO"&"Emulator

In most cases you can use the auto-completion function:

cd ISOTab ↹

Unlike the single quote marks the double quote marks are applicable when the name contains a variable:

cd "$HOME/ISO&Emulator"
  • The same question here. – pa4080 Oct 3 '17 at 19:49

Since this isn't a command-line-only system and a graphical desktop environment is installed, you should know about another way to use files and directories from the terminal whose names require quoting or are otherwise cumbrersome to type: Drag the folder icon from your file browser into the terminal window. On you system the file browser is Nautilus, but this works with nearly all file browsers. This pastes the full path of the file or directory whose icon you dragged with correct quoting automatically applied.

This isn't a full substitute for knowing how to quote pathnames (or, really, any text) yourself using the techniques pa4080 describes, but it's extremely useful, can save you a lot of time, and if you're not comfortable with when and how to quote using \, in most graphical terminal emulators that's the form of quoting that is automatically applied when you do this, so it will demonstrate it to you. (In some, ' ' are used.)

Unless you've changed it, the shell you get when you open a terminal window or log on in a virtual console is Bash. The purpose of quoting in any shell is to tell the shell not to treat certain characters specially. You may want to read 3.1.2 Quoting in the Bash reference manual.

When you quote manually, I suggest you prefer the ' ' (single quotes) form, since it's the simplest and easiest way to quote more than a few characters of text. If what you want to quote doesn't itself contain a ' character then you can always enclose it in single quotes, because the only character with special meaning after ' begins quoting is the subsequent ' that ends quoting.

Finally, you may be wondering what happened when you had an unquoted & in your command.

This treated what came before it (cd ISO) as one command, ran it asynchronously in the background, and treated what came after it (Emulator) as a second command to run as well (in the foreground, since it had no & after it).

  1. [1] 1635 reported the background job had started (it was job 1, and its process ID happened to be 1635).
  2. bash: Emulator: command not found reported there was no command called Emulator.
  3. The message bash: cd: ISO: No such file or directory arrived from the background job to report there was no ISO directory to change to.
  4. [1]+ Exit 1 reported job 1 had finished.

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