In Babylonian and Assyrian religions, Shedim was a generic name like the Hebrew and Christian word ‘spirit.’ The word possibly derives from the root meaning ‘to be violent.’ They were frequently portrayed as winged bulls that guarded the entrances to temples.
They can appear with an evil connotation in magical texts, like the following:
“the evil spirit (Sedu, Heb.: Shed), the dazzlig fiend (alu, Sum.:galla),
the evil wind, the assaulting wind,
which strips off the clothing of the body as an evil demon,
conjure, O spirit of heaven! conjure, O spirit of earth!”
Or as a friendly spirit:
“may the evil incubus depart;
to another pace may he betake himself;
may the propitious spirit (Sedu) (and) the propitious colossus
rest upon his body…”
In the OT, they seem to only have the evil connotation. Deuteronomy 32:17 says of them:
“They sacrificed to demons [Hebrew: Shedim], no-gods,
Gods they had never known,
New ones, who came but lately,
Who stirred not your fathers’ fears.”
They are also mentioned in Psalms 106:37-38
“Their own sons and daughters,
they sacrificed to demons [Hebrew: Shedim].
They shed innocent blood,
the blood of their sons and daughters,
whom they sacrificed to the idols of Canaan;
so the land was polluted with bloodguilt.”
The Bereshith Rabba vii says they were created by God. God created their souls, but then the Sabbath came and He rested, so as a result, they remained disembodied. It is also said they were begotten by Adam during the period that he and Eve were separated after their transgression. Other texts claim that they were the offspring of Adam and Lilith. There is also the story that some of the people that were scattered after the building of the tower of Babel were transformed into Shedim, Ruchin, and Lilin.
The chief of the Shedim according to the T.B. Pesachim is Asmedaj. They are thought to live in deserted and/or unclean places.