39

I'm completely new and lost in Ubuntu 12.04, I'm having trouble navigating to my Sublime folder which I know is in my /opt folder. Yet I've tried to no avail to navigate into it via Terminal window. The directory is colored in blue, no idea what this means...but I am able to access the folder using the GUI explorer...?

k@k-Ubuntu:~$ cd /opt
k@k-Ubuntu:/opt$ ls
Sublime Text 2
k@k-Ubuntu:/opt$ cd Sublime Text 2
bash: cd: Sublime: No such file or directory
k@k-Ubuntu:/opt$ cd /Sublime Text 2
bash: cd: /Sublime: No such file or directory
1
  • 1
    the default color scheme colours directories blue.
    – djeikyb
    Jan 1, 2014 at 5:27

2 Answers 2

46

Go inside the /opt directory via terminal and then run below command,

k@k-Ubuntu:~$ cd /opt
k@k-Ubuntu:/opt$ cd "Sublime Text 2"

As the folder you want to connect has spaces in the name, you must surround the name with quotes in order for the Shell to read it correctly (as one name). In other case it will read only the Sublime and this doesn’t exist.

Another way to avoid this issue, is to use Tab Completion. This is a feature that will help you to auto-fill weird names and/or long names. Read here about Tab Completion and learn it. It is very useful(in Ubuntu is pre-installed).

A third way for names with spaces is the backslash \ . Above command with quotes could be

cd Sublime\ Text\ 2/

the backslash followed by a space explicitly denotes a space.

A suggestion could be: Do not create folders in Linux with space in name. Prefer something like Sublime-Text-2 or Sublime_Text_2

6
  • 1
    or after going to /opt, type cd Sub and then press Tab to autocomplete.
    – Web-E
    Jan 1, 2014 at 4:50
  • Can you please explain to me why you need to use the double quotes? Is this for all directories that have spaces? Or for the directories marked in blue in the Terminal window?
    – webdev
    Jan 1, 2014 at 4:50
  • no,its for the directory which contains spaces on their names. Jan 1, 2014 at 4:51
  • Tried the tab for autocomplete, didn't do anything? - NVM, my mistake didn't use the caps on S. :/
    – webdev
    Jan 1, 2014 at 4:51
  • Thanks for all the help and information guys, appreciate it!
    – webdev
    Jan 1, 2014 at 4:56
3

If there are spaces in the name ,then just use a backslash('\') and then the space(' ') ,for e.g " os program " so in this there are three spaces so use three backslashes, so the command will be

cd \ os\ program\ 

so for each space in the name use a backslash and then the space, another example "os program" ,have two continuous space ,so command is

cd os\ \ program
1
  • 2
    This looks exactly like the 2nd part of Avinash Raj answer. While it's factual, I'm not sure it needs repetition.
    – Elder Geek
    Mar 26, 2015 at 19:12

Not the answer you're looking for? Browse other questions tagged .