pkgs is a command-line tool that provides a unified interface for package management across different operating
systems. It wraps around native package managers like apt, dnf, yum, apk, pacman, and brew, allowing you
to use the same commands regardless of the underlying system.
- Unified commands across different operating systems (Linux distributions and macOS)
- Automatic detection of the system's package manager
- Support for common package management operations
- Intelligent privilege handling:
- Automatic sudo elevation on Linux when required
- No sudo usage on macOS with Homebrew (as recommended)
- Intelligent handling of package manager-specific behaviors
brew(macOS)apt(Debian, Ubuntu)dnf(Fedora, RHEL 8+)yum(CentOS, RHEL 7 and earlier)apk(Alpine)pacman(Arch)
git clone https://github.com/mobydeck/pkgs.git
cd pkgs
just build
sudo just installgit clone https://github.com/mobydeck/pkgs.git
cd pkgs
go build
sudo mv pkgs /usr/local/bin/The project includes a justfile with the following commands:
# Build the application
just build
# Install the application to /usr/local/bin
just install
# Clean build artifacts
just clean
# Show the current version
just version
# Build for specific platforms
just build-linux-amd64
just build-macos-arm64
just build-windows-amd64
# Build for all platforms
just build-all
# Create release packages
just packageThese commands handle the package manager-specific details, making it easier to manage packages across different systems:
# Install packages
pkgs install nginx
pkgs i vim git curl
# Reinstall packages
pkgs reinstall nginx
pkgs ri vim git curl
# Remove packages
pkgs remove nginx
pkgs rm vim git curl
# Search for packages
pkgs search nginx
pkgs s python
# Show package information
pkgs info nginx
pkgs show vim
# Update package lists
pkgs update
pkgs up
# Upgrade all packages
pkgs upgrade
pkgs ug
# Remove unused packages
pkgs autoremove
# Clean package cache
pkgs clean
# Show which package manager is being used
pkgs which
# Show only the package manager name (useful for scripting)
pkgs which -sFor example, a script could now do something like:
PM=$(pkgs which -s)
if [ "$PM" = "apt" ]; then
# Do something specific for apt systems
elif [ "$PM" = "brew" ]; then
# Do something specific for Homebrew systems
fiThese commands handle the package manager-specific details, making it easier to manage repositories across different systems:
# Add a repository key
pkgs add-key [name] url
# Examples:
# For apt-based systems (Debian/Ubuntu)
pkgs add-key nodesource https://deb.nodesource.com/gpgkey/nodesource.gpg.key
# For Alpine Linux
pkgs add-key alpine-key https://alpine-keys.example.com/key.rsa.pub
# Add a repository
pkgs add-repo [name] url
# Examples:
# For apt-based systems (Debian/Ubuntu)
pkgs add-repo nodesource "deb [signed-by=/etc/apt/keyrings/nodesource.asc] https://deb.nodesource.com/node_20.x nodistro main"
# For dnf/yum-based systems (Fedora/RHEL/CentOS)
pkgs add-repo https://download.docker.com/linux/fedora/docker-ce.repo
# For Alpine Linux
pkgs add-repo edge-testing https://dl-cdn.alpinelinux.org/alpine/edge/testing
# For Homebrew
pkgs add-repo homebrew/cask-fonts
# Enable a repository
pkgs enable-repo name
# Examples:
# For apt-based systems (Debian/Ubuntu)
pkgs enable-repo nodesource
# For dnf/yum-based systems
pkgs enable-repo docker-ce
# For Alpine Linux
pkgs enable-repo edge-testing
# Disable a repository
pkgs disable-repo name
# Examples:
# For apt-based systems (Debian/Ubuntu)
pkgs disable-repo nodesource
# For dnf/yum-based systems
pkgs disable-repo docker-ce
# For Alpine Linux
pkgs disable-repo edge-testing
# List all repositories with their status (enabled/disabled)
pkgs list-repos# Show general help
pkgs --help
# Show command-specific help
pkgs install --help
# Show version information
pkgs --versionFor CI/CD pipelines and automation scripts, you can use the --yes or -y flag to run commands non-interactively:
# Install packages without prompting
pkgs -y install nginx
# Update and upgrade without prompting
pkgs -y update && pkgs -y upgrade
# Remove packages without prompting
pkgs -y remove nginxThis flag automatically adds the appropriate non-interactive flag to the underlying package manager:
-yfor apt, dnf, and yum--noconfirmfor pacman- No additional flag for brew and apk (as they're already non-interactive by default)
Alternatively, you can set the PKGS_YES environment variable to achieve the same effect:
# Set the environment variable for the current session
export PKGS_YES=true
# Now all commands will run in non-interactive mode
pkgs install nginx
pkgs update
pkgs remove nginx
# You can also set it for a single command
PKGS_YES=1 pkgs install nginxThe PKGS_YES environment variable accepts the following values (case-insensitive):
true,yes,1,y: Enable non-interactive mode- Any other value or unset: Use the default interactive mode
On macOS systems, pkgs automatically detects and uses Homebrew. Some key differences when using Homebrew:
- Commands never use sudo (as recommended by Homebrew)
autoremoveruns bothbrew autoremoveto remove unused dependencies andbrew cleanupto remove old versionsremoveusesbrew uninstallinstead of remove/purgereinstallusesbrew reinstallto reinstall packagesadd-repousesbrew tapto add new tapsadd-keyis not applicable for Homebrewlist-reposshows all taps
Each Linux package manager has its own specific implementation:
apt(Debian/Ubuntu):- Uses
--purgefor thorough removal - Uses
--reinstallflag for reinstalling packages add-keysaves keys to/etc/apt/keyrings/name.ascadd-repocreates files in/etc/apt/sources.list.d/name.listenable-repouncomments entries in repository filesdisable-repocomments out entries in repository fileslist-reposshows repositories from/etc/apt/sources.listand/etc/apt/sources.list.d/
- Uses
dnf/yum(RedHat):- Uses
check-updatefor the update command - Has a dedicated
reinstallcommand add-repocreates files in/etc/yum.repos.d/directoryadd-keyprovides guidance for usingrpm --importenable-reposetsenabled=1in repository filesdisable-reposetsenabled=0in repository fileslist-reposshows repositories from/etc/yum.repos.d/
- Uses
apk(Alpine):- Uses
addanddelinstead of install/remove - Uses
add --force-overwritefor reinstalling add-keyadds keys to/etc/apk/keys/add-repoadds repositories to/etc/apk/repositoriesenable-repouncomments repository entriesdisable-repocomments out repository entrieslist-reposshows repositories from/etc/apk/repositories
- Uses
pacman(Arch):- Uses special flags like
-S,-Rns, etc. - Uses
-S --neededfor reinstalling packages add-keyprovides guidance for usingpacman-key --addadd-repoprovides guidance for manually editing/etc/pacman.confenable-repoanddisable-repoprovide guidance for manually editing/etc/pacman.conflist-reposshows repositories from/etc/pacman.conf
- Uses special flags like
On Linux systems, package management operations typically require root privileges. The pkgs tool will:
- Check if the current user has root privileges
- If not, automatically use
sudoto elevate privileges for commands that require it - If
sudois not available, provide a clear error message
Commands that require privilege elevation:
- install
- reinstall
- remove
- update
- upgrade
- autoremove
- clean
- add-key
- add-repo
- enable-repo
- disable-repo
- list-repos
MIT License
Contributions are welcome! Please feel free to submit a Pull Request.