To elevate to the root user in the macOS terminal:

sudo -s

This opens a shell with root privileges. Use with caution — you’ll have unrestricted access to the system.

To exit the root shell, simply type exit.