In order to get the result specified in the title of the article, there is a single command which is needed to be executed as ‘root’ in the command line of FreeBSD operating system. Below is the situation depicted when a user is logging in to the operating system but unfortunately after successfully logging in, the user cannot switch to root account :
root@hostname:~# ssh [email protected] Password for user@mybsd: Last login: Sat Jul 14 22:05:54 2018 from xxx.xxx.xxx.xxx FreeBSD 11.1-RELEASE (GENERIC) #0 r321309: Fri Jul 21 02:08:28 UTC 2017 Welcome to FreeBSD! Release Notes, Errata: https://www.FreeBSD.org/releases/ Security Advisories: https://www.FreeBSD.org/security/ FreeBSD Handbook: https://www.FreeBSD.org/handbook/ FreeBSD FAQ: https://www.FreeBSD.org/faq/ Questions List: https://lists.FreeBSD.org/mailman/listinfo/freebsd-questions/ FreeBSD Forums: https://forums.FreeBSD.org/ Documents installed with the system are in the /usr/local/share/doc/freebsd/ directory, or can be installed later with: pkg install en-freebsd-doc For other languages, replace "en" with a language code like de or fr. Show the version of FreeBSD installed: freebsd-version ; uname -a Please include that output and any error messages when posting questions. Introduction to manual pages: man man FreeBSD directory layout: man hier Edit /etc/motd to change this login announcement. To see the last 10 lines of a long file, use "tail filename". To see the first 10 lines, use "head filename". -- Dru <[email protected]> $ su - su: Sorry $ su - root su: Sorry $
As shown in the above output, a user connecting remotely to a host with the FreeBSD installed operating system even where normally a user created after fresh installation cannot switch to root. In order for that user can switch to root account, below is the actual process for achieving it by executing the command in the steps taken as follows :
1. Access the command line interface of FreeBSD
2. Try to be the root account. It can be done either by logging as root locally or it might done remotely or switch from a normal account to a root account.
root@hostname:~# ssh [email protected] Password for root@mybsd: Last login: Sat Jul 14 22:01:56 2018 FreeBSD 11.1-RELEASE (GENERIC) #0 r321309: Fri Jul 21 02:08:28 UTC 2017 Welcome to FreeBSD! Release Notes, Errata: https://www.FreeBSD.org/releases/ Security Advisories: https://www.FreeBSD.org/security/ FreeBSD Handbook: https://www.FreeBSD.org/handbook/ FreeBSD FAQ: https://www.FreeBSD.org/faq/ Questions List: https://lists.FreeBSD.org/mailman/listinfo/freebsd-questions/ FreeBSD Forums: https://forums.FreeBSD.org/ Documents installed with the system are in the /usr/local/share/doc/freebsd/ directory, or can be installed later with: pkg install en-freebsd-doc For other languages, replace "en" with a language code like de or fr. Show the version of FreeBSD installed: freebsd-version ; uname -a Please include that output and any error messages when posting questions. Introduction to manual pages: man man FreeBSD directory layout: man hier Edit /etc/motd to change this login announcement. root@mybsd:~ #
3. Just execute the following command :
pw groupmod wheel -m user
For an example, the above command can be executed in the following real situation :
root@mybsd:~ # pw groupmod wheel -m user root@mybsd:~ # exit logout Connection to xxx.xxx.xxx.xxx closed. root@hostname:~#
4. Test the user whether it can be switched to root account as shown in the following output :
root@hostname:~# ssh [email protected] Password for user@mybsd: Last login: Sat Jul 14 23:44:36 2018 from xxx.xxx.xxx.xxx FreeBSD 11.1-RELEASE (GENERIC) #0 r321309: Fri Jul 21 02:08:28 UTC 2017 Welcome to FreeBSD! Release Notes, Errata: https://www.FreeBSD.org/releases/ Security Advisories: https://www.FreeBSD.org/security/ FreeBSD Handbook: https://www.FreeBSD.org/handbook/ FreeBSD FAQ: https://www.FreeBSD.org/faq/ Questions List: https://lists.FreeBSD.org/mailman/listinfo/freebsd-questions/ FreeBSD Forums: https://forums.FreeBSD.org/ Documents installed with the system are in the /usr/local/share/doc/freebsd/ directory, or can be installed later with: pkg install en-freebsd-doc For other languages, replace "en" with a language code like de or fr. Show the version of FreeBSD installed: freebsd-version ; uname -a Please include that output and any error messages when posting questions. Introduction to manual pages: man man FreeBSD directory layout: man hier Edit /etc/motd to change this login announcement. If you want to play CDs with FreeBSD, a utility for this is already included. Type 'cdcontrol' then 'help' to learn more. (You may need to set the CDROM environment variable in order to make cdcontrol want to start.) $ su - Password: root@mybsd:~ #
As shown above, the switch process by executing the command ‘su -‘ has already successfully carried out.