Understanding the “su” Command in Linux

What is the “su” Command?

The "su" command in Linux means "substitute user,". It allows you to change to a different user account.

Basic Usage

To switch to the root user, simply type: su

Switching to a Specific User

Use the following syntax to switch to a specific user: su username

Running a Single Command

Execute a single command as another user: su -c "command" username

Root Privileges

Switch to the root user without using the “-” option: su root

Security Considerations

Use “su” cautiously. It's best practice to limit its usage to minimize security risks.

Discover the Best Linux Hosting Companies

Arrow