Changing Identities

At various times, we may find it necessary to take on the identity of another user. Often we want to gain superuser privileges to carry out some administrative task, but it is also possible to “become” another regular user to perform such tasks as testing an account. There are three ways to take on an alternate identity:

  • Log out and log back in as the alternate user.

  • Use the su command.

  • Use the sudo command.

We will skip the first technique because we know how to do it and it lacks the convenience of the other two. From within your own shell session, the su command allows you to assume the identity of another user and either start a new shell session with that user’s ID or issue a single command as that user. The sudo command allows ...

Get The Linux Command Line now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.