Abu Hurairah (May Allah be pleased with him) said: The Messenger of Allah (PBUH) said, "Avoid two habits which provoke cursing." The Companions said: "What are those things which provoke cursing?" He said, "Relieving on the thoroughfares or under the shades where people take shelter and rest."[Muslim].
We learn from this Hadith that a Muslim must avoid all such things which cause inconvenience to other Muslims. If one uses the places mentioned in this Hadith as toilet, this would not only cause inconvenience to the public but may also cause an epidemic. It is also necessary to avoid such things for the sake of cleanliness. Some religious scholars are of the opinion that this act is deemed to be a major sin, as it brings people's curses upon the one who practices it.