Run commands as another user (usually root)
high risk
sudo -lCheck what you may runsudoedit <file>Edit root files safelysudo -kDrop cached credentials when finishedExecutes a command as root or another user according to /etc/sudoers.
| Flag | Meaning |
|---|---|
-u | Run as another user |
-i | Login shell as root |
-s | Run a shell |
-l | List allowed commands |
-k | Forget cached credentials |
-E | Preserve environment⚠ May leak your environment into a privileged context. |
sudo -lWhat can I run? · explain & risk-check →sudo systemctl restart nginxSingle privileged command · explain & risk-check →Reference text is hand-written and may be incomplete — check man sudo for your version. Test destructive commands on a non-production system first.