7

In order to change both a file's owner and group we can do this:

chown trump file
chgrp trump file

but can I do both commands in one approach or one command?

  • Why the downvotes? – kevin Aug 21 '17 at 8:01
16

per chown man page chown user:group file:

chown trump:trump file
  • 5
    Or chown trump: file if trump is the primary group of user trump – xhienne Aug 3 '17 at 15:52
  • Or chown user.group filename or chown .group filename – ivanivan Aug 3 '17 at 17:11
  • 4
    POSIX specifies allowed characters for user and group names. (pubs.opengroup.org/onlinepubs/9699919799/basedefs/…) The BSD chown manual states "Previous versions of the chown utility used the dot (.) character to distinguish the group name. This has been changed to be a colon (:) character, so that user and group names may contain the dot character." The RHEL man page for chown does not have that usage note. Nonetheless, there are reasons to abstain from using the . character. – Christopher Aug 3 '17 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.