sudo vs su — What's the Difference in Linux?

sudo runs a single command with elevated (root) privileges; su switches your entire shell session to another user, typically root.

Published October 2, 2026

sudo runs a single command with elevated (root) privileges; su switches your entire shell session to another user, typically root.

Key points

  • sudo requires your own password (not root's) by default and logs every command run, which is generally considered safer
  • su root requires knowing the root password directly and starts an entire root shell session until you exit it
  • Most modern distributions favor sudo and disable direct root login altogether

Example

sudo systemctl restart nginx
More Linux articles