I will like to ask is $brew command line doing the same thing $ sudo does ?
It's a completely different thing.
sudo is used to authorize something. While
brew, is kind of like the App Store.
When in doubt you can always try to see the documentation/manual page.
NAME
sudo, sudoedit - execute a command as another user
DESCRIPTION
sudo allows a permitted user to execute a command as the superuser or another user, as specified by the security policy. The invoking user's
real (not effective) user-ID is used to determine the user name with which to query the security policy.
NAME
brew - The Missing Package Manager for macOS (or Linux)
DESCRIPTION
Homebrew is the easiest and most flexible way to install the UNIX tools Apple didn´t include with macOS. It can also install software not
packaged for your Linux distribution to your home directory without requiring sudo.