Let it be known that it is not easy for a jinn to harm a human physically or to appear to him, because in this case he exposes himself to being punished by means of the Qur'an, because he is detaining himself inside the human's body. And he exposes himself to destruction and death when he appears in a different form, because he is then subject to the same rules that affect the form in which he appears.
So if he appears in the form of a cat, for example, and you kill him with, say, a spear, then he will be killed, as in the story of the young Ansari man which is narrated in Sahih Muslim. Hence the jinn do not harm a human unless they are certain that he is completely negligent in remembering Allah (SWT) and is far away from Him, so that they can harm him.
A jinn may harm a human wrongfully, for no purpose, as foolish people also do.
A jinn may fall in love with a human and desire him, as happens between people, so he possesses him.
A human may harm a jinn without realizing, by falling on him, throwing a stone at him, urinating on him or pouring hot water on him, so the jinn punishes him more than he deserves.