Knowledgebase

How do I move user's home folder to another location if I have CageFS installed?

Moving a user's home folder when CageFS is installed requires some extra steps to ensure that CageFS continues to work properly for that user. Here's how you can do it:

  1. Backup Home Directory: Before making any changes, it's crucial to create a backup of the user's home directory. This ensures that you have a copy in case anything goes wrong.

    bash

 

  • sudo mv /home/username /path/to/backup/location
  • Update CageFS Configuration: Open the CageFS configuration file for editing.

    bash
  • sudo nano /etc/cagefs/cagefs.mp

    Find the line that refers to the user's home directory (/home/username) and update it to the new path.

  • Update /etc/passwd: You'll need to edit the /etc/passwd file to reflect the new home directory for the user.

    bash
  • sudo nano /etc/passwd

    Find the line that starts with the username (e.g., username:x:1001:1001::/home/username:/bin/bash) and update the home directory path to the new location.

  • Update Ownership: Make sure that the new home directory has the correct ownership and permissions. This can be done using the chown command.

    bash
  • sudo chown -R username:username /new/home/directory
  • Restart Services: Restart any services that might be affected by this change. This could include the web server, FTP server, etc.

  • Rebuild CageFS: After making changes to the CageFS configuration, you need to rebuild CageFS for the changes to take effect.

    bash

 

  1. cagefsctl --remount-all
  2. Verify Access: Log in as the user and ensure that they have proper access to their new home directory.

Please note that modifying user home directories can have implications on the user's environment and any services they may be using. Always communicate with the user beforehand and ensure that you have backups available before making significant modifications.

 
  • 0 Users Found This Useful
Was this answer helpful?