Assalaamu alaykum. I know now that swearing is prohibited, but what if the swearing is not directed at someone, like when someone randomly swears when something bad happens or perhaps swears at an object, and not a person?
All perfect praise be to Allah, The Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad, sallallahu ‘alayhi wa sallam, is His slave and Messenger.
The person who is given to cursing and swearing all the time or when bad things happen to him or curses inanimate objects, for instance, is indeed afflicted with a blameworthy trait. It is one of the diseases of the tongue about which Ibn Qudaamah said, “The fourth disease: indecent language, swearing, and a foul mouth; all of which are dispraised and forbidden. The source of it is wickedness and cunning. The Prophet, sallallahu ‘alayhi wa sallam, said, 'Beware of obscenity; Allah does not like obscenity or uttering obscenities.' 'Paradise is forbidden for every obscene person.' 'The believer is not given to slander, cursing, obscenity, or foul language.'” [Minhaaj Al-Qaasideen]
Nadhrat An-Na‘eem fi Makaarim Akhlaaq Ar-Rasool Al-Kareem reads, “Al-Ghazaali wrote, 'Swearing, obscene language, and vulgarity are dispraised and forbidden. Their source is wickedness and cunning with the intention of harming, or they are acquired as a habit due to keeping the company of immoral people who are given to wickedness, because it is the habit of such people to swear.’”
Whoever is plagued with the habit of swearing has to discipline himself and guard his tongue. The Prophet, sallallahu ‘alayhi wa sallam, advised Mu‘aath, may Allah be pleased with him, to guard his tongue, saying, “...Shall I not tell you of the way to control all this?” Mu‘aath said, “Yes, O Messenger of Allah.” He took hold of his tongue and said, “Restrain this.” Mu‘aath said, “O Prophet of Allah, will we be held accountable for what we say?” He, sallallahu ‘alayhi wa sallam, said, “May your mother lose you, O Mu‘aath! Are people thrown onto their faces - or their noses - in Hellfire for anything other than the harvest of their tongues?” [At-Tirmithi graded it hasan saheeh (good or sound)]
Al-Munaawi commented on the hadeeth, saying, “Whoever gives free rein to his tongue, Satan directs him everywhere and ultimately leads him to destruction. Nothing saves from the evil of the tongue but the reins of the Sharia.’”
Allah knows best.
You can search for fatwa through many choices