From: Jeff Kinz [mailto:jkinz@kinz.org] Sent: Thursday, January 29, 2004 9:33 AM To: suse-linux-e@suse.com Subject: Re: [SLE] how to change users home directories
I want to change a bunch of users home directories from /home and move them to /home/year7 but I want the username, password and directory content to remain the same. I can edit /etc/passwd and change to the new
On Thu, Jan 29, 2004 at 06:18:40PM +0000, steve-ss wrote: directory but
how do I make the changes take effect? Unfortunately I can't use yast to do this. Thanks, Steve.
something like:
cd /homr for file in *; do if [ ! -e year7 ] ; then mkdir year7 fi mv $file year7/. done
then edit /etc/passwd
Could you help explain the script ? the "for file in *" seems like it would move every username in /home to /home/year7 ? (why not just do: cd /home; make year7; mv * year7/ ) ? I am probably reading your script wrong so if you could help out that'd be awesome. Anyway, if the OP only wants to move specified accounts and not everyone in /home, here is another possible way edit the /etc/passwd file first. Change the /home dirs. assuming "year7" only shows up in your /etc/passwd file for those users whose accounts are in /home/year7/[username] (e.g. there is no username "year7" or somehting like that). (grep year7 passwd | awk -F: '{print "mv /home/"$1" /home/year7/"$1}') | cat This will print out what the script is going to do. If it looks good, you can then redirect to a file and run as a shell script OR change "cat" to "/bin/sh" or "/bin/bash" and it will then do the actual "mv "commands. Ben