Ubuntu and Debian aren't "operating systems" -- they're distributions of the GNU/Linux OS (and a lot of add-on bits and pieces), with strong packaging help, UI tweaks, etc. (There are many other distributions of the same OS -- Gentoo, Fedora and Mandriva being some of the most successful).
If you want to build a distribution of Linux (or other open-source OS, such as a BSD variant or others yet), Python is a precious language for you (it's used in a particularly intensive way in Ubuntu, possibly in part because its ideator, Mark Shuttleworth, is a big fan of Python -- but no doubt in part because it's so good for the job).
If you want to build a brand new kernel, at the other extreme, you need strong command of C, a little machine language / assembly, and at least the kind of know-how you would get by reading several of Tanenbaum's books.
Between a bare kernel, and a full distribution (or full-fledged commercial OSs such as MacOSX or Windows 7), there is, of course, a huge number of large components (that's why GNU/Linux is a proper way to name what many call just "Linux": Linux is actually the kernel, GNU software adds compilers, shells, many utilities, libraries, and so on -- though many other crucial parts, like the graphical parts, depend on completely different components yet, most of them not related to GNU or the Free Software Foundation).
To write "the whole stack" -- from the kernel up all the way to a full, rich modern distribution -- basically requires strong competence in all kinds and areas of software development (one might except "application programming", but much of what nowadays is identified as "OS" in the sense of a full distribution is actually entirely at the application layer, so the exception isn't really one;-).
So, you need to clarify, or at least prioritize!, your desires: do you want to start with the parts that "run on the bare metal" and present more usable facades for it to every other piece of code on the system -- i.e., the kernel -- or take existing kernels &c, and build a full-fledged distribution on top of them... or, what else?