3

I created some files as root that I would now like to be changed to a specific user. How would I do this? I cannot go trough the files one by one as that'd just take way too much time. I would like to do this preferably trough Nautilus. If there is an easier way to do it trough console though, I'm all in.

Jeroen
  • 443
  • 3
  • 10
  • 25
  • exact duplicated http://askubuntu.com/questions/30629/how-can-i-recursively-change-the-permissions-of-files-and-directories – Braiam Sep 21 '13 at 13:25
  • 1
    @Braiam This is not a duplicate; It's related but the questioner wants to change the owner not just the permissions. – Warren Hill Sep 21 '13 at 13:27
  • @WarrenHill actually that's the plus, both commands there, for permissions and owner. Please read the answers. The two most voted has chown and chmod. **"Change the ownership of the files in /var/www: sudo chown -R www-data:www-data /var/www"** – Braiam Sep 21 '13 at 13:31
  • @Braiam I still think this one should be kept though as that one didn't pop into the search results and thus it probably won't either for other people. – Jeroen Sep 21 '13 at 13:33
  • @Binero that was the third result as the two first where only about permissions and I was looking with your exact title http://i.stack.imgur.com/wd33T.png – Braiam Sep 21 '13 at 13:37

1 Answers1

11

I'm not aware of any way you can do this in nautilus but you can do it from a command line

For example I have the following files in a directory

$ ls -la
total 400
drwxrwxr-x  2 warren warren   4096 Jun 22 17:49 .
drwxr-xr-x 74 warren warren  20480 Sep 21 13:05 ..
-rwxrwxr-x  1 root   root      199 Jun 22 18:02 ex1.py
-rwxrwxr-x  1 root   root       43 Jun 22 17:45 hello.py
-rw-rw-r--  1 root   root    27792 May 27 15:18 img.txt
-rw-rw-r--  1 root   root   323944 May 27 15:16 img.xcf
-rwxrwxr-x  1 root   root     3178 Jun  7 22:11 snake.py
-rw-rw-r--  1 root   root     3182 Jun  4 20:20 snake.py~
-rwxrwxr-x  1 root   root     7242 May 27 09:26 test
-rw-rw-r--  1 root   root      821 May 27 09:25 test.c

You can change all these to be owned by the user warren with:

sudo chown -R warren:warren *

As shown

warren@dell:~/test$ sudo chown warren:warren *
warren@dell:~/test$ ls -la
total 400
drwxrwxr-x  2 warren warren   4096 Jun 22 17:49 .
drwxr-xr-x 74 warren warren  20480 Sep 21 13:05 ..
-rwxrwxr-x  1 warren warren    199 Jun 22 18:02 ex1.py
-rwxrwxr-x  1 warren warren     43 Jun 22 17:45 hello.py
-rw-rw-r--  1 warren warren  27792 May 27 15:18 img.txt
-rw-rw-r--  1 warren warren 323944 May 27 15:16 img.xcf
-rwxrwxr-x  1 warren warren   3178 Jun  7 22:11 snake.py
-rw-rw-r--  1 warren warren   3182 Jun  4 20:20 snake.py~
-rwxrwxr-x  1 warren warren   7242 May 27 09:26 test
-rw-rw-r--  1 warren warren    821 May 27 09:25 test.c

the -R option means recursive; i.e. including sub-directories for more information enter man chown in a terminal.

Warren Hill
  • 21,832
  • 28
  • 67
  • 88