There are three ways to access the command line interface in Ubuntu, as on any Linux and UNIX distribution. One is launching the terminal emulator program within the graphical user interface. The other two are about accessing the console directly, independent of the graphical user interface and the windowing system powering it (typically X server), and that's what we're concerned with here.
The quickest way to get to the console in Ubuntu is to just press Ctrl-Alt-F1. You will immediately be thrown out of the GUI and into the clean Linux console where you can log in and use the command line. Multiple console terminals are available this way if you press Ctrl-Alt-F2, Ctrl-Alt-F3, and so on.
However, what you might want is to get into the text console when you boot into Ubuntu instead of booting directly into the graphics mode. For that you'll need to make some configuration changes to your GRUB bootloader. The configuration file you will need to modify is /etc/default/grub, and it is a good idea to make a backup of it first in case you ever want to come back to the original configuration:
sudo cp /etc/default/grub /etc/default/grub.backup
With that out of the way you can start modifying the configuration file by opening it, with superuser privileges, in a text editor such as nano:
sudo nano /etc/default/grub
Enter your password and the file will open. Then look for this line: GRUB_CMDLINE_LINUX_DEFAULT="quiet splash". Using nano you can search for this line by pressing the Ctrl-W shortcut and typing that line in. You just need to comment it out by putting a hash character in front of it so it looks like this:
# GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
As you might guess this disables booting with the splash screen, and the "quiet" mode, meaning it wouldn't hide the console output during boot.
Next enable the text mode finding GRUB_CMDLINE_LINUX and adding the "text" option to it. The line will then look like this:
This will ensure that you see the text output, but still doesn't enable the console login. For that find the #GRUB_TERMINAL line, which is likely commented out, uncomment it by removing the # character, and add the "console" option to it so it reads like this:
Finally save the file, which in nano you can do by pressing Ctrl-X and then enter, and make sure to update GRUB with the new configuration using the update-grub command:
Now you can reboot and Ubuntu should boot in the text mode, and allow you to log in to the console and run the desired commands.