The concentration of viruses in sewage sludge is significantly higher (10-1000-fold) than that found in natural environments, posing a potential risk for human and animal health. However, the composition of these viruses and their role in the transfer of pathogenic factors, as well as their role in the carbon, nitrogen, and phosphorus cycles remain poorly understood. In this study, we employed a shotgun metagenomic approach to investigate the pathogenic bacteria and viral composition and function in two wastewater treatment plants located on a campus. Our analysis revealed the presence of 1334 amplicon sequence variants (ASVs) across six sludge samples, with 242 ASVs (41.22% of total reads) identified as pathogenic bacteria. Arcobacter was found to be the most dominant pathogen accounting for 6.79% of total reads. The virome analysis identified 613 viral genera with Aorunvirus being the most abundant genus at 41.85%. Approximately 0.66% of these viruses were associated with human and animal diseases. More than 60% of the virome consisted of lytic phages. Host prediction analysis revealed that the phages primarily infected Lactobacillus (37.11%), Streptococcus (21.11%), and Staphylococcus (7.11%). Furthermore, our investigation revealed an abundance of auxiliary metabolic genes (AMGs) involved in carbon, nitrogen, and phosphorus cycling within the virome. We also detected a total of 113 antibiotic resistance genes (ARGs), covering major classes of antibiotics across all samples analyzed. Additionally, our findings indicated the presence of virulence factors including the clpP gene accounting for approximately 4.78%, along with toxin genes such as the RecT gene representing approximately 73.48% of all detected virulence factors and toxin genes among all samples analyzed. This study expands our understanding regarding both pathogenic bacteria and viruses present within sewage sludge while providing valuable insights into their ecological functions.