Search code examples
linuxbashshmkdir

Using mkdir -m -p and chown together correctly


I would like to create a directory using a bash script and then set the mode to 00755 at the same time

mkdir -p -m=00755 "/dir/dir2"

Is this the correct way of using them together and can I also add chown command to the same line while creating them?


Solution

  • It goes a little like this:

    install -d -m 0755 -o someuser -g somegroup /dir/dir2