Suponho que o seu shell raiz interativo é /bin/bash (mas cuidado, talvez o seu /etc/passwd defina outra coisa, por exemplo, /bin/dash ).
Então, o que você realmente quer é executar um shell de login raiz em sudo . Como eu comentei, eu acredito que você geralmente não precisa disso. E você também pode desfazer algumas variáveis de ambiente ou defini-las para os padrões apropriados, através de seu arquivo /etc/sudoers.d/apt-get .
Mas Invocação de Bash diz que
-l
Make this shell act as if it had been directly invoked by login. When the shell is interactive, this is equivalent to starting a login shell with exec -l bash. When the shell is not interactive, the login shell startup files will be executed. exec bash -l or exec bash --login will replace the current shell with a Bash login shell. See Bash Startup Files, for a description of the special behavior of a login shell.
e mais tarde
A login shell is one whose first character of argument zero is -, or one invoked with the --login option.
Então, você provavelmente poderia escrever um script de shell (ou um programa wrapper em C) que chama bash com -l ou --login e ter essa coisa mencionada em /etc/sudoers.d/apt-get
Talvez a execução de /bin/bash -l -c "/usr/bin/apt-get $*" seja suficiente.
Observe também que sudoers(5) menciona env_reset e env_keep
Talvez você queira apenas remover algumas variáveis de ambiente, como DBUS_SESSION_BUS_ADDRESS ....
(Eu posso estar errado e nunca tentei isso)