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.
-
Download Miniconda: Download the appropriate Miniconda installer for your platform from the Miniconda website.
-
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
-
Set the PATH for Miniconda:
To ensure Miniconda is available globally, add it to the system-wide
PATHby modifying the/etc/profile.d/miniconda.shfile. 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
-
Activate the changes:
To apply the changes, either log out and log back in or run:
source /etc/profile.d/miniconda.sh -
Test the installation: Verify that Miniconda was installed correctly by running:
conda --version
-
Create the
anacondagroup:sudo groupadd anaconda
-
Add users to the
anacondagroup: Users who should have access to Miniconda need to be added to theanacondagroup: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.
-
Change ownership and set permissions for
/opt/miniconda3:Ensure that the Miniconda directory is owned by
rootand the group isanaconda, with appropriate read/write/execute permissions for the group:sudo chown -R root:anaconda /opt/miniconda3 sudo chmod -R 775 /opt/miniconda3
-
Create the cache directory (if not already present):
sudo mkdir /opt/miniconda3/cache
-
Set ACL for the cache directory:
Apply ACLs to ensure that members of the
anacondagroup 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
-
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
-
Ensure correct ownership of the cache directory:
Set the ownership of the
cachedirectory toroot:anaconda:sudo chown root:anaconda /opt/miniconda3/cache
-
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
-
Modify
/etc/default/useradd:Open the file for editing:
sudo nano /etc/default/useradd
-
Set the default group for new users:
If something is already set for
GROUP=, append,anacondato it.GROUP=group1,group2,anaconda
Otherwise, set it to
anaconda:GROUP=anaconda
-
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
anacondagroup even if the user is added to it.