The command to kill dogs, and its abrogation. The prohibition of keeping dogs, except for hunting, farming, (herding) livestock and the like Sahih Muslim 1574 e

Arabic hadith text
حَدَّثَنَا إِسْحَاقُ بْنُ إِبْرَاهِيمَ، أَخْبَرَنَا وَكِيعٌ، حَدَّثَنَا حَنْظَلَةُ بْنُ أَبِي سُفْيَانَ، عَنْ سَالِمٍ، عَنْ أَبِيهِ، عَنْ رَسُولِ اللَّهِ صلى الله عليه وسلم قَالَ ‏"‏مَنِ اقْتَنَى كَلْبًا إِلاَّ كَلْبَ ضَارٍ أَوْ مَاشِيَةٍ نَقَصَ مِنْ عَمَلِهِ كُلَّ يَوْمٍ قِيرَاطَانِ ‏"‏ ‏.‏ قَالَ سَالِمٌ وَكَانَ أَبُو هُرَيْرَةَ يَقُولُ ‏"‏ أَوْ كَلْبَ حَرْثٍ ‏"‏ ‏.‏ وَكَانَ صَاحِبَ حَرْثٍ
Translation
Salim reported on the authority of his father (Allah be pleased with him) that Allah's Messenger (ﷺ) said

He who kept a dog other than one meant for hunting or for the protection of the herd would lose two qirat of his deeds every day. Salim said: Abu Huraira (Allah be pleased with him) used to say: Or the dog meant for watching the field, and he was the owner of the land.