A subgroup H of a finite group G is called a subgroup perfect code of G if there exists an inverse-closed subset S of \(G\setminus \{1\}\) such that H is a perfect code in the Cayley graph \(\textrm{Cay}(G,S)\) . In this paper, we determine the subgroup perfect codes of 2-groups with cyclic maximal subgroups, and for groups with such Sylow 2-subgroups, we deduce a correlation between their subgroup perfect codes and Sylow 2-subgroups. As applications, subgroup perfect codes of the special linear groups \(\textrm{SL}_{3}(q)\) with \(q\equiv 1 \pmod 4\) and finite groups with cyclic subgroups of index 2 are studied.