When creating directories, mkdir -m <mode> <dir> provides for creating one or more directories with the given mode/permissions set (atomically).Is there an equivalent for creating files, on the command line?Something akin to:open(file, O_WRONLY | O_APPEND | O_CREAT, 0777);Is using touch followed by a chmod my only option here?Edit: After trying out teppic's suggestion to use install, I ran it through strace to see how close to atomic it was. The answer is, not very:$ strace install -m 777 /dev/null newfile...open(newfile, O_WRONLY|O_CREAT|O_EXCL, 0666) = 4fstat(4, {st_mode=S_IFREG|0666, st_size=0, ...}) = 0...fchmod(4, 0600)                         = 0close(4)                                = 0...chmod(newfile, 0777)                  = 0...Still, it's a single shell command and one I didn't know before.
Can files be created with permissions set on the command line?
shell;permissions;files
You could use the install command (part of GNU coreutils) with a dummy file, e.g.$ install -b -m 755 /dev/null newfileThe -b option backs up 'newfile' if it already exists. You can use this command to set the owner as well.