0
0
Linux CLIscripting~3 mins

Why su (switch user) in Linux CLI? - Purpose & Use Cases

Choose your learning style9 modes available
The Big Idea

What if you could switch users instantly without logging out and losing your place?

The Scenario

Imagine you are working on a shared computer where you need to perform tasks as different users. You have to log out and log back in every time you want to switch users to run commands or access files.

The Problem

This manual method wastes time and interrupts your workflow. Logging out and back in repeatedly is slow and frustrating. It also increases the chance of mistakes, like forgetting to save work or closing important programs.

The Solution

The su command lets you switch users instantly within the same session. You can run commands as another user without logging out, saving time and reducing errors.

Before vs After
Before
logout
login as another user
run commands
After
su username
run commands as that user
exit # to return
What It Enables

You can quickly and safely switch user identities to manage tasks without interrupting your work.

Real Life Example

A system administrator needs to switch to the root user to install software, then switch back to their regular user to continue daily work--all without logging out.

Key Takeaways

Manually switching users by logging out is slow and error-prone.

su lets you switch users instantly in the same session.

This saves time and keeps your workflow smooth and safe.