[NTLUG:Discuss] Moving /home

Steve Baker sjbaker1 at airmail.net
Tue Sep 7 19:17:22 CDT 1999


Kathleen Weaver wrote:
> 
> On Tue, 07 Sep 1999, you wrote:
> 
> > You *can* make the trick of mounting a second drive under /home work -
> > but
> > IMHO that's "A Bad Idea".
> 
> Yeah, I figured that out using the test system here at the house.  (this from
> my "other" account.
> 
> > Instead, put your users directories anywhere on either disk that takes
> > your fancy - and in /home put a bunch of symbolic links to the real
> > home directories.
> >
> >  eg
> >     cd /home
> >     ln -s /some_other_drive/joe_q_public joe_q_public
> >
> >
> > Now, you can move home directories around at will - and so long as
> > you keep the symlink in /home pointing at the right place, nobody
> > will either know or care that you did it.
> 
> Yikes, but I have 200+ students to keep track up.  And it will get worse when I
> added the 100+ teachers.  My objection to manually putting people in groups.

Scripts can be your friend.

In csh/tcsh/whatever, you can do stuff like:

     cd /home
     # Make a list of users into a shell variable
     set users=`ls -1 /newhome`
     # Loop over that list, doing something to each one
     foreach i ( ${users} )
       ln -s /newhome/${i} ${i}
     end

...which creates all those symbolic links completely
automatically. (Bash can do similar things - but the syntax is
a little different)...I didn't test that BTW.

If you find learning to write shell scripts painful, but if you can
use a text editor, do something like this:

  cd /home
  # Make a list of users into a file.
  ls -l /newhome >tempfile
  # Use Emacs to edit that file list
  emacs tempfile
    ...use emacs commands to change every line from
        whatever
    ...to...
        ln -s /newhome/whatever whatever
    ...and save tempfile.
  # Run the commands stored in tempfile.
  source ./tempfile

(You may not want to use emacs - but any reasonable text editor will do)

In essence, you can use the bulk editing commands of the text editor
to do the job of turning a list of files into a list of commands to
run on those files.  Although I'm not bad at writing shell scripts,
I still sometimes resort to this method because it lets me see the
commands before I run them - and hand-edit the special cases that
would be too tedious to test for in a script.

If you ever find yourself about to do any operation on more than
a handful of files, consider one of these two approaches.

-- 
Steve Baker                  http://web2.airmail.net/sjbaker1
sjbaker1 at airmail.net (home)  http://www.woodsoup.org/~sbaker
sjbaker at hti.com      (work)




More information about the Discuss mailing list