Can't make new dir with mkdir
up vote
1
down vote
favorite
When I run
mkdir ../../bin/Release_Linux/Resources
Im getting an error
$ mkdir ../../bin/Release_Linux/Resources
mkdir: cannot create directory ‘../../bin/Release_Linux/Resources’: No such file or directory
Or just
mkdir Release_Linux/Resources
mkdir: cannot create directory ‘Release_Linux/Resources’: No such file or directory
command-line mkdir
|
show 3 more comments
up vote
1
down vote
favorite
When I run
mkdir ../../bin/Release_Linux/Resources
Im getting an error
$ mkdir ../../bin/Release_Linux/Resources
mkdir: cannot create directory ‘../../bin/Release_Linux/Resources’: No such file or directory
Or just
mkdir Release_Linux/Resources
mkdir: cannot create directory ‘Release_Linux/Resources’: No such file or directory
command-line mkdir
4
It's because at least one of the sub-directories doesn't exist. What do you mean by../../bin
? In my opinion it must be/bin
. Where are you creating the directory? I think there is no folder likeRelease_Linux
available by default.
– Kulfy
Nov 28 at 15:44
4
Possible duplicate of How do I recursively create a folder inside another unexistent folder?
– Kulfy
Nov 28 at 18:48
2
@Kulfy It doesn't have to be/bin
. Consider for example~/bin
which is often used for user's personal scripts. OP might be trying to create a directory like that for another user in their home directory. Or even a directory to package a debian package
– Sergiy Kolodyazhnyy
Nov 29 at 4:12
2
As far as duplicate thing goes, I've taken liberty to close the linked duplicate and another question ( that's this one ) as duplicate of this question, since it's newer and shinier and shows up #1 on Google. Note that this can always be re-opened and edited. Feel free to ask any cmmand-line tag gold badge holders to re-open and close as necessary. Answers are indeed the same, although this one is more specific towards resolving an error message. Either way, solutions are the same.
– Sergiy Kolodyazhnyy
Nov 29 at 8:28
3
related Create file and its parent directory
– Zanna
Nov 29 at 8:32
|
show 3 more comments
up vote
1
down vote
favorite
up vote
1
down vote
favorite
When I run
mkdir ../../bin/Release_Linux/Resources
Im getting an error
$ mkdir ../../bin/Release_Linux/Resources
mkdir: cannot create directory ‘../../bin/Release_Linux/Resources’: No such file or directory
Or just
mkdir Release_Linux/Resources
mkdir: cannot create directory ‘Release_Linux/Resources’: No such file or directory
command-line mkdir
When I run
mkdir ../../bin/Release_Linux/Resources
Im getting an error
$ mkdir ../../bin/Release_Linux/Resources
mkdir: cannot create directory ‘../../bin/Release_Linux/Resources’: No such file or directory
Or just
mkdir Release_Linux/Resources
mkdir: cannot create directory ‘Release_Linux/Resources’: No such file or directory
command-line mkdir
command-line mkdir
edited Nov 29 at 0:09
muru
134k19285484
134k19285484
asked Nov 28 at 15:41
Slobodan Vidovic
326
326
4
It's because at least one of the sub-directories doesn't exist. What do you mean by../../bin
? In my opinion it must be/bin
. Where are you creating the directory? I think there is no folder likeRelease_Linux
available by default.
– Kulfy
Nov 28 at 15:44
4
Possible duplicate of How do I recursively create a folder inside another unexistent folder?
– Kulfy
Nov 28 at 18:48
2
@Kulfy It doesn't have to be/bin
. Consider for example~/bin
which is often used for user's personal scripts. OP might be trying to create a directory like that for another user in their home directory. Or even a directory to package a debian package
– Sergiy Kolodyazhnyy
Nov 29 at 4:12
2
As far as duplicate thing goes, I've taken liberty to close the linked duplicate and another question ( that's this one ) as duplicate of this question, since it's newer and shinier and shows up #1 on Google. Note that this can always be re-opened and edited. Feel free to ask any cmmand-line tag gold badge holders to re-open and close as necessary. Answers are indeed the same, although this one is more specific towards resolving an error message. Either way, solutions are the same.
– Sergiy Kolodyazhnyy
Nov 29 at 8:28
3
related Create file and its parent directory
– Zanna
Nov 29 at 8:32
|
show 3 more comments
4
It's because at least one of the sub-directories doesn't exist. What do you mean by../../bin
? In my opinion it must be/bin
. Where are you creating the directory? I think there is no folder likeRelease_Linux
available by default.
– Kulfy
Nov 28 at 15:44
4
Possible duplicate of How do I recursively create a folder inside another unexistent folder?
– Kulfy
Nov 28 at 18:48
2
@Kulfy It doesn't have to be/bin
. Consider for example~/bin
which is often used for user's personal scripts. OP might be trying to create a directory like that for another user in their home directory. Or even a directory to package a debian package
– Sergiy Kolodyazhnyy
Nov 29 at 4:12
2
As far as duplicate thing goes, I've taken liberty to close the linked duplicate and another question ( that's this one ) as duplicate of this question, since it's newer and shinier and shows up #1 on Google. Note that this can always be re-opened and edited. Feel free to ask any cmmand-line tag gold badge holders to re-open and close as necessary. Answers are indeed the same, although this one is more specific towards resolving an error message. Either way, solutions are the same.
– Sergiy Kolodyazhnyy
Nov 29 at 8:28
3
related Create file and its parent directory
– Zanna
Nov 29 at 8:32
4
4
It's because at least one of the sub-directories doesn't exist. What do you mean by
../../bin
? In my opinion it must be /bin
. Where are you creating the directory? I think there is no folder like Release_Linux
available by default.– Kulfy
Nov 28 at 15:44
It's because at least one of the sub-directories doesn't exist. What do you mean by
../../bin
? In my opinion it must be /bin
. Where are you creating the directory? I think there is no folder like Release_Linux
available by default.– Kulfy
Nov 28 at 15:44
4
4
Possible duplicate of How do I recursively create a folder inside another unexistent folder?
– Kulfy
Nov 28 at 18:48
Possible duplicate of How do I recursively create a folder inside another unexistent folder?
– Kulfy
Nov 28 at 18:48
2
2
@Kulfy It doesn't have to be
/bin
. Consider for example ~/bin
which is often used for user's personal scripts. OP might be trying to create a directory like that for another user in their home directory. Or even a directory to package a debian package– Sergiy Kolodyazhnyy
Nov 29 at 4:12
@Kulfy It doesn't have to be
/bin
. Consider for example ~/bin
which is often used for user's personal scripts. OP might be trying to create a directory like that for another user in their home directory. Or even a directory to package a debian package– Sergiy Kolodyazhnyy
Nov 29 at 4:12
2
2
As far as duplicate thing goes, I've taken liberty to close the linked duplicate and another question ( that's this one ) as duplicate of this question, since it's newer and shinier and shows up #1 on Google. Note that this can always be re-opened and edited. Feel free to ask any cmmand-line tag gold badge holders to re-open and close as necessary. Answers are indeed the same, although this one is more specific towards resolving an error message. Either way, solutions are the same.
– Sergiy Kolodyazhnyy
Nov 29 at 8:28
As far as duplicate thing goes, I've taken liberty to close the linked duplicate and another question ( that's this one ) as duplicate of this question, since it's newer and shinier and shows up #1 on Google. Note that this can always be re-opened and edited. Feel free to ask any cmmand-line tag gold badge holders to re-open and close as necessary. Answers are indeed the same, although this one is more specific towards resolving an error message. Either way, solutions are the same.
– Sergiy Kolodyazhnyy
Nov 29 at 8:28
3
3
related Create file and its parent directory
– Zanna
Nov 29 at 8:32
related Create file and its parent directory
– Zanna
Nov 29 at 8:32
|
show 3 more comments
2 Answers
2
active
oldest
votes
up vote
19
down vote
accepted
Probably a parent directory in the path does not exist.
You can try with
mkdir -p /path-to-directory/directory-name
See man mkdir
-p, --parents
no error if existing, make parent directories as needed
If you get a permission denied
error, you have not permissions to create a directory in the specified path.
Check if you can get around the problem by modifying the group membership or ownership, so that you get the permission needed for the whole directory path involved.
Otherwise you need elevated permissions, so try with sudo
sudo mkdir -p /path-to-directory/directory-name
1
Note that elevated permission might be an overkill. If a user belongs to group which also owns the directory AND there's write permission to group set on that directory, there's no need forsudo
in that case. Things can get more complex with ACL permissions, but general gist is that group ownership should remove the sudo need
– Sergiy Kolodyazhnyy
Nov 29 at 8:32
Yes, why mentionsudo
at all? There is no indication of a permissions issue and people abusesudo
too much already.
– terdon♦
Nov 29 at 11:57
@terdon, I mentionsudo
only as a second alternative, ifmkdir -p
does not work without it. I agree with @ Sergiy, that it might be better to use group membership/ownership in some cases, but I think there remain several cases, wheresudo
is necessary.
– sudodus
Nov 29 at 12:05
In those cases, you get a permission denied error, which is not the case here. So since sudo isn't relevant to this case, and since using sudo when it isn't needed can be dangerous, why mention it at all?
– terdon♦
Nov 29 at 12:36
@terdon, Is it better now, that I have lowered the priority of thesudo
alternative?
– sudodus
Nov 29 at 12:48
|
show 1 more comment
up vote
6
down vote
sudodus's answer appropriately addresses how to create all directories along the given path. Alternative way would be via Python. This is especially useful if you're developing software for Ubuntu in Python and need such functionality. Calling mkdir
as external command would add overhead of additional process and extra forking which would waste resources. Luckily Python's standard library, specifically os
module has makedirs()
function:
$ python3 -c 'import os,sys;os.makedirs(sys.argv[1])' test_1/test2/test_3
$ tree test_1
test_1
└── test2
└── test_3
2 directories, 0 files
Note that such behavior also can be achieved in Perl, which is another scripting language that comes by default with Ubuntu.
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
19
down vote
accepted
Probably a parent directory in the path does not exist.
You can try with
mkdir -p /path-to-directory/directory-name
See man mkdir
-p, --parents
no error if existing, make parent directories as needed
If you get a permission denied
error, you have not permissions to create a directory in the specified path.
Check if you can get around the problem by modifying the group membership or ownership, so that you get the permission needed for the whole directory path involved.
Otherwise you need elevated permissions, so try with sudo
sudo mkdir -p /path-to-directory/directory-name
1
Note that elevated permission might be an overkill. If a user belongs to group which also owns the directory AND there's write permission to group set on that directory, there's no need forsudo
in that case. Things can get more complex with ACL permissions, but general gist is that group ownership should remove the sudo need
– Sergiy Kolodyazhnyy
Nov 29 at 8:32
Yes, why mentionsudo
at all? There is no indication of a permissions issue and people abusesudo
too much already.
– terdon♦
Nov 29 at 11:57
@terdon, I mentionsudo
only as a second alternative, ifmkdir -p
does not work without it. I agree with @ Sergiy, that it might be better to use group membership/ownership in some cases, but I think there remain several cases, wheresudo
is necessary.
– sudodus
Nov 29 at 12:05
In those cases, you get a permission denied error, which is not the case here. So since sudo isn't relevant to this case, and since using sudo when it isn't needed can be dangerous, why mention it at all?
– terdon♦
Nov 29 at 12:36
@terdon, Is it better now, that I have lowered the priority of thesudo
alternative?
– sudodus
Nov 29 at 12:48
|
show 1 more comment
up vote
19
down vote
accepted
Probably a parent directory in the path does not exist.
You can try with
mkdir -p /path-to-directory/directory-name
See man mkdir
-p, --parents
no error if existing, make parent directories as needed
If you get a permission denied
error, you have not permissions to create a directory in the specified path.
Check if you can get around the problem by modifying the group membership or ownership, so that you get the permission needed for the whole directory path involved.
Otherwise you need elevated permissions, so try with sudo
sudo mkdir -p /path-to-directory/directory-name
1
Note that elevated permission might be an overkill. If a user belongs to group which also owns the directory AND there's write permission to group set on that directory, there's no need forsudo
in that case. Things can get more complex with ACL permissions, but general gist is that group ownership should remove the sudo need
– Sergiy Kolodyazhnyy
Nov 29 at 8:32
Yes, why mentionsudo
at all? There is no indication of a permissions issue and people abusesudo
too much already.
– terdon♦
Nov 29 at 11:57
@terdon, I mentionsudo
only as a second alternative, ifmkdir -p
does not work without it. I agree with @ Sergiy, that it might be better to use group membership/ownership in some cases, but I think there remain several cases, wheresudo
is necessary.
– sudodus
Nov 29 at 12:05
In those cases, you get a permission denied error, which is not the case here. So since sudo isn't relevant to this case, and since using sudo when it isn't needed can be dangerous, why mention it at all?
– terdon♦
Nov 29 at 12:36
@terdon, Is it better now, that I have lowered the priority of thesudo
alternative?
– sudodus
Nov 29 at 12:48
|
show 1 more comment
up vote
19
down vote
accepted
up vote
19
down vote
accepted
Probably a parent directory in the path does not exist.
You can try with
mkdir -p /path-to-directory/directory-name
See man mkdir
-p, --parents
no error if existing, make parent directories as needed
If you get a permission denied
error, you have not permissions to create a directory in the specified path.
Check if you can get around the problem by modifying the group membership or ownership, so that you get the permission needed for the whole directory path involved.
Otherwise you need elevated permissions, so try with sudo
sudo mkdir -p /path-to-directory/directory-name
Probably a parent directory in the path does not exist.
You can try with
mkdir -p /path-to-directory/directory-name
See man mkdir
-p, --parents
no error if existing, make parent directories as needed
If you get a permission denied
error, you have not permissions to create a directory in the specified path.
Check if you can get around the problem by modifying the group membership or ownership, so that you get the permission needed for the whole directory path involved.
Otherwise you need elevated permissions, so try with sudo
sudo mkdir -p /path-to-directory/directory-name
edited Nov 29 at 12:47
answered Nov 28 at 15:46
sudodus
21.7k32871
21.7k32871
1
Note that elevated permission might be an overkill. If a user belongs to group which also owns the directory AND there's write permission to group set on that directory, there's no need forsudo
in that case. Things can get more complex with ACL permissions, but general gist is that group ownership should remove the sudo need
– Sergiy Kolodyazhnyy
Nov 29 at 8:32
Yes, why mentionsudo
at all? There is no indication of a permissions issue and people abusesudo
too much already.
– terdon♦
Nov 29 at 11:57
@terdon, I mentionsudo
only as a second alternative, ifmkdir -p
does not work without it. I agree with @ Sergiy, that it might be better to use group membership/ownership in some cases, but I think there remain several cases, wheresudo
is necessary.
– sudodus
Nov 29 at 12:05
In those cases, you get a permission denied error, which is not the case here. So since sudo isn't relevant to this case, and since using sudo when it isn't needed can be dangerous, why mention it at all?
– terdon♦
Nov 29 at 12:36
@terdon, Is it better now, that I have lowered the priority of thesudo
alternative?
– sudodus
Nov 29 at 12:48
|
show 1 more comment
1
Note that elevated permission might be an overkill. If a user belongs to group which also owns the directory AND there's write permission to group set on that directory, there's no need forsudo
in that case. Things can get more complex with ACL permissions, but general gist is that group ownership should remove the sudo need
– Sergiy Kolodyazhnyy
Nov 29 at 8:32
Yes, why mentionsudo
at all? There is no indication of a permissions issue and people abusesudo
too much already.
– terdon♦
Nov 29 at 11:57
@terdon, I mentionsudo
only as a second alternative, ifmkdir -p
does not work without it. I agree with @ Sergiy, that it might be better to use group membership/ownership in some cases, but I think there remain several cases, wheresudo
is necessary.
– sudodus
Nov 29 at 12:05
In those cases, you get a permission denied error, which is not the case here. So since sudo isn't relevant to this case, and since using sudo when it isn't needed can be dangerous, why mention it at all?
– terdon♦
Nov 29 at 12:36
@terdon, Is it better now, that I have lowered the priority of thesudo
alternative?
– sudodus
Nov 29 at 12:48
1
1
Note that elevated permission might be an overkill. If a user belongs to group which also owns the directory AND there's write permission to group set on that directory, there's no need for
sudo
in that case. Things can get more complex with ACL permissions, but general gist is that group ownership should remove the sudo need– Sergiy Kolodyazhnyy
Nov 29 at 8:32
Note that elevated permission might be an overkill. If a user belongs to group which also owns the directory AND there's write permission to group set on that directory, there's no need for
sudo
in that case. Things can get more complex with ACL permissions, but general gist is that group ownership should remove the sudo need– Sergiy Kolodyazhnyy
Nov 29 at 8:32
Yes, why mention
sudo
at all? There is no indication of a permissions issue and people abuse sudo
too much already.– terdon♦
Nov 29 at 11:57
Yes, why mention
sudo
at all? There is no indication of a permissions issue and people abuse sudo
too much already.– terdon♦
Nov 29 at 11:57
@terdon, I mention
sudo
only as a second alternative, if mkdir -p
does not work without it. I agree with @ Sergiy, that it might be better to use group membership/ownership in some cases, but I think there remain several cases, where sudo
is necessary.– sudodus
Nov 29 at 12:05
@terdon, I mention
sudo
only as a second alternative, if mkdir -p
does not work without it. I agree with @ Sergiy, that it might be better to use group membership/ownership in some cases, but I think there remain several cases, where sudo
is necessary.– sudodus
Nov 29 at 12:05
In those cases, you get a permission denied error, which is not the case here. So since sudo isn't relevant to this case, and since using sudo when it isn't needed can be dangerous, why mention it at all?
– terdon♦
Nov 29 at 12:36
In those cases, you get a permission denied error, which is not the case here. So since sudo isn't relevant to this case, and since using sudo when it isn't needed can be dangerous, why mention it at all?
– terdon♦
Nov 29 at 12:36
@terdon, Is it better now, that I have lowered the priority of the
sudo
alternative?– sudodus
Nov 29 at 12:48
@terdon, Is it better now, that I have lowered the priority of the
sudo
alternative?– sudodus
Nov 29 at 12:48
|
show 1 more comment
up vote
6
down vote
sudodus's answer appropriately addresses how to create all directories along the given path. Alternative way would be via Python. This is especially useful if you're developing software for Ubuntu in Python and need such functionality. Calling mkdir
as external command would add overhead of additional process and extra forking which would waste resources. Luckily Python's standard library, specifically os
module has makedirs()
function:
$ python3 -c 'import os,sys;os.makedirs(sys.argv[1])' test_1/test2/test_3
$ tree test_1
test_1
└── test2
└── test_3
2 directories, 0 files
Note that such behavior also can be achieved in Perl, which is another scripting language that comes by default with Ubuntu.
add a comment |
up vote
6
down vote
sudodus's answer appropriately addresses how to create all directories along the given path. Alternative way would be via Python. This is especially useful if you're developing software for Ubuntu in Python and need such functionality. Calling mkdir
as external command would add overhead of additional process and extra forking which would waste resources. Luckily Python's standard library, specifically os
module has makedirs()
function:
$ python3 -c 'import os,sys;os.makedirs(sys.argv[1])' test_1/test2/test_3
$ tree test_1
test_1
└── test2
└── test_3
2 directories, 0 files
Note that such behavior also can be achieved in Perl, which is another scripting language that comes by default with Ubuntu.
add a comment |
up vote
6
down vote
up vote
6
down vote
sudodus's answer appropriately addresses how to create all directories along the given path. Alternative way would be via Python. This is especially useful if you're developing software for Ubuntu in Python and need such functionality. Calling mkdir
as external command would add overhead of additional process and extra forking which would waste resources. Luckily Python's standard library, specifically os
module has makedirs()
function:
$ python3 -c 'import os,sys;os.makedirs(sys.argv[1])' test_1/test2/test_3
$ tree test_1
test_1
└── test2
└── test_3
2 directories, 0 files
Note that such behavior also can be achieved in Perl, which is another scripting language that comes by default with Ubuntu.
sudodus's answer appropriately addresses how to create all directories along the given path. Alternative way would be via Python. This is especially useful if you're developing software for Ubuntu in Python and need such functionality. Calling mkdir
as external command would add overhead of additional process and extra forking which would waste resources. Luckily Python's standard library, specifically os
module has makedirs()
function:
$ python3 -c 'import os,sys;os.makedirs(sys.argv[1])' test_1/test2/test_3
$ tree test_1
test_1
└── test2
└── test_3
2 directories, 0 files
Note that such behavior also can be achieved in Perl, which is another scripting language that comes by default with Ubuntu.
answered Nov 29 at 8:41
Sergiy Kolodyazhnyy
68k9142301
68k9142301
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f1096849%2fcant-make-new-dir-with-mkdir%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
4
It's because at least one of the sub-directories doesn't exist. What do you mean by
../../bin
? In my opinion it must be/bin
. Where are you creating the directory? I think there is no folder likeRelease_Linux
available by default.– Kulfy
Nov 28 at 15:44
4
Possible duplicate of How do I recursively create a folder inside another unexistent folder?
– Kulfy
Nov 28 at 18:48
2
@Kulfy It doesn't have to be
/bin
. Consider for example~/bin
which is often used for user's personal scripts. OP might be trying to create a directory like that for another user in their home directory. Or even a directory to package a debian package– Sergiy Kolodyazhnyy
Nov 29 at 4:12
2
As far as duplicate thing goes, I've taken liberty to close the linked duplicate and another question ( that's this one ) as duplicate of this question, since it's newer and shinier and shows up #1 on Google. Note that this can always be re-opened and edited. Feel free to ask any cmmand-line tag gold badge holders to re-open and close as necessary. Answers are indeed the same, although this one is more specific towards resolving an error message. Either way, solutions are the same.
– Sergiy Kolodyazhnyy
Nov 29 at 8:28
3
related Create file and its parent directory
– Zanna
Nov 29 at 8:32