Skip to content

Instantly share code, notes, and snippets.

@patel-zeel
Created April 27, 2025 11:33
Show Gist options
  • Save patel-zeel/25b7b0d4bb43ca8c03fbb986dbdea3d8 to your computer and use it in GitHub Desktop.
Save patel-zeel/25b7b0d4bb43ca8c03fbb986dbdea3d8 to your computer and use it in GitHub Desktop.
Instructions to set up system-wide anaconda installation

System-wide Miniconda Installation and Cache Directory Setup

This guide walks you through the steps to install Miniconda system-wide, configure permissions for shared environments, and set up the cache directory with appropriate ACL and sticky bit permissions.

Step 1: Install Miniconda System-Wide

  1. Download Miniconda: Download the appropriate Miniconda installer for your platform from the Miniconda website.

  2. Install Miniconda:

    Run the following command to install Miniconda system-wide under /opt/miniconda3:

    sudo bash Miniconda3-latest-Linux-x86_64.sh

    Follow the installation prompts. When asked for the installation location, choose /opt/miniconda3:

    Miniconda3 will be installed to: /opt/miniconda3
  3. Set the PATH for Miniconda:

    To ensure Miniconda is available globally, add it to the system-wide PATH by modifying the /etc/profile.d/miniconda.sh file. Create the file if it doesn't exist:

    sudo nano /etc/profile.d/miniconda.sh

    Add the following line:

    export PATH="/opt/miniconda3/bin:$PATH"

    Then, make the script executable:

    sudo chmod +x /etc/profile.d/miniconda.sh
  4. Activate the changes:

    To apply the changes, either log out and log back in or run:

    source /etc/profile.d/miniconda.sh
  5. Test the installation: Verify that Miniconda was installed correctly by running:

    conda --version

Step 2: Create the anaconda Group

  1. Create the anaconda group:

    sudo groupadd anaconda
  2. Add users to the anaconda group: Users who should have access to Miniconda need to be added to the anaconda group:

    sudo usermod -aG anaconda <username>

    After adding a user to the group, they need to log out and log back in for the changes to take effect.


Step 3: Set Permissions for the Miniconda Directory

  1. Change ownership and set permissions for /opt/miniconda3:

    Ensure that the Miniconda directory is owned by root and the group is anaconda, with appropriate read/write/execute permissions for the group:

    sudo chown -R root:anaconda /opt/miniconda3
    sudo chmod -R 775 /opt/miniconda3

Step 4: Set Up the Cache Directory with ACL and Sticky Bit

  1. Create the cache directory (if not already present):

    sudo mkdir /opt/miniconda3/cache
  2. Set ACL for the cache directory:

    Apply ACLs to ensure that members of the anaconda group can write to the directory, while others have read-only access:

    sudo setfacl -d -m u::rwx /opt/miniconda3/cache   # Default ACL for owner (root)
    sudo setfacl -d -m g::rwx /opt/miniconda3/cache   # Default ACL for group (anaconda)
    sudo setfacl -d -m o::r-x /opt/miniconda3/cache   # Default ACL for others
    sudo setfacl -m u::rwx /opt/miniconda3/cache      # ACL for owner (root)
    sudo setfacl -m g::rwx /opt/miniconda3/cache      # ACL for group (anaconda)
    sudo setfacl -m o::r-x /opt/miniconda3/cache      # ACL for others
  3. Apply the sticky bit:

    The sticky bit ensures that only the creator of a file can delete or rename it, even if others have write permissions:

    sudo chmod +t /opt/miniconda3/cache
  4. Ensure correct ownership of the cache directory:

    Set the ownership of the cache directory to root:anaconda:

    sudo chown root:anaconda /opt/miniconda3/cache
  5. Verify the permissions:

    Verify the ACL and sticky bit settings:

    ls -ld /opt/miniconda3/cache

    The output should show:

    drwxrwsr-t+ 2 root anaconda 4096 Apr 27 16:33 cache

Step 5: Automatically Add New Users to the anaconda Group

  1. Modify /etc/default/useradd:

    Open the file for editing:

    sudo nano /etc/default/useradd
  2. Set the default group for new users:

    If something is already set for GROUP=, append ,anaconda to it.

    GROUP=group1,group2,anaconda

    Otherwise, set it to anaconda:

    GROUP=anaconda
  3. Verify the changes:

    Create a new user to verify that the default group is set correctly:

    sudo useradd testuser
    sudo passwd testuser

    Check the groups for the new user:

    groups testuser

    The output should include anaconda.

    Don't try this step in VS code terminal because groups are not updated automatically. So, it'll not show anaconda group even if the user is added to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment