That's called a boolean action, subtracting one solid from another


https://www.youtube.com/watch?v=Djh7ZSxuYYQ