Using mkdir -m -p and chown together correctly

jquery picture jquery · Sep 16, 2014 · Viewed 22k times · Source

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?

Answer

Ignacio Vazquez-Abrams picture Ignacio Vazquez-Abrams · Sep 16, 2014

It goes a little like this:

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