0

When I type in

cd Desktop/Code

and then press Enter, it says

-bash: cd: DesktopCode: No such file or directory

I do have that file in my desktop, but I'm not sure how to access it and I'm not sure why it says -bash beforehand, and if that has something to do with it.

What is wrong?

Edit: I was confused and mistyped it. The error is "-bash: cd: Desktop/Code: No such file or directory". I am considering deleting ubuntu and then re-installing it, but I'm not sure if that would be too much of a hassle and if there is another way. Also, thank you to everyone who's helped me! I need to fix this in order to do an assignment and I cannot figure it out and I appreciate it so much.

  • What is "Code", a file or a directory? And this has nothing to do with programming. – user931000 Feb 8 '19 at 1:45
  • What does cd Desktop//Code do for you? – Pimp Juice IT Feb 8 '19 at 19:34
  • What directory are you in when you do this? Unless Desktop is a child of your current directory, you will need the complete path. – fixer1234 Feb 10 '19 at 3:12
6

You have typed a backslash (\) in your command instead of a forward slash (/).

The backslash is used as an escape character. Since \C (in Desktop\Code) is not a recognized escape sequence, the backslash is ignored, so your command is interpreted as cd DesktopCode.

|improve this answer|||||
  • 1
    Ninja’ed by a dog!    :-(    ⁠ – Scott Feb 8 '19 at 2:49
  • 1
    That's speciesist! – Journeyman Geek Feb 8 '19 at 3:51
  • BARK! BARKBARKBARK! – duskwuff -inactive- Feb 8 '19 at 3:52
  • According to the original content and the latest edit to make that specific point more clear (I read it for the first time just now anyway), they are indeed already using a forward slash and not a backslash. Why might that happen when that is the case to go along with your existing answer. – Pimp Juice IT Feb 8 '19 at 5:51
  • @PimpJuiceIT The edits were not made by the OP. The simplest and most likely explanation for the behavior they're describing is that they typed a backslash by mistake. – duskwuff -inactive- Feb 8 '19 at 19:06
0

There are details that would be helpful, but, since you are new to Unbutu, you would not know them. Let's try some troubleshooting and see what happens.

At you command prompt, what does your prompt look like? something like this:
[Gabriel@mycomputer] $ _

Can you run a directory listing?
ls -la

Can you print the current directory?
pwd
-- or --
cwd

Next, can you try just a cd command:
cd ~

if not, try to "unalias" the cd, like this:
\cd ~ Notice the "backslash" before the cd. This is not the "forward slash" that you see with the question mark.
Forward Slash: /
Back Slash: \

And, try this command, just to see what it says:
which cd
Can you run any other command successfully, besides cd?

|improve this answer|||||
  • Hello! Sorry for the late response. I am able to run a directory listing and print the current directory, and my prompt does look like that somewhat. When I run a cd command, it says "-bash: cd:" the directory I was trying to access, and ":No such file or directory" – Gabriel L. Feb 9 '19 at 5:03
  • In Unix, you have a shell program, like a command prompt in Windows. Linux has several. Bash is the one you are using. the error you are getting means 1 of 2 things: 1) It cannot find the "cd" command 2) It cannot find the directory you are looking for.Desktop/code First, run the 'which cd' command and post the result. Second, run the 'ls -la' command and post the result. I'm sure we can figure it out if you do that. – Scottie H Feb 9 '19 at 5:20
0

If the error message is bash: cd: DesktopCode: No such file or directory, then the most likely explanation is that you typed cd Desktop\Code instead of cd Desktop/Code.  In Unix & Linux, you must use / as a separator between directory names in a pathname.

|improve this answer|||||
  • Thank you! I changed the slashes, however, now my message says "-bash: cd: Desktop/Code: No such file or directory" – Gabriel L. Feb 9 '19 at 5:05
-2

Bash is the shell, or command interpreter that you are using. That error essentially means that the shell you are using is reporting that it can’t find the directory.

Try this

cd ~/Desktop/Code

Keep in mind Linux is case sensitive, so if your directory is named code with a lower case “c” the. You will need to modify the command accordingly like this:

cd ~/Desktop/code

Let me know if that works

|improve this answer|||||
  • Wow I screwed that up! I have updated my answer – Richie086 Feb 8 '19 at 17:24
  • Hello! I tried that. however, I just get the same error. It says "-bash: cd:" what I'm trying to access, and ": No such file or directory" – Gabriel L. Feb 9 '19 at 5:06
  • Did you actually create a folder on your desktop called code at all? – Richie086 Feb 12 '19 at 13:48

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.