rename home directory

Alexander Skwar (ML) alexanders.mailinglists+nospam at gmail.com
Tue Mar 13 07:03:39 UTC 2012


Am 12.03.2012 21:58, schrieb Johnny Rosenberg:
> 2012/3/12 Alexander Skwar (ML)<alexanders.mailinglists+nospam at gmail.com>:
>> Am 12.03.2012 14:31, schrieb Saikat Saha:
>>
>>> Hi,
>>>
>>> i want to rename "/Home/username" this folder only.
>>
>>
>> usermod -d
>>
>> from man usermod:
>>
>>        -d, --home HOME_DIR
>>            The user's new login directory.
>>
>>            If the -m option is given, the contents of the current home
>>            directory will be moved to the new home directory, which is
>> created
>>            if it does not already exist.
>>
>>
>> But, as I said, it might not work so well, because of applications,
>> which store path names in their configuration files.
>
> And reinstalling those won't help? Or at least uninstalling and then
> installing again?

It's not about *installation*. The installed programs will work just
fine.

It's rather about *configuration*. For example, Firefox or Thunderbird
used to store the full path name to the "profile" in some configuration
file. If you then changed the path, the profile couldn't be found.
(Note: I am not sure if it is still a problem with Firefox or
Thunderbird, but it might - and it might also affect other programs.)

> I suppose that sed in some kind of loop could solve the problem
> otherwise, couldn't it?

Sure. If you know what to change, it can be done. Something like this
might help out:

grep -rl "/home/old" /home/old > /home/old/files-with-home-old.txt

Then verify each file listed in /home/old/files-with-home-old.txt
and change /home/old to /home/new.

If you're confident about what's in /home/old/files-with-home-old.txt,
maybe after removing "wrong" files from the list, perl would be
handy:

while read home_old_file; do
  perl -pi -e 's,/home/old,/home/new,g' "$home_old_file"
done < /home/old/files-with-home-old.txt

Alexander
-- 
☄ Google+ ↣ http://plus.skwar.me                   ☄
☛ Lifestream (Twitter, …) ↣ http://sup.skwar.me    ☛
⚰ Twitter: @alexs77 ↣ http://twitter.com/alexs77   ⚰
☞ Chat (Jabber/Google Talk) ↣ a.skwar at gmail.com


More information about the ubuntu-users mailing list