code: def chown(dirs, user=None, group=None):
      
      if isinstance(dirs, basestring):
          dirs = [dirs]
      args = ' '.join(dirs)
      if user and group:
          return sudo('chown {}:{} {}'.format(user, group, args))
      elif user:
          return sudo('chown {} {}'.format(user, args))
      elif group:
          return sudo('chgrp {} {}'.format(group, args))
      else:
          return None
docs: User sudo to set user and group ownership