su command is used to switch to another user, in other words, change user ID during a normal login session (that is why it is sometimes referred to as switch (-) user by a number of Linux users). If executed without a username, for example, su - it will log in as root user by default.

Following command, then you will be prompted for the password of the user you’re switching to.

$ su ucartz

When you invoke su with a -, or -l or --login flags, it offers you a login interface similar to when you are logging on normally. All the commands below are equivalent to each other.

$ su - ucartz
$ su  -l ucartz
$ su --login ucartz

When you run su without a username, you will automatically become the superuser. You will be given root’s default environment, including the path to executable files changes. You will also land into root’s home directory:

$ su

Was this answer helpful? 2 Users Found This Useful (2 Votes)