Use su
:
su - alice
sudo vim /etc/hosts
De man su
:
The su command is used to become another user during a login session.
Invoked without a username, su defaults to becoming the superuser. The
optional argument - may be used to provide an environment similar to
what the user would expect had the user logged in directly.
Para mais informações, consulte
man su
e Wikipedia .