You're probably very familiar with the tools you use daily and operate them from muscle memory. But there are also these setup or maintenance tasks you only do every X months and their practical details are a bit hazy.
This is a random, work-in-progress collection of cheat sheets for these commands or workflows I use too infrequently to remember.
Jupyter/JupyterLab
-
List installed Jupyter/JupyterLab kernels (run from env that has jupyter installed):
jupyter kernelspec list
-
Add a new kernel for a custom virtual/conda env:
- Enter the virtual/env (e.g.
. bin/venv/activate
orconda activate $envname
) - Install ipykernel package: e.g.
pip install ipykernel
- Create kernel spec for jupyter/jupyterlab:
python -m ipykernel install --user --name $kernelname
Optionally add
--display-name "Pretty Name"
to give it a prettier name in the Jupyter(Lab) UI - Check that kernel is now listed atjupyter kernelspec list
(run this from env where you run Jupyter(Lab)) - Enter the virtual/env (e.g.
asdf (for managing Python versions)
- List installed python versions
asdf list python
- List all available Python versions
asdf list all python
- Install new version
asdf install python 3.11.2
- Select certain version for current shell:
asdf shell python 3.11.1
Conda/Anaconda
- Updating
- update conda (base environment):
conda update conda
- Update all packages in an environment:
conda update --all
- update conda (base environment):
-
Remove unused packages and caches (can save up multiple GB).
conda clean --all
(optionally add
--dry-run
) -
Remove environment
conda env remove -n $ENVNAME
Homebrew
- List installed formulas
- Including dependencies:
brew list
- Only the "leave" formulas:
brew leaves
-
How do I update my local packages?
# First update the formulae and Homebrew itself: brew update # You can now find out what is outdated with: brew outdated # Upgrade everything with: brew upgrade # Or upgrade a specific formula with: brew upgrade <formula>
-
By default, Homebrew does not uninstall old versions of a formula. To clean up the accumulation of old, unused versions:
brew cleanup <formula> # or clean up everything at once (add `-n` for dry run): brew cleanup
-
Remove packages that were once installed as dependency of another, but not necessary anymore:
brew autoremove
-
General checkup
brew doctor
Docker
-
First, it's best to clean up all stopped containers (assuming these are all just disposable leftovers).
# Check first for stopped containers docker ps -a # Prune stopped containers docker container prune
-
Clean up dangling images
# List images we currently have docker image ls # Prune dangling images (untagged and not being used by a container) docker image prune
-
A bit more aggressive: prune all images (also tagged ones) that were created long enough ago
docker image prune -a --filter "until=2022-01-01"
-
Even more aggressive, suggested on Adam Johnson's blog:
docker system prune --all --force --filter until=24h docker volume prune --force
Vim
(yes, I use vim too infrequently to remember these, sue me)
- Change a word (e.g. interactive git rebase):
:cw
- show line numbers
:set number