Help - Search - Members - Calendar
Full Version: How to chown to nobody
The Planet Forums > Control Panels > cPanel/WHM
goodman
Hi, everyone,

I backed up a website from one server to another server using wget http://domain.com/name.tar

I Unzip all the files in the new server and then using
chown -R username.username *

All the files and directories in the new server are owned by username. But

All the directories should owned by be nobody !

What commands should I use to change all the directories to nobody. And all the files remain username.

Thanks in advance!
Tomy Durden
It doesn't look like chown will restrict itself to recursively changing directories, but...

Go into the directory containing all of the directories you want to change. Keep in mind, this'll also change the current directory(".") but not the parent directory("..").

du |awk -F' ' '{ system("chown -R nobody:nobody " $2) }'


Also, make sure you test this on a smaller subset of directories just to make sure it does what you're wanting.

--

[root@transistor hi]# ls -la
total 44
drwxrwxr-x 5 test test 4096 Mar 13 13:37 .
drwx------ 5 test test 4096 Mar 13 13:32 ..
-rw-rw-r-- 1 test test 0 Mar 13 13:32 hello
drwxrwxr-x 2 test test 4096 Mar 13 13:37 test1
drwxrwxr-x 2 test test 4096 Mar 13 13:37 test2
drwxrwxr-x 2 test test 4096 Mar 13 13:37 test3

[root@transistor hi]# du |awk -F' ' '{ system("chown -R tdurden:tdurden " $2) }'

[root@transistor hi]# ls -la
total 44
drwxrwxr-x 5 tdurden tdurden 4096 Mar 13 13:37 .
drwx------ 5 test test 4096 Mar 13 13:32 ..
-rw-rw-r-- 1 test test 0 Mar 13 13:32 hello
drwxrwxr-x 2 tdurden tdurden 4096 Mar 13 13:37 test1
drwxrwxr-x 2 tdurden tdurden 4096 Mar 13 13:37 test2
drwxrwxr-x 2 tdurden tdurden 4096 Mar 13 13:37 test3

[root@transistor hi]# cd ..

[root@transistor test]# ls -la
total 72
drwx------ 5 test test 4096 Mar 13 13:32 .
drwxr-xr-x 4 root root 4096 Feb 23 20:43 ..
-rw------- 1 test test 2098 Mar 13 09:57 .bash_history
-rw-r--r-- 1 test test 33 Feb 23 20:42 .bash_logout
-rw-r--r-- 1 test test 176 Feb 23 20:42 .bash_profile
-rw-r--r-- 1 test test 142 Mar 2 09:41 .bashrc
drwxrwxr-x 5 tdurden tdurden 4096 Mar 13 13:37 hi
drwx------ 3 test test 4096 Mar 2 21:44 .irssi
drwxr-xr-x 4 test test 4096 Feb 23 20:42 .mozilla
Catalyst
That's the most creative way to do a `find -type d | xargs chown nobody.nobody` I've ever seen. ;-)
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.