In Linux, there is really no meaningful distinction between GUI applications and terminal applications. Actually, X is just another application -- it happens to do some pretty complex stuff, but as far as the OS is concerned, there is nothing special about it. Anything that X can do, any other application can do, and in the end, X is all about managing the display and input devices and exposing a unified API to do things like drawing to the screen and reading pointing device input, regardless of the underlying hardware. Various toolkits such as Qt, GTK and others build upon that to provide a more high-level approach to developing userland applications, offering such advanced features as input text boxes, menus, clickable buttons, list views and more.
Some Linux applications even expose double user interfaces, selecting which one to use depending on whether there is a display attached to the current terminal or not. More have separate builds depending on whether you want an X interface or not. Examples might be Emacs and Vim.
This is in stark contrast to e.g. Windows or (I believe) OS X, where the GUI is for all intents and purposes an inseparable part of the operating system itself. Look at Windows Server Core, for example; they did away with Explorer and a whole bunch of other things, but they kept the GUI right there, except by default it just drops you to a command prompt window! Now that takes some getting used to.
The Linux kernel doesn't concern itself with any command line, other than its own (the one you can edit through the boot manager). Anything beyond that (including $PATH handling and file name globbing) is handled by userspace applications like the GNOME desktop, the bash shell, the system initialization application (normally /sbin/init -- although that one is somewhat of a hybrid between a part of the kernel and a userland program like any other, it executes in user space and has no special privileges granted by the kernel), the text editor, or what have you.
And Ubuntu isn't "essentially Linux under the hood"; it is a Linux distribution, like Debian, Slackware, RHEL, SuSE or any number of others. They probably package some software of their own just like pretty much every other mainstream distribution, but there's nothing non-Linux about it. It is closely related to Debian though, which can be used without Linux (that's Debian/kFreeBSD, which is pretty much the same old Debian but running on top of the FreeBSD kernel).