Rename user account / move user data

Hello all,

I am using Nextcloud 11.0.3. I am looking for a possibility to rename an account name. Goal is to take away access to data to one account. Is there any way? What I can think of:

  • Rename the account
  • Create a new account and move all files (incl. access rights) from old to new account.

I hope that someone can help me.

If the main goal is to disable access, then you could also (as admin) just change the password of that account. That way all files stay in place and all shares are still valid.

There is no proper rename option on the system, the only option would be to migrate the account to a new one using the occ command with the function:

files:transfer-ownership All files and folders are moved to another user - shares are moved as well.

The syntax would be then:

sudo -u www-data php occ files:transfer-ownership <source-user> <destination-user>

UPDATE 03-02-2021: From the latest reply I noticed I put the wrong command in, so corrected the first command

Thanks for the help - the transfer seems to be a good solution. What are the exact steps? The question I have are:

  1. I have to create the new account - correct?
  2. Do I manually have to copy the data-folder from the old to the new account and then transfer ownership?
  3. Are there other points I should do?

You are correct with the steps:

  1. Create a new user
  2. Use the occ command to move the files over.

This process is done by the occ command itself, so you don’t need to do any manual moving of files. That would do the whole migration and nothing else would be required.

Hi - I am aware this is almost a dead conversation but I just tried your solution on a NextcloudPi
with the following system info
|NextCloudPi version|v1.34.7|

|NextCloudPi image|NextCloudPi_09-05-20|

|distribution|Raspbian GNU/Linux 10 \n \l|

Below is the output from the command you recommended. Any suggestions on how to resolve it?

pi@nextcloudpi:~ $ php -u www-data php occ files:transfer-ownership Sherab1  Sherab10      
Error in argument 1, char 2: option not found u

I guess it should be
sudo -u www-data php occ files:transfer-ownership Sherab1 Sherab10

I get the following error when I try to execute the command:

In Local.php line 339:

  Invalid path

The transfer doesn’t work…what I’m doing wrong? Using Nextcloud 20