Someone who looks for or exploits weaknesses in a computer system or network, typically illegally or illegitimately. Someone engaged in legitimate vulnerability research or penetration testing is sometimes called an “ethical hacker” or white hat hacker.
Someone who enjoys achieving a detailed understanding of how software or hardware work, and in extending systems’ capabilities, as opposed to the ordinary user who has no interest in such understanding. In this sense, “hacker” is not pejorative.