Prior to working on/modifying a file, use the ‘install -m’ command which can both copy files, create directories, and set their permissions at the same time. Useful when you are working in the public_html folder and need to keep the copied file hidden from the world.

#install -m 0400 foo bar/

#install -m 0400 a.txt{,.bak}
-rw-r--r-- 1 user user 653 Feb 27 14:26 a.txt
-r-------- 1 root root 653 Feb 27 15:58 a.txt.bak

Was this post helpful?