Tuesday, May 4, 2010

How To Change A User's Home Directory in Solaris

# usermod -d /export/home/username username

(Don't forget to move any files from the old user account location to the new location!)


  1. How to move user home directory to under different user home directory.
    will this command do the job usermod -d /export/home/username username

    1. I know this is old, but may help someone else.

      You'll have to execute

      usermod -d /export/home/username username

      And make a cp as well, something like

      cp -r /old/home/path /new/home/path

    2. Since this post is still getting a lot of traffic:

      the move command will take care of the process
      # mv /old/dir/username /export/home/username

      This will move the actual inode holding the old username directory to the new tree, which is very fast! If there are running processes accessing file in the tree, the running processes will also be able to keep their file handles open and continue editing the files in the home directory.

      If the old location is not on the same filesystem of the new directory, the underlying OS should take care of the details.

      I would not recommend using "cp -r" since this does not handle some file types, like symbolic links, correctly... and also leaves the old files behind. Also, if there are any old file handles opened, from processes editing files, they may not know the copy has taken place, and could remain writing to the former directory.

      If you want to copy the files correctly, including all file types, and leave the original files behind, and don't care about processes editing the old files during the copy - you may want to try the following:
      # cd /old/dir; find username -print | cpio -pdum /export/home