By its original definition, a hacker is a skilled or clever computer expert who can solve technical problems using non-standard or undocumented means. The term is now generally used instead to refer to a security hacker, or someone skilled at gaining unauthorized access to a computer system.
The term originally applied to a general subculture of early computer enthusiasts in the 1960s, 70s, and 80s. These hackers were hobbyists who found enjoyment in creatively pushing the limits of what they could accomplish on their computers. This sort of hacker subculture continues today, often seen in the open source software community, computer clubs, and events known as "hackathons."
Now, the term "hacker" is most often used to refer to security hackers who illegally access computer systems, often for nefarious reasons. A hacker's methods of gaining entry to a system can be simple, like guessing or stealing login credentials. Skilled hackers may use more complex methods like exploiting bugs or implanting a virus in a system. They may also use social engineering or phishing to gain access.
Not all hackers break into computer systems for nefarious reasons. "White Hat" hackers are also known as ethical hackers; they are security researchers hired by the operators of a system to break into it. They identify weaknesses, like zero-day exploits, to fix them and help fortify a system against other hackers. "Grey Hat" hackers are similar to White Hats — breaking into systems and reporting the vulnerabilities they discover, but without advance permission. Grey Hats generally perform this work to claim an offered payment, known as a "bug bounty." "Black Hat" hackers, meanwhile, are the hackers who break into systems for criminal purposes like stealing information or extorting payment via ransomware.