diff --git a/distrobox-export b/distrobox-export index d67fee1c4c..a96f5fe6f5 100755 --- a/distrobox-export +++ b/distrobox-export @@ -217,10 +217,14 @@ if [ -z "${container_name}" ]; then fi # -if [ "${is_sudo}" -ne 0 ]; then - start_shell="$(command -v sudo) -i" +if [ "${is_sudo}" -ne 0 ]; then + if command -v su-exec > /dev/null2 >&1; then + start_shell="su-exec root su - root -c" + elif command -v sudo > /dev/null 2>&1; then + start_shell="$(command -v sudo) -i" + fi else - start_shell="$(command -v sudo) -u ${USER} -i" + start_shell="/bin/sh -l -c" fi # Prefix to add to an existing command to work through the container