How to change the permission and group-owner of a file at the same time

chmodchownfiles

For changing file permission, I know I could use chmod. For changing group-owner, I could use chgrp. However, if I want to change both permission and owner at the same time, any command I could use on Linux?

For example, there is a file with this permission and owner:

-rw-r--r--+  1 raymondtau  staff    0 May  8 16:38 WantToChangeThisFile

And now I want to change it to:

---x-w--wx+  1 raymondtau  admin    0 May  8 16:38 WantToChangeThisFile

I know I could use this command: chmod 123 WantToChangeThisFile && chgrp admin WantToChangeThisFile, but want to know if there is any neat way to do that.

Best Answer

If what you also want is to copy the file somewhere (like its final destination), you might want to have a look at the install command:

install -m 0777 -o root $sourcefile $destinationfile

Related Question