Backslash at start of file path?












0















When using the cd command at the terminal, I get a 'no such directory' error if I type something like



cd /directory/whatever/


But when I type something like



cd directory/whatever/


It works just fine.



This occurs whether I am in the home directory or inside another directory.



What's more, this only seems to apply to directories like Downloads, Pictures, and the like, and also directories that I have created myself. Directories like usr and etc do not have this problem.



What could be causing this? and how can I change it to normal?










share|improve this question


















  • 1





    Welcome to Ask Ubuntu! Please edit your question to add the output of the pwd command before and after you executed your cd.

    – Melebius
    Feb 21 at 10:57
















0















When using the cd command at the terminal, I get a 'no such directory' error if I type something like



cd /directory/whatever/


But when I type something like



cd directory/whatever/


It works just fine.



This occurs whether I am in the home directory or inside another directory.



What's more, this only seems to apply to directories like Downloads, Pictures, and the like, and also directories that I have created myself. Directories like usr and etc do not have this problem.



What could be causing this? and how can I change it to normal?










share|improve this question


















  • 1





    Welcome to Ask Ubuntu! Please edit your question to add the output of the pwd command before and after you executed your cd.

    – Melebius
    Feb 21 at 10:57














0












0








0








When using the cd command at the terminal, I get a 'no such directory' error if I type something like



cd /directory/whatever/


But when I type something like



cd directory/whatever/


It works just fine.



This occurs whether I am in the home directory or inside another directory.



What's more, this only seems to apply to directories like Downloads, Pictures, and the like, and also directories that I have created myself. Directories like usr and etc do not have this problem.



What could be causing this? and how can I change it to normal?










share|improve this question














When using the cd command at the terminal, I get a 'no such directory' error if I type something like



cd /directory/whatever/


But when I type something like



cd directory/whatever/


It works just fine.



This occurs whether I am in the home directory or inside another directory.



What's more, this only seems to apply to directories like Downloads, Pictures, and the like, and also directories that I have created myself. Directories like usr and etc do not have this problem.



What could be causing this? and how can I change it to normal?







command-line cd-command






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 21 at 10:53









InglorionInglorion

31




31








  • 1





    Welcome to Ask Ubuntu! Please edit your question to add the output of the pwd command before and after you executed your cd.

    – Melebius
    Feb 21 at 10:57














  • 1





    Welcome to Ask Ubuntu! Please edit your question to add the output of the pwd command before and after you executed your cd.

    – Melebius
    Feb 21 at 10:57








1




1





Welcome to Ask Ubuntu! Please edit your question to add the output of the pwd command before and after you executed your cd.

– Melebius
Feb 21 at 10:57





Welcome to Ask Ubuntu! Please edit your question to add the output of the pwd command before and after you executed your cd.

– Melebius
Feb 21 at 10:57










1 Answer
1






active

oldest

votes


















5














cd /directory/whatever/ uses full pathname, starting from top-most directory /. Usually only users with root/sudo level of privilege can create directories there, so likely directory in / does not exist , hence the error.



cd directory/whatever/ uses relative pathname - relative to current working directory. Terminal starts out in user's home directory, aka /home/$USER aka same as what pwd or echo $PWD would report. Likely you've created directory and subdirectory whatever in your home directory. Equivalent would be cd ./directory/whatever, where ./ signifies current working directory link.



As for d that uses the slash as escape character, which is here unnecessary but would be necessary in cases where filename contains special characters that shell treats as having different meaning. For example, cd with space and cd 'with space' are the same - one single string as argument to cd. By contrast, cd with space are two different strings given as arguments to cd (because unescaped spaces are treated as word separators in shell, aka word splitting) and of course it will result in an error






share|improve this answer



















  • 1





    “cd with space are two different strings given as arguments to cd (…) and of course it will result in an error” …not necessarily if you’re using Zsh. blog.confirm.ch/zsh-tips-changing-directories

    – Melebius
    Feb 21 at 11:06











  • And of course cd "./directory with space/foo" takes care of whitespace in any shell.

    – Carl Witthoft
    Feb 21 at 12:29













Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1120087%2fbackslash-at-start-of-file-path%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









5














cd /directory/whatever/ uses full pathname, starting from top-most directory /. Usually only users with root/sudo level of privilege can create directories there, so likely directory in / does not exist , hence the error.



cd directory/whatever/ uses relative pathname - relative to current working directory. Terminal starts out in user's home directory, aka /home/$USER aka same as what pwd or echo $PWD would report. Likely you've created directory and subdirectory whatever in your home directory. Equivalent would be cd ./directory/whatever, where ./ signifies current working directory link.



As for d that uses the slash as escape character, which is here unnecessary but would be necessary in cases where filename contains special characters that shell treats as having different meaning. For example, cd with space and cd 'with space' are the same - one single string as argument to cd. By contrast, cd with space are two different strings given as arguments to cd (because unescaped spaces are treated as word separators in shell, aka word splitting) and of course it will result in an error






share|improve this answer



















  • 1





    “cd with space are two different strings given as arguments to cd (…) and of course it will result in an error” …not necessarily if you’re using Zsh. blog.confirm.ch/zsh-tips-changing-directories

    – Melebius
    Feb 21 at 11:06











  • And of course cd "./directory with space/foo" takes care of whitespace in any shell.

    – Carl Witthoft
    Feb 21 at 12:29


















5














cd /directory/whatever/ uses full pathname, starting from top-most directory /. Usually only users with root/sudo level of privilege can create directories there, so likely directory in / does not exist , hence the error.



cd directory/whatever/ uses relative pathname - relative to current working directory. Terminal starts out in user's home directory, aka /home/$USER aka same as what pwd or echo $PWD would report. Likely you've created directory and subdirectory whatever in your home directory. Equivalent would be cd ./directory/whatever, where ./ signifies current working directory link.



As for d that uses the slash as escape character, which is here unnecessary but would be necessary in cases where filename contains special characters that shell treats as having different meaning. For example, cd with space and cd 'with space' are the same - one single string as argument to cd. By contrast, cd with space are two different strings given as arguments to cd (because unescaped spaces are treated as word separators in shell, aka word splitting) and of course it will result in an error






share|improve this answer



















  • 1





    “cd with space are two different strings given as arguments to cd (…) and of course it will result in an error” …not necessarily if you’re using Zsh. blog.confirm.ch/zsh-tips-changing-directories

    – Melebius
    Feb 21 at 11:06











  • And of course cd "./directory with space/foo" takes care of whitespace in any shell.

    – Carl Witthoft
    Feb 21 at 12:29
















5












5








5







cd /directory/whatever/ uses full pathname, starting from top-most directory /. Usually only users with root/sudo level of privilege can create directories there, so likely directory in / does not exist , hence the error.



cd directory/whatever/ uses relative pathname - relative to current working directory. Terminal starts out in user's home directory, aka /home/$USER aka same as what pwd or echo $PWD would report. Likely you've created directory and subdirectory whatever in your home directory. Equivalent would be cd ./directory/whatever, where ./ signifies current working directory link.



As for d that uses the slash as escape character, which is here unnecessary but would be necessary in cases where filename contains special characters that shell treats as having different meaning. For example, cd with space and cd 'with space' are the same - one single string as argument to cd. By contrast, cd with space are two different strings given as arguments to cd (because unescaped spaces are treated as word separators in shell, aka word splitting) and of course it will result in an error






share|improve this answer













cd /directory/whatever/ uses full pathname, starting from top-most directory /. Usually only users with root/sudo level of privilege can create directories there, so likely directory in / does not exist , hence the error.



cd directory/whatever/ uses relative pathname - relative to current working directory. Terminal starts out in user's home directory, aka /home/$USER aka same as what pwd or echo $PWD would report. Likely you've created directory and subdirectory whatever in your home directory. Equivalent would be cd ./directory/whatever, where ./ signifies current working directory link.



As for d that uses the slash as escape character, which is here unnecessary but would be necessary in cases where filename contains special characters that shell treats as having different meaning. For example, cd with space and cd 'with space' are the same - one single string as argument to cd. By contrast, cd with space are two different strings given as arguments to cd (because unescaped spaces are treated as word separators in shell, aka word splitting) and of course it will result in an error







share|improve this answer












share|improve this answer



share|improve this answer










answered Feb 21 at 11:00









Sergiy KolodyazhnyySergiy Kolodyazhnyy

74.4k9155325




74.4k9155325








  • 1





    “cd with space are two different strings given as arguments to cd (…) and of course it will result in an error” …not necessarily if you’re using Zsh. blog.confirm.ch/zsh-tips-changing-directories

    – Melebius
    Feb 21 at 11:06











  • And of course cd "./directory with space/foo" takes care of whitespace in any shell.

    – Carl Witthoft
    Feb 21 at 12:29
















  • 1





    “cd with space are two different strings given as arguments to cd (…) and of course it will result in an error” …not necessarily if you’re using Zsh. blog.confirm.ch/zsh-tips-changing-directories

    – Melebius
    Feb 21 at 11:06











  • And of course cd "./directory with space/foo" takes care of whitespace in any shell.

    – Carl Witthoft
    Feb 21 at 12:29










1




1





“cd with space are two different strings given as arguments to cd (…) and of course it will result in an error” …not necessarily if you’re using Zsh. blog.confirm.ch/zsh-tips-changing-directories

– Melebius
Feb 21 at 11:06





“cd with space are two different strings given as arguments to cd (…) and of course it will result in an error” …not necessarily if you’re using Zsh. blog.confirm.ch/zsh-tips-changing-directories

– Melebius
Feb 21 at 11:06













And of course cd "./directory with space/foo" takes care of whitespace in any shell.

– Carl Witthoft
Feb 21 at 12:29







And of course cd "./directory with space/foo" takes care of whitespace in any shell.

– Carl Witthoft
Feb 21 at 12:29




















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1120087%2fbackslash-at-start-of-file-path%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

Mangá

 ⁒  ․,‪⁊‑⁙ ⁖, ⁇‒※‌, †,⁖‗‌⁝    ‾‸⁘,‖⁔⁣,⁂‾
”‑,‥–,‬ ,⁀‹⁋‴⁑ ‒ ,‴⁋”‼ ⁨,‷⁔„ ‰′,‐‚ ‥‡‎“‷⁃⁨⁅⁣,⁔
⁇‘⁔⁡⁏⁌⁡‿‶‏⁨ ⁣⁕⁖⁨⁩⁥‽⁀  ‴‬⁜‟ ⁃‣‧⁕‮ …‍⁨‴ ⁩,⁚⁖‫ ,‵ ⁀,‮⁝‣‣ ⁑  ⁂– ․, ‾‽ ‏⁁“⁗‸ ‾… ‹‡⁌⁎‸‘ ‡⁏⁌‪ ‵⁛ ‎⁨ ―⁦⁤⁄⁕