single command for creating file and setting permission to it.
Hi All,
I want to know is there is any command which let me create file and set to some permission(other than default). Like we can do with directories with command mkdir -m 777 testdir Some where I found "install" command. But again i successfully able to create directory from it, not file. Is there is any way to do it. Or we should follow touch file;chmod 777 file command itself. Thanks in Advance. :) |
No 'single command'. EDIT: corrected to Yes, in post#5 below; see man install
Have a study of: man creat There's always umask: https://unix.stackexchange.com/quest...-touch-command Oh, maybe visit my favorite command: strace ;) Enjoy your Linux! |
It depends on how you define "single command". You can string several commands into one "script", and run the script as a single command. But caveats, as when you lose the script you might not remember the commands. And if you're on someone else's system, they wont have your script.
|
correct it is more done in steps, first create, then change permissions two commands one line
Code:
$⚡ ~ ⚡> touch changePermissionsOnMe ; chmod 777 changePermissionsOnMe |
A *single* command!
Oh: ooops: I found this (/dev/null 'trick' to make install 'work'):
https://unix.stackexchange.com/quest...e-command-line Code:
install -m 7666 /dev/null MYrwSrwSrwT p.s. Got milkstdin?: echo hi | install -m 7666 /dev/stdin MYrwSrwSrwT |
Thanks Jjanel
Its worked $install -m 755 /dev/null newfile |
All times are GMT -5. The time now is 03:50 PM. |