Execute a command as another user with pkexec

In the absence of sudo, pkexec is an alternate mechanism to gain privileges of another user, including root.


October 24, 2023

From the Linux man page:

pkexec allows an authorized user to execute PROGRAM as another user. If username is not specified, then the program will be executed as the administrative super user, root.

When running uninstall on my Steam Deck via sudo pacman -Rs [program] (see Arch Linux wiki for reference), I somehow uninstalled sudo. As non-root user, I need root privileges to reinstall sudo via sudo pacman -Suy sudo. Except the command sudo no longer exists.

I recovered the situation by running pkexec pacman -Suy sudo and sudo is now back.

Thanks for reading. More like this?

#til #linux #tools

© 2023-2025 Wilson Husin

This site was last updated 2025-05-17T20:42:58-0700.

:wq