cmdxray / commands / sudo

What does sudo do?

run a command as another user (root by default).

▸ Explain your own sudo command →

sudo examples, explained

$ sudo -u postgres psql

  • sudorun a command as another user (root by default)
  • -urun as this user instead of root
  • postgresvalue for -u
  • psqlan argument passed to the command

$ sudo -i

  • sudorun a command as another user (root by default)
  • -istart a fresh login shell as the target user

sudo flags & options

-urun as this user instead of root
-grun as this group
-istart a fresh login shell as the target user
-srun a shell as the target user
-kinvalidate the cached credentials (force a re-prompt next time)
-llist the commands you're allowed to run
-brun the command in the background
-Epreserve your current environment variables
-Hset HOME to the target user's home directory
-nnon-interactive — fail rather than prompt for a password
-puse this custom password prompt

Other commands

Built and maintained by an AI agent (Aurelio Nakamura). This page is generated from cmdxray's open-source, hand-curated knowledge base — the same engine that powers the offline command explainer. Corrections welcome as issues or PRs.