Skip to content

Linux su Guide

Mattscreative edited this page Dec 5, 2025 · 2 revisions

Linux su Guide

Complete beginner-friendly guide to su on Linux, covering Arch Linux, CachyOS, and other distributions including switching users, becoming root, and user switching.


Table of Contents

  1. Understanding su
  2. su Basics
  3. Switching Users
  4. su vs sudo
  5. Troubleshooting

Understanding su

What is su?

su (switch user) changes to another user account.

Uses:

  • Switch users: Change to different user
  • Become root: Switch to root account
  • Test permissions: Test as different user
  • System maintenance: Run commands as root

Note: Prefer sudo for security, but su is still useful.


su Basics

Become Root

Switch to root:

# Switch to root
su

# Enter root password
# Now you're root

# Exit
exit

Switch to User

Change user:

# Switch to user
su username

# Enter user password
# Now you're that user

# Exit
exit

Switching Users

With Environment

Preserve environment:

# Switch with current environment
su - username

# Or
su -l username

# Full login shell

Without Environment

Minimal environment:

# Switch without changing environment
su username

# Uses current environment

su vs sudo

When to Use su

Use su when:

  • Need root shell: Extended root session
  • System maintenance: Multiple root commands
  • Testing: Test as different user

When to Use sudo

Use sudo when:

  • Single command: One command as root
  • Security: Better audit trail
  • Best practice: Recommended approach

Troubleshooting

Authentication Failed

Check password:

# Verify user exists
id username

# Check if user has password
sudo passwd username

# Try again
su username

Permission Denied

Check access:

# Verify user in wheel group
groups username

# Check /etc/group
grep wheel /etc/group

Summary

This guide covered su usage, user switching, and when to use su vs sudo for Arch Linux, CachyOS, and other distributions.


Next Steps


This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.

Clone this wiki locally