# Ubuntu – Change owner of files recursively, but not directories

chownpermissions

I have a directory that has ~50k directories and ~1m files.

I want to change owner (or permission) of all files, but not the directories. This is because i'm trying to SCP additional files from a remote server, (~150k directories and ~3.6m files).

The directory I have is a part of the remote directory, but the scp failed…

If i run SCP again, it will start over by overwriting the files i already copied from the remote directory.

#### Best Answer

You can use find, it has an added advantage that the ARG_MAX will not be triggered in the process. From the parent directory:

find . -type f -exec chown newowner {} +


For chmod:

find . -type f -exec chmod 644 {} +


-type f will find only files.