Sayyiduna Abdur Rahman bin Abu Qurad رضي الله عنه narrates that I set out with the Messenger of Allah صلى الله عليه وسلم (for Hajj). (Once) I saw that when the Messenger of Allah صلى الله عليه وسلم came out from the toilet (after relieving himself), and when he intended to relieve himself, he would go far away from the people.
Hadith Referenceصحيح ابن خزيمه / جماع أبواب الآداب المحتاج إليها في إتيان الغائط والبول إلى الفراغ منها / 51
Hadith Gradingالألبانی:اسناده صحيح: صحيح ابي داوٗد: 11
Hadith Takhrij«سنن النسائى: كتاب الطهارة باب الابعاد عند ارادة الحاجة ، رقم: 16 ، وفي الكبرىٰ: رقم: 17 ، سنن ابن ماجه: 334 ، مسند احمد: 443/3 ، 237 ، 224 ، وعبد الله بن أحمد فى زيادته على المسند: 224/4»
These hadiths mention the etiquettes of relieving oneself, that when in an open place, one should go so far that he becomes hidden from the sight of people. Or, if there are low-lying places where some cover is available, then relieving oneself in such places is also permissible, even if they are near inhabited areas. Similarly, it is also permissible to relieve oneself in a restroom (toilet), or by using a cloth or similar means as a screen. The requirement in relieving oneself is to cover the private parts (awrah); wherever and however this covering is achieved, relieving oneself is permissible and correct.
Source: Sahih Ibn Khuzaymah: Commentary by Muhammad Farooq Rafee, Page: 51