How can I switch one user to another in Freebsd?
For examples, I am user david now and I want to change to user Bob. This is a personal OS for my study. not a server. I searched it, but only got sites about how to create new user. Thank you.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
You have many options, including
The easiest way is to run su, e.g.
$ su otheruser
$ su - otheruser
The first one sets your user to
The second one sets you user to
otheruser and sources otheruser's login scripts (e.g.
csh), to make it seem like you've logged in as that user.
root (or is missing, which also means
root), then you will need to be in the
wheel group, as per the man page:
by default only users in the
wheelgroup can switch to UID 0 (
Another way is login, e.g.
$ login login: otheruser Password:
Or, if you are running sshd, you could use ssh, e.g.
$ ssh otheruser@localhost
# cd /usr/ports/security/sudo # make && make install
# pkg_add -r sudo
See the sudo man page for details of how to run it.
su can be used for this purpose. If you want to become user
bob you would type:
su will then ask for a password, which is
bob's password, not yours. When invoked without arguments it tries to become superuser (same as
su root). You may have to add your user account to the
wheel group, or change some configuration so that the normal user can use
I usually do:
sudo su - bob
so I won't need to know the password of the other user (Note: I'm a Linux user and I'm not sure how different BSD is).