Plays a role in peptidoglycan recycling by cleaving the terminal beta-1,4-linked N-acetylglucosamine (GlcNAc) from peptide-linked peptidoglycan fragments, giving rise to free GlcNAc, anhydro-N-acetylmuramic acid and anhydro-N-acetylmuramic acid-linked peptides. Hydrolysis of terminal non-reducing N-acetyl-D-hexosamine residues in N-acetyl-beta-D-hexosaminides. Cell wall biogenesis; peptidoglycan recycling. Monomer. Belongs to the glycosyl hydrolase 3 family. NagZ subfamily.