shell script and chown
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix administration > shell script and chown




Pages (2): [1] 2 »   Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    shell script and chown  
Tony


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 09:51 PM

I moved user directories from one server to another

/home/username

after moving them the owner is root
group is root

I have over 200+ user directories

How do I change all the directories to their owners and groups without doing
it one by one

chown -R username.username userhomedir


Thanks








[ Post a follow-up to this message ]



    Re: shell script and chown  
Adam Price


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 09:51 PM

In news:r-adnQzjTLROqQKiRVn-gw@comcast.com,
Tony <tony.wong@comcast.net> typed:
quote:
> I moved user directories from one server to another > > /home/username > > after moving them the owner is root > group is root > > I have over 200+ user directories > > How do I change all the directories to their owners and groups > without doing it one by one > > chown -R username.username userhomedir > > > Thanks
untested... awk -F: 'BEGIN{print "#!/bin/sh"} {print "chown -R $1.$1 $6"}' /etc/passwd > fix.sh Should generate a script to fix the permissions. Check that fix.sh does what you want and then run it. Adam




[ Post a follow-up to this message ]



    Re: shell script and chown  
Bill Marcum


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 09:51 PM

On Tue, 28 Oct 2003 19:32:41 -0800, Tony
<tony.wong@comcast.net> wrote:
quote:
> I moved user directories from one server to another > > /home/username > > after moving them the owner is root > group is root >
How did you move the files?
quote:
> I have over 200+ user directories > > How do I change all the directories to their owners and groups without doi ng > it one by one >
Copy them the right way using, for example, (s)cp -a or rsync -a or tar. -- You can go anywhere you want if you look serious and carry a clipboard.




[ Post a follow-up to this message ]



    Re: shell script and chown  
phn@icke-reklam.ipsec.nu


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 09:51 PM

Tony <tony.wong@comcast.net> wrote:
quote:
> I moved user directories from one server to another
quote:
> /home/username
quote:
> after moving them the owner is root > group is root
quote:
> I have over 200+ user directories
quote:
> How do I change all the directories to their owners and groups without doi ng > it one by one
quote:
> chown -R username.username userhomedir
Using proper tools ( pax, cpio or simular) will preserve ownership and rights. Applying repeated commands cn be done with scripts. Do yourself a favor and start learning scripting, i'd recommend the "bash"-book from o'reilly.
quote:
> Thanks
-- Peter Håkanson IPSec Sverige ( At Gothenburg Riverside ) Sorry about my e-mail address, but i'm trying to keep spam out, remove "icke-reklam" if you feel for mailing me. Thanx.




[ Post a follow-up to this message ]



    Re: shell script and chown  
Tony


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 09:52 PM

scp -a -a is not an option?
"Bill Marcum" <bmarcum@iglou.com> wrote in message
news:oe2471-o1j.ln1@don.localnet...
quote:
> On Tue, 28 Oct 2003 19:32:41 -0800, Tony > <tony.wong@comcast.net> wrote: > How did you move the files? > doing[QUOTE] > Copy them the right way using, for example, (s)cp -a or rsync -a or tar. > > > -- > You can go anywhere you want if you look serious and carry a clipboard.




[ Post a follow-up to this message ]



    Re: shell script and chown  
Tony


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 09:52 PM

my fix.sh script look like this:

#!/bin/sh
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6
chown -R $1.$1 $6

I ran fix.sh but nothing happens

"Adam Price" <adam+usenet@pappnase.co.uk> wrote in message
news:bnnl4p$12jvu8$1@ID-138239.news.uni-berlin.de...
quote:
> In news:r-adnQzjTLROqQKiRVn-gw@comcast.com, > Tony <tony.wong@comcast.net> typed: > > untested... > > awk -F: 'BEGIN{print "#!/bin/sh"} {print "chown -R $1.$1 $6"}' /etc/passwd > fix.sh > > Should generate a script to fix the permissions. > Check that fix.sh does what you want and then run it. > Adam > >




[ Post a follow-up to this message ]



    Re: shell script and chown  
Villy Kruse


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 09:52 PM

On Wed, 29 Oct 2003 00:18:03 -0800,
Tony <tony.wong@comcast.net> wrote:

[QUOTE] 

Awk does not interpolate variable in strings unlike perl.

Do this
awk -F: 'BEGIN{print "#!/bin/sh"} {print "chown -R " $1 "." $1, $6}' /etc/pa
sswd

I prefer this to get the right group from the password file.

awk -F: 'BEGIN{print "#!/bin/sh"} {print "chown -R " $3 "." $4, $6}' /etc/pa
sswd


Also do remove the entries for system user names such root, bin, daemon,
or adm from the generated shell script.  Mofifying the owner for any
files in the home directories of those users may have a devastating
result on your unix system.


Villy





[ Post a follow-up to this message ]



    Re: shell script and chown  
Bill Marcum


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 09:52 PM

On Wed, 29 Oct 2003 00:04:14 -0800, Tony
<tony.wong@comcast.net> wrote:
quote:
> scp -a -a is not an option?
Oops, that should be scp -p. Silly of me to expect these things to make sense, but you could have read the man page. -- You can go anywhere you want if you look serious and carry a clipboard.




[ Post a follow-up to this message ]



    Re: shell script and chown  
Bill Marcum


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 09:52 PM

On Wed, 29 Oct 2003 00:18:03 -0800, Tony
<tony.wong@comcast.net> wrote:
quote:
> my fix.sh script look like this: > > #!/bin/sh > chown -R $1.$1 $6 > chown -R $1.$1 $6 > > I ran fix.sh but nothing happens >
You can't chown files on a FAT filesystem. -- You can go anywhere you want if you look serious and carry a clipboard.




[ Post a follow-up to this message ]



    Re: shell script and chown  
Trent Curry


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-04 09:52 PM

Trent Curry wrote:
quote:
> Bill Marcum wrote: > > Who said anything about using a FAT fs? This is a linux ng after all.
^^^^^ Ahem, unix-based os admin ng ;p




[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 01:14 PM.      Post New Thread    Post A Reply      
Pages (2): [1] 2 »   Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register