Question: Let's say i have a directory, at:

* `/tmp/uploads/`

And inside got several recursive directories and files created by DIFFERENT USERS before.

So now, suddenly how do i make that above directory to be **writable by root only**? 

Which means, the existing whatever users won't be suddenly able to write at all (but read only). So then only `root` will be able to write any further.

---

**Very importantly, i can NOT lose the original ownership *(who owns what)* of the things inside.**

---

Which also means, after all, i am trying to LOCK the directory for security reason.

Thank you.

Answer: 
Use attributes:

```
chattr -R +i files

```

(as root) will add the `+i` attribute recursively to your folders and files which will prevent ANY alternations. Note that root will also be locked and you would need to unset the `i` manually every time. Ownership and alike will be left unchanged.
First change user and group to root 

`chown -R root:root /tmp/uploads`

then change permissions so that only root can write 

`chmod -R 755 /tmp/uploads`

EDIT:

If you only need to restore files owners, I would save your files and owner in a file (There sure are better ways to do this, but this is the first thing that comes to my mind). Be sure /tmp/old\_file\_owners doesn't exist before runing the next:

`for i in $(find /tmp/uploads);do ls -ld $i|awk -vf=$i '{if (NF==9) {print $3 ":" $4 " " f}}'>>/tmp/old_file_owners; done`

and when you want to restore your files' owners, just do a 

`IFS=$'\n';for i in $(cat /tmp/old_file_owners);do chown $i;done`

If you want to keep original file permissions more info will need to be stored in your file, but you can use the previous as a reference and do your stuff like that.