[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [K12OSN] Permissions?



On Wed, 30 Apr 2003, jamie wrote:

>This should be easy but it is eluding me, man page after man page I can't
>seem to find what I need.
>
>Basically I need to copy a bunch of files and directories to all my users
>home directories. Copying the files isn't the hard part. Its the fact that
>If I copy the files to all their directories as root then the root user owns
>the files. I need for the ownership of the files to be the same as the
>directory I am copying them into.
>
>I hope I am explaining this right. I would do it by hand but I have 3000
>users. I though about just changing the files to 777 but I that¹s not really
>the answer. 
>
>Its almost like I need the /etc/skel thing going on. But I can delete and
>recreate the home directories because I can't wipe out the users data they
>already have. 
>
>Any Ideas?

This is the magic you are looking for...

	cp /some/file /home/someuser/
	chown --reference=/home/someuser /home/someuser/file


To copy a file to every user's homedir, you could do something like...


	for USER in /home/*
	do
		cp /some/file $USER
		chown --reference=$USER $USER/file
	done


You probably want to throw in some sanity checks, such as only doing the
copy if the file does not exist (or is not a symlink, etc).

	for USER in /home/*
	do
		if [ -f $USER/file ]
		then
			echo "skipping $USER/file, it already exists"
		else
			cp /some/file $USER
			chown --reference=$USER $USER/file
		fi
	done


-Eric





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]