Backslash at start of file path?
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
add a comment |
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
1
Welcome to Ask Ubuntu! Please edit your question to add the output of thepwd
command before and after you executed yourcd
.
– Melebius
Feb 21 at 10:57
add a comment |
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
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
command-line cd-command
asked Feb 21 at 10:53
InglorionInglorion
31
31
1
Welcome to Ask Ubuntu! Please edit your question to add the output of thepwd
command before and after you executed yourcd
.
– Melebius
Feb 21 at 10:57
add a comment |
1
Welcome to Ask Ubuntu! Please edit your question to add the output of thepwd
command before and after you executed yourcd
.
– 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
add a comment |
1 Answer
1
active
oldest
votes
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
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 coursecd "./directory with space/foo"
takes care of whitespace in any shell.
– Carl Witthoft
Feb 21 at 12:29
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
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 coursecd "./directory with space/foo"
takes care of whitespace in any shell.
– Carl Witthoft
Feb 21 at 12:29
add a comment |
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
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 coursecd "./directory with space/foo"
takes care of whitespace in any shell.
– Carl Witthoft
Feb 21 at 12:29
add a comment |
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
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
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 coursecd "./directory with space/foo"
takes care of whitespace in any shell.
– Carl Witthoft
Feb 21 at 12:29
add a comment |
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 coursecd "./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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
1
Welcome to Ask Ubuntu! Please edit your question to add the output of the
pwd
command before and after you executed yourcd
.– Melebius
Feb 21 at 10:57