Use the command chown to set owner.
333739
@Override
  public void setOwner(Path p, String username, String groupname
      ) throws IOException {
    if (username == null && groupname == null) {
      throw new IOException("username == null && groupname == null");
    }

    if (username == null) {
      execCommand(pathToFile(p), Shell.SET_GROUP_COMMAND, groupname); 
    } else {
      //OWNER[:[GROUP]]
      String s = username + (groupname == null? "": ":" + groupname);
      execCommand(pathToFile(p), Shell.SET_OWNER_COMMAND, s);
    }
  }
223670
def get_owner(gh, owner):
    """"""
    try:
        u = gh.user(owner)
        name = u.name or u.login
        company = u.company or ''
        return [dict(name=name, affiliation=company)]
    except Exception:
        return None
635385
public void setOwner(ListenerOwner owner)
    {
        super.setOwner(owner);
        if (owner != null) if (m_recordToSync != null)
            m_recordToSync.addListener(new FileRemoveBOnCloseHandler(this));
    }
1133791
def is_owned_by_current_user(self):
        

        from bambou.nurest_root_object import NURESTRootObject
        root_object = NURESTRootObject.get_default_root_object()
        return self._owner == root_object.id
330802
public void setOwner(ListenerOwner owner)
    {
        super.setOwner(owner);
        if (this.getOwner() == null)
            return;
        if (m_fldDest.getRecord() != this.getOwner())  // If field is not in this file, remember to remove it
            m_fldDest.addListener(new FieldRemoveBOnCloseHandler(this));
        if (m_fldSource != null) if (m_fldSource.getRecord() != this.getOwner()) if (m_fldSource.getRecord() != m_fldDest.getRecord())
            m_fldSource.addListener(new FieldRemoveBOnCloseHandler(this));
        if ((this.getOwner().getEditMode() == DBConstants.EDIT_CURRENT) || (this.getOwner().getEditMode() == DBConstants.EDIT_IN_PROGRESS))
            if (m_bMoveOnValid)
                this.moveTheData(DBConstants.DISPLAY, DBConstants.INIT_MOVE);  // Do trigger a record change.
        if (this.getOwner().getEditMode() == DBConstants.EDIT_ADD)
            if (m_bMoveOnNew)
                this.moveTheData(DBConstants.DISPLAY, DBConstants.INIT_MOVE);  // Do trigger a record change.
    }
637797
public void setOwner(Path f, String user, String group) throws IOException {
    try (Closeable context = new TimerContextWithLog(this.setOwnerTimer.time(), "setOwner", f, user, group)) {
      super.setOwner(f, user, group);
    }
  }
865129
public void setOwner(ListenerOwner owner)
    {
        super.setOwner(owner);
        if (this.getOwner() == null)
            return;
        if (m_recordSub != null)    // If field is not in this file, remember to remove it
            m_recordSub.addListener(new FileRemoveBOnCloseHandler(this));
    }
867408
def transfer_owner(self, new_owner):
        """"""

        if not self.owner and not self.admin:
            raise RuntimeError("You need more street creed to do this")

        new_owner = new_owner.strip().lower()
        if not new_owner:
            raise ValueError("Empty strings cannot be new owners")

        self.__set_config_value("owner", new_owner)
927294
def set_ownership(self):
        """"""
        assert self.section is not None

        for t in self.children:
            t.parent = self
            t._section = self.section
            t.doc = self.doc
            t.set_ownership()
900617
def chown(path, user=None, group=None):
    """"""
    import os
    import pwd
    import grp
    uid = pwd.getpwnam(user).pw_uid if user else -1
    gid = grp.getgrnam(group).gr_gid if group else -1
    return os.chown(path, uid, gid)
546420
protected void setOwnerId(Integer id){
        if(getOwnerId() != null){
            logger.warn("Attempting to set owner id for an object where it as previously been set. Ignoring new id");
            return;
        }
        meta_put(OWNER_ID_KEY, id); // dont allow null
    }
278767
def set_owner(self, path, **kwargs):
        
        response = self._put(path, 'SETOWNER', **kwargs)
        assert not response.content
266727
def configure_owner(self, owner='www-data'):
        
        if owner is not None:
            self.main_process.set_owner_params(uid=owner, gid=owner)

        return self
14573
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
229642
def chown_tty(username)
      tty = `tty 2> /dev/null`.chomp
      @log.error("'tty' command failed") unless $?.success?

      if File.exists?(tty)
        %x(sudo chown #{Shellwords.escape(username)} #{Shellwords.escape(tty)})
        raise RuntimeError, "Failed to change ownership of #{tty}" unless $?.success?
        else
          @log.error("'tty' command did not give a reasonable answer: #{tty}")
      end
    end
468474
def SetTimelineOwner(self, username):
    
    self._timeline_owner = username
    logger.info('Owner of the timeline: {0!s}'.format(self._timeline_owner))
762510
def channels_add_owner(self, room_id, user_id=None, username=None, **kwargs):
        """"""
        if user_id:
            return self.__call_api_post('channels.addOwner', roomId=room_id, userId=user_id, kwargs=kwargs)
        elif username:
            return self.__call_api_post('channels.addOwner', roomId=room_id, username=username, kwargs=kwargs)
        else:
            raise RocketMissingParamException('userID or username required')