Miniforge Cheat Sheet
The core takeaway when using Miniforge is that mamba serves as a fast, drop-in replacement for conda, meaning you can swap the word conda for mamba in almost every environment and package management command. For optimal performance, use mamba to handle heavy lifting tasks like downloading, searching, and installing packages, and use conda for basic environment activation or shell initialization.
Here's a Miniforge Cheat Sheet created with AI's help. It will cover the essential categories of your daily workflow.
1. Initialization Commands
Before running operations, ensure Miniforge is properly integrated into your command line interface.
- conda init: Registers the package manager configuration to your specific shell or terminal program.
- mamba init: Adds performance-optimized shell configurations tailored directly for Mamba-specific executions.
2. Environment Management
Isolate distinct projects by organizing their dependencies inside standalone virtual runtime environments.
- mamba create -n my_env python=3.11 (Generates a completely new environment named my_env preloaded with Python 3.11.)
- conda activate my_env (Launches and switches your active terminal prompt context over into my_env.)
- conda deactivate (Exits the current active virtual context and returns your terminal to its global default.)
- conda env list (Scans your local storage and outputs a comprehensive directory of all existing environments.)
- conda env remove -n my_env (Erases the specified project directory environment along with every internal library.)
3. Package Management
Search for, install, inspect, or delete targeted software modules directly inside an activated environment.
- mamba search numpy (Queries remote repositories to find specific versions and information regarding a target library.)
- mamba install numpy pandas (Downloads and installs dependencies simultaneously while automatically optimizing versions.)
- mamba install -c conda-forge numpy (Forces a targeted installation specifically from the community-driven conda-forge index channel.)
- mamba list (Generates a complete inventory of every library currently installed in your active environment.)
- mamba update --all (Synchronizes every asset inside the active workspace to its newest compatible version.)
- mamba remove numpy (Safely deletes the designated package while cleaning up orphan project files.)
4. System Utilities & Maintenance
Keep your installation lean and clean by pruning cached installer files or backing up workspace state configurations.
- mamba clean --all (Purges unused package caches and temporary tarballs to recover wasted local disk space.)
- conda env export > environment.yml (Backs up the absolute layout blueprint of your active environment into a portable file.)
- mamba env create -f environment.yml (Reads an exported configuration layout file to recreate an identical project environment locally.)
5. Configuration & Channel Management
Manage your repository search paths and global system behaviors.
- conda config --show channels (Displays the active remote repositories Miniforge is searching.)
- conda config --add channels <channel_name> (Adds a new repository (like pytorch) to the top of your search priority list.)
- conda config --set auto_activate_base false (Stops the (base) environment from automatically loading every time you open a terminal.)
6. Advanced Package Inspection
Investigate dependency issues, origins, and file paths.
- mamba repoquery depends numpy (Shows every single package that numpy relies on to function.)
- mamba repoquery whoneeds numpy (Shows which of your installed packages would break if you deleted numpy.)
- mamba list --explicit (Outputs a strict, absolute URL list of your exact package binaries (perfect for perfect replication).)
7. History & Rollbacks
Fix your environment if an installation accidentally breaks something.
- conda list --revisions (Displays a numbered history log of every install, update, or removal action in the environment.)
- conda install --revision 2 (Rolls back the environment state to exactly how it looked at revision number 2.)
8. Deep Cleanup
For when a simple clean isn't enough and you need to free up massive disk space.
- mamba clean --index-cache (Forces Mamba to delete old repository index copies and fetch fresh package lists on the next search.)
Note:
(A) There is no need to run both mamba init and conda init. Running mamba init is the best choice because it configures your terminal for both tools simultaneously. After running mamba init and restarting your terminal, check your prompt. If you see (base) next to your command line, the initialization was successful.
Why mamba init is sufficient
- Dual Setup: mamba init automatically adds the necessary shell code for both mamba and conda.
- Activation Control: Once it runs, you will be able to use conda activate and mamba activate interchangeably.
- Redundancy: Running conda init afterward is redundant and will only add duplicate blocks of code to your shell profile script (like your .bashrc or .zshrc file).
(B) By default, when you run mamba search numpy, it is searching the conda-forge community repository. Because you installed Miniforge, your system is explicitly pre-configured to prioritize this free, open-source, and community-maintained repository instead of Anaconda’s commercial channels.
- How to see your active repositories. You can check exactly which repositories (called "channels") your local installation is querying by running:
conda config --show channels
If you need packages that are not hosted on conda-forge, you can instruct Mamba to search additional public repositories by passing the -c (channel) flag. For example:
- Bioconda (for bioinformatics): mamba search samtools -c bioconda
