Search code examples
bashpermissionsmkdir

Why might "mkdir -p" lead to a Bash permission error?


If I make a directory with mkdir -p, it causes problems with scripts

$ mkdir -p test2/test2

$ cd test2/test2

$ echo '#!/bin/sh
> echo hello' > hello.sh

$ ./hello.sh
bash: ./hello.sh: Permission denied

Solution

  • This is nothing to do with mkdir. You simply haven't given hello.sh executable permissions. You need the following:

    chmod +x hello.sh