In this blog post, we will explore the su command in Linux, which allows you to switch the shell to another user. This can be particularly useful when you need to perform certain tasks or access files associated with a different user account.

Let’s say you are currently logged in as the root user and you want to switch to another user account. You can use the following syntax to achieve that:

su <username>

For example, if you want to switch to the user account named flavio, you would enter the command su flavio.

When you execute the su command without specifying a username, it assumes that you want to switch to the root user. In this case, it will prompt you to enter the password for the root user.

Screenshot

Once you enter the correct password, su will start a new shell as the specified user. You can now perform actions, access files, and execute commands as if you were logged in as that user.

To return to your original user account, simply type exit in the shell. This will close the shell associated with the switched user and bring you back to your current user’s shell.

It’s worth noting that the su command works on Linux systems. However, on macOS, you will need to enable the root user in order to use it. As an alternative, you can use the sudo command to execute commands with root privileges.

In summary, the su command is a powerful tool that allows you to switch the shell to another user in Linux. It provides a convenient way to perform tasks or access files associated with different user accounts.

Tags: Linux command, su, user account, shell, root user, sudo