The statement, "a shot gun would like rip open your walls even if it didn't hit them" is not accurate. They can be powerful and can damage walls, but only the walls that are directly hit. I wonder about the general gun knowledge and common sense of someone who says that.
Bullets from a Glock 21 can definitely penetrate walls, even multiple walls, and also people. Rounds can actually leave your house and penetrate a neighbor's house, endangering the people inside. Most rounds fired in self defense miss the intended target, making this problem even worse. It is essential to know what is down range behind your target and fire only when it is safe to do so.
A responsible gun owner interested in home defense will plan out lines of fire ahead of time. Do not fire in the direction of other occupied rooms within your home or other neighboring homes. One good line of fire in many two-story homes is down the staircase. The downward angle of the shot will allow you to use the ground as a backstop. Bedrooms are often on the second story with points of entry on the first. The stairway is a place anyone must pass through to threaten the safety of family members upstairs. It would concentrate intruders into a narrow space and it offers no cover for those ascending, but good cover for someone laying on the floor at the top.
Some bullets penetrate less than others. One specially designed for these scenarios is called the "Glaser Safety Slug" which is designed to have very low penetration in building materials.
A good book to read about self and home defense is "In the gravest extreme" by M. F. Ayoob.
Gaining shooting experience at a gun range is highly recommended if you would consider using the gun in self defense. There are also many classes widely available, often aimed at people applying for a concealed weapon permit. A class like that would be helpful for your purposes as well. But at a minimum, shoot the gun at a range until you are comfortable with it.
And remember to always treat every gun as if it is loaded, even when it is empty, and never let it point at anything you wouldn't be willing to shoot.