Go Back   Aquarium Advice - Aquarium Forum Community > Community Forum > Aquaria Off-Topic
Click Here to Login

Join Aquarium Advice Today
Closed Thread
 
Thread Tools Search this Thread Display Modes
Please support our sponsors and let them know you heard about them on AquariumAdvice.com
 
Old 05-18-2005, 09:43 AM   #1
Aquarium Advice Addict
 
Join Date: Dec 2003
Location: Central Ohio
Posts: 1,728
Send a message via Yahoo to deli_conker
Quick Linux question

Ok, so the boss went on vacation and gave me a to do list. We are in the middle of a migration that I, until now, haven't had a whole to do with directly. One of the things I need to do is copy a few generic files (.bashrc, .profile, etc) that have been tweaked , to all of the user's home directories. I can't just hard link them as some of the users will need to change some of the files, I need a seperate copy in each directory.

I can't get it to work with the cp command. Is there something else I can use in SuSE 9.3?
__________________

__________________
deli_conker is offline  
Old 05-18-2005, 09:52 AM   #2
Aquarium Advice Activist
 
Join Date: May 2004
Location: North Carolina
Posts: 126
You can't copy the files at all or you want to copy them all at once?
__________________

__________________
Maybe didn't mean so much, but it meant everything to me. - T. Reznor
SteveM is offline  
Old 05-18-2005, 09:56 AM   #3
Aquarium Advice Activist
 
Join Date: Mar 2005
Location: Maryland
Posts: 202
Do you have root access (shudder...)? You can't copy files into other people's accounts if you don't have the right access priviledges.
__________________
2 x Goldfish - $0.09
2 x Ghost Shrimp - $0.60
Look on wife's face when she found out how much I've spent on fish related gear this month - PRICELESS

Heatware 164-0-0
bzbee is offline  
Old 05-18-2005, 10:04 AM   #4
Aquarium Advice Addict
 
Join Date: Nov 2004
Location: Rockland, Ontario
Posts: 1,439
I agree, you have to be Root to have full access to other people's directories. When done, ensure that the users have, at least, read, execute privs on those files. HTH

8)
__________________
Serge

Vote Here for Aquarium Advice
Serge is offline  
Old 05-18-2005, 10:06 AM   #5
Aquarium Advice Addict
 
Join Date: Dec 2003
Location: Central Ohio
Posts: 1,728
Send a message via Yahoo to deli_conker
Yes I have root access.
Yes I can copy the files individually, I just don't want to spend all day typing...

Code:
cp /etc/skel/.* /home/user1
cp /etc/skel/.* /home/user2
etc.
I looked at the cp help file and haven't found anything that might help me. I even tried stupid things like...
Code:
cp /etc/skel/.* /home/*/

and

cp /etc/skel/.profile /home/*/.profile
to no avail...
__________________
deli_conker is offline  
Old 05-18-2005, 10:11 AM   #6
Aquarium Advice Activist
 
Join Date: May 2004
Location: North Carolina
Posts: 126
Try this -

Code:
for i in /home/* ; do (for j in /etc/skel/.* ; do if test -f $j;then echo $j $i;echo `basename $i` $i/`basename $j`;fi;done);done
if it looks right to you, then change the first echo to cp, and the second echo to chown
__________________
Maybe didn't mean so much, but it meant everything to me. - T. Reznor
SteveM is offline  
Old 05-18-2005, 11:17 AM   #7
Aquarium Advice Addict
 
Join Date: Dec 2003
Location: Central Ohio
Posts: 1,728
Send a message via Yahoo to deli_conker
That all kinda makes sense, but I'm fairly new to scripting in linux.

The i variable cycles through the home directory.
The j variable cycles through the /etc/skel directory.
I'm not sure what the "if test -f" does. It seems like it looks into the current /home/i/ for a file named /etc/skel/j and if false (the -f switch?) if copies the file and then changes the ownership to the username matching the directory it is copying it into? Next j, next i.

What does the "fi" do?

Sorry, like I said, fairly new to linux and want to double check all of this before I mess it all up...
__________________
deli_conker is offline  
Old 05-18-2005, 11:18 AM   #8
Aquarium Advice Activist
 
Join Date: Mar 2005
Location: Maryland
Posts: 202
fi == end if
__________________
2 x Goldfish - $0.09
2 x Ghost Shrimp - $0.60
Look on wife's face when she found out how much I've spent on fish related gear this month - PRICELESS

Heatware 164-0-0
bzbee is offline  
Old 05-18-2005, 12:20 PM   #9
Aquarium Advice Addict
 
Join Date: Dec 2003
Location: Central Ohio
Posts: 1,728
Send a message via Yahoo to deli_conker
I take it that done == next (as in old school basic next)?
__________________
deli_conker is offline  
Old 05-18-2005, 12:20 PM   #10
Aquarium Advice Activist
 
Join Date: May 2004
Location: North Carolina
Posts: 126
Quote:
Originally Posted by deli_conker
I'm not sure what the "if test -f" does. It seems like it looks into the current /home/i/ for a file named /etc/skel/j and if false (the -f switch?) if copies the file and then changes the ownership to the username matching the directory it is copying it into? Next j, next i.

What does the "fi" do?
"test -f" checks to see if $j is a file. This is to avoid trying to copy "." and ".." from /etc/skel. If you have any directories in /etc/skel that you want copied, then this will be a problem. And as bzbee said, the fi is end if (if spelled backwards).

Quote:
Sorry, like I said, fairly new to linux and want to double check all of this before I mess it all up...
Before you change the echo's it is totally safe and won't do a thing. Maybe this will be more clear as to what it is doing:

Code:
for i in /home/* ; do (for j in /etc/skel/.* ; do if test -f $j;then echo cp $j $i;echo chown `basename $i` $i/`basename $j`;fi;done);done
Still does nothing, but echos the actual commands it would do. Remove the echos to make it actually do the work.
__________________

__________________
Maybe didn't mean so much, but it meant everything to me. - T. Reznor
SteveM is offline  
Closed Thread

Tags
ick

Please support our sponsors and let them know you heard about them on AquariumAdvice.com

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Quick Question DeadOrAlive Saltwater Fish Only & FOWLR 2 12-16-2009 04:07 PM
quick question mike3epanda Saltwater Fish Only & FOWLR 2 07-28-2007 08:47 AM
Quick question... ntswift Saltwater Reef Aquaria 15 03-25-2006 01:36 AM
Quick question fishman Saltwater Reef Aquaria 4 08-05-2004 10:21 AM







» Photo Contest Winners








Copyright 2002- Social Knowledge, LLC All Rights Reserved.

All times are GMT -4. The time now is 08:00 PM.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2017, vBulletin Solutions, Inc.