sudo command
Run commands as root or another user.
- Users & permissions
- Package sudo
- 6 options · 6 examples
Syntax
sudo [options] commandProvided by the sudo package. Run man sudo for the full manual.
Common options
| Option | What it does |
|---|---|
-i | Root login shell |
-s | Shell as root, keep your environment |
-u USER | Run as another user |
-l | List what you may run |
-k | Forget the cached password |
-E | Keep your environment variables |
Examples
Run a command as root
sudo apt updateOpen a root shell
sudo -iRun as another user
sudo -u www-data php artisan migrateRe-run the last command with sudo
sudo !!List your sudo rights
sudo -lEdit the sudoers file safely
sudo visudo
No example matches. Check the options table or search the guides.
Tips
- Add users to the
sudogroup (Ubuntu) orwheel(RHEL) to grant sudo.
sudo guides
- How to Create a Sudo User on MX Linux Linux · Updated Apr 2025
- How to Create a sudo User on Ubuntu Linux Commands · Updated Apr 2025
- How to Create a Sudo User on Fedora Linux Commands · Updated Apr 2025
- Disabling Root SSH Login and Creating a Sudo User: Linux Server Security Security · Updated Apr 2025
- Linux Security Advisory – Sudo Vulnerability in Linux [CVE-2017-1000367] Security · Updated Apr 2025
- How to Create a Sudo User in Debian Linux · Updated Apr 2025
- Understanding the difference: “sudo su -” And “sudo -i” Linux · Updated Apr 2025
- How to Increase Sudo Session Duration in Linux Linux · Updated Apr 2025
