How to create a directory and give permission in single command

后端 未结 8 1947
日久生厌
日久生厌 2021-01-29 23:27

How to create a directory and give permission in single command in Linux?

I have to create lots of folder with full permission 777.

Commands

8条回答
  •  北海茫月
    2021-01-29 23:41

    You could write a simple shell script, for example:

    #!/bin/bash
    mkdir "$1"
    chmod 777 "$1"
    

    Once saved, and the executable flag enabled, you could run it instead of mkdir and chmod:

    ./scriptname path/foldername
    

    However, alex's answer is much better because it spawns one process instead of three. I didn't know about the -m option.

提交回复
热议问题