Score:0

sudo mkdir -p parent/child | Permission Denied

th flag

This seems like such a Day 0 problem. I need to create a 2-level folder structure.

I tried:

sudo mkdir parent/child
>>> mkdir: cannot create directory ‘parent/child’: No such file or directory
sudo mkdir -p parent/child
>>> mkdir: cannot create directory ‘parent’: Permission denied
in flag
Can I understand the objective? You want to make a directory called “parent” (for example), then create a directory inside “parent” called “child” (for example). Is this correct? Or do you want to make a directory that has a slash in its name?
StressedBoi69420 avatar
th flag
2 folders, one inside the other
Soren A avatar
mx flag
In what directory are you trying to create parent/child ?
hr flag
... I wonder if it's on a NFS mount with `root_squash` or similar?
Score:0
in flag

Most file systems do not work in a fashion similar to S3 block storage, making the automatic generation of what appears to be a fully-qualified path an automagical process. Generally, to do what you are attempting to do, a person would perform these actions:

mkdir parent
mkdir parent/child

However, if you insist on doing this as a one-liner, you can try this:

mkdir -p ~/{parent/{child}}

What’s nice about this is that you can create multiple directories pretty much simultaneously:

mkdir -p ~/{parent/{child1,child2,child3},uncle,aunt,Morty}

This will give you lots of directories all at once, so long as you remember -p and the curly brackets

terdon avatar
cn flag
There is no reason I can think of on a regular Linux file system why `mkdir -p foo/bar` would not work. That's the entire point of the GNU `-p` option to `mkdir`. More importantly, if `mkdir -p ~/{parent/{child}}` works, then so does `mkdir -p ~/parent/child` the braces aren't doing anything useful here. In fact, they are breaking things: your command will create a directory called `~/{parent` and a subdirectory in that named `{child}}`. Try it. Brace expansion only works with commas.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.