Skip to content

About

A bash script to automatically restore broken sudo privileges inside Distrobox containers.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Fix Distrobox Sudo

A bash script to automatically restore broken sudo privileges inside Distrobox containers.

If you accidentally alter permissions or get locked out of sudo with errors like sudo: /usr/bin/sudo must be owned by uid 0, this script runs from your host machine to safely bypass the container's broken environment and reset the necessary system file permissions using Podman.

Prerequisites

  • podman
  • distrobox
  • fzf (Optional, for an improved interactive menu)

Installation

  1. Create a local binary directory if it does not already exist:
mkdir -p ~/.local/bin
  1. Create the script file:
nano ~/.local/bin/fix-distrobox-sudo
  1. Paste the provided script into the file and save it.
  2. Make the script executable:
chmod +x ~/.local/bin/fix-distrobox-sudo
  1. Ensure ~/.local/bin is in your system's PATH.

Usage

Run the script from your host machine (do not run it from inside the container).

Interactive Mode

To run the script and select your container from a menu, simply run the command without any arguments:

fix-distrobox-sudo

Direct Mode

To bypass the menu and fix a specific container directly, pass the container name as an argument:

fix-distrobox-sudo my-container-name

What it fixes

The script forces a root shell into the target container and resets the ownership and permissions of the following critical files:

  • /usr/bin/sudo
  • /usr/bin/su
  • /etc/sudo.conf
  • /etc/sudoers
  • /etc/sudoers.d/

About

A bash script to automatically restore broken sudo privileges inside Distrobox containers.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Contributors

Languages