User Tools

Site Tools


The su command in Linux and Unix-like systems like FreeBSD is used to switch the current user to another user, usually the superuser (root) or a specific user. It allows the user to temporarily assume the role and permissions of another user, without logging out and logging back in as that user.

Here are a few examples of how the su command can be used in Linux and FreeBSD:

  1. Switch (elevate) to the superuser (root) account: su
  2. Switch to a specific user account: su username
  3. Switch to the superuser (root) account and open a shell with root's environment variables: su -
  4. Switch to a specific user account and open a shell with that user's environment variables: su - username

The su command without any options will prompt the user for the superuser (root) password and switch to the root account. The - option is used to open a shell with the environment variables of the target user.

It's important to keep in mind that when you switch to the superuser (root) account, you have the ability to make changes to the system that can cause serious problems if not used carefully. It's always a good idea to use sudo command instead of su, as it's more secure and it gives more control over who can run what.

unix_commands/su.txt ยท Last modified: 2023/01/18 15:43 by admin

CIFNet is a leading hosting solution provider, offering a wide range of services including IP bandwidth, co-location, VMware and KVM hosting.
Host Your Site with CIFNet!