Firstly: What is Said upon Entering
It is from the sunnah to say upon entering the place of relieving oneself: “Allah, I seek refuge from you from male and female devils.”  Ibn Hajar said: “This may refer to two scenarios: the first of which is if this dhikr is specific for places where one normally relieves oneself and are thence inhabited by devils, as is in the Hadith of Zayd ibn Arqam, or whether it additionally includes any time one wishes to relieve oneself, like in a vessel in the corner of his abode. The second opinion is most correct.” Fath al-Bari (244/1)
Secondly: What is Said upon Exiting
It is from the sunnah to say upon leaving the place of relieving oneself: “Allah, I ask for Your forgiveness!”  Ibn `Uthaymin said: “He says this after exiting, and if he is in the open, then upon leaving the place where he squatted.” Al-Sharh al-Mumti` (1/104-105)
Thirdly: Entering with The Left Foot and Exiting with The Right
It is mustahabb to enter khala'  Khala' literally means emptiness, but contextually refers to the place of relieving oneself. It may refer in today’s age to toilets. with the left foot and exit with the right, and this is by agreement of the four schools of jurisprudence.
Fourthly: Avoiding Allah’s Mention in Khala' Mentioning Allah in Khala'
It is makruh to mention Allah by the tongue when relieving oneself. This includes repeating after the call to prayer and supplicating for the one who sneezed. This is by agreement of the four schools of jurisprudence. Entering What Has the Mention of Allah in Khala'
It is makruh to enter what has the mention of Allah to khala'  Al-Shawkani said: “Qur’an has even more priority [not to be taken into khala'], to the point that some have said it is haram to take a mushaf (book wherein Qur’an is written) into khala' without need.” Nayl al-Awtar (74/1). Phones and other devices that have Qur’an applications installed are not a valid analogy and so do not take the same ruling. except due to a need, and this is by agreement of the four schools of jurisprudence.
Fifthly: Talking while Relieving Oneself
Talking while relieving oneself is makruh if without some benefit.  Al-Nawawi said: “Any scenario where there is need for talking is an exception for this, like if he saw a blind man about to fall into a well, or a snake or scorpion heading for a person, or other scenarios, then talking in these situations is not makruh, rather it is obligatory.” Sharh al-Nawawi `ala Muslim (65/4) This is by agreement of the four schools of jurisprudence, and a group of the Salaf held this view, as well as the majority of jurists.
Sixthly: Maintaining a Distance if in The Dessert
It is liked for one relieving himself in the desert or an arid expanse to further himself from others’ sight.  Unless he is able to cover up or hide somewhere, in which case covering up suffices from furthering himself. The majority have explicitly mentioned this: Malikis, Shafi`is, and Hanbalis.
Seventhly: Covering up from Others’ Sight
It is wajib for a person relieving himself to cover up from others sight such that they are unable to see his `awrah. Consensus has been quoted on the obligation of covering one’s `awrah: al-Jassas, Ibn `Abd al-Barr, Ibn Rushd the grandson and Ibn Rajab al-Hanbali.
Eighthly: Seeking out Soft Land for Relieving Oneself
It is mustahabb for one about to relieve himself to seek out a soft piece of land,  Rikhw, in Arabic and in this context, refers to some sort of land that will not cause the urine to spray, like sand or soil. Ibn `Uthaymin said: “It refers to the soft piece of land where urine is not feared to spray.” Al-Sharh al-Mumti`(110/1) and this is by agreement of the four schools of jurisprudence.
Ninthly: Facing the Qiblah or Away from it when Relieving Oneself
It is haram to face towards or turn one’s back to the qiblah when relieving oneself in open spaces, but is permissible in built spaces. This is the position of the majority: Malikis, Shafi`is, and Hanbalis.
Tenthly: Facing the Wind when Urinating
It is makruh to face the wind when urinating, and this is by agreement of the four schools of jurisprudence.
Eleventhly: Places where Relieving Oneself is Prohibited The Mosque
It is haram to relieve oneself in the mosque, and this is by agreement of the four schools of jurisprudence. Graves
It is haram to relieve oneself on a grave, and this is by agreement of the four schools of jurisprudence. Places where People Meet and Benefit from
It is haram to relieve oneself on a path, under beneficial shade, under fruiting trees, and other places where people meet and benefit in. This is an opinion among the Malikis, a narration from Ahmad, and chosen by al-Nawawi and Ibn `Uthaymin. In a Hole or Crack
It is makruh to urinate in a crack or a hole  Sarab refers to a hole in the earth without an escape, also Wakr – an animal’s small den. Al-Nawawi said: “a hole is that which is circular, and it is what is referred to as juhr…and sarab is what is rectangular.” Al-Majmu` (86/2) and similar outlets, and this is by agreement of the four schools of jurisprudence. Bath
It is makruh to urinate or defecate in a bath  Al-Baghawi said: “What is meant by mustahamm is the place of bathing and washing, and it is referred to as mustahamm from hamim, which is hot water used for washing.” Sharh al-sunnah (384/1) that has no outlet, and this is by agreement of the four schools of jurisprudence.  Malikis used the term ijtinab in this matter sometimes, meaning to avoid, and with tark on others, which is to leave; that is, leaving it is required.