Is it possible to have temporary root access on termux or any other terminal without rooting your android phone? I would like to know whether it is possible to be able to have a temporary root access to an android phone using a Termux or any other terminal in the same way that ubuntu does without rooting your phone.
Ubuntu for PC is permanently rooted. It comes with root user as well as with the mechanism to allow a process to gain superuser privilege when requested so and authenticated by the user (that which you considered temporary root). Android devices, on the other hand, do not provide the mechanism to gain superuser access. That mechanism, often involves installing a su binary coupled with some daemons and hacks, provides the user a way to gain elevated privileges and manage that privilege on a per app basis.

Even if you root a device, it is not like every app or process gets to have superuser access on its own. It is the user, through a superuser manager app such  as SuperSU and Magisk, who manages whether to permit temporary or permanent access to superuser privilege.