1610s, "fruit of the tropical palm tree," from coco + nut. In reference to the dried, shredded flesh of the nut used in cookery and confections, by 1830. Meaning "the head" is slang from 1834. Coconut-oil is attested from 1829.
"palm tree," 1550s, from Spanish and Portuguese coco "grinning or grimacing face," on resemblance of the three depressions at the base of the shell to a monkey or human face. The earlier word for it was the Latinized form cocus, which sometimes was Englished as cocos.
"the fruit of certain trees and shrubs which have the seed enclosed in a woody covering not opening when ripe," Middle English note, from Old English hnutu, from Proto-Germanic *hnut- (source also of Old Norse hnot, Dutch noot, Old High German hnuz, German Nuss "nut"), from PIE *kneu- "nut" (source also of Latin nux; see nucleus).
Sense of "testicle" is attested by 1915 (nuts). Nut-brown "brown as a ripe, dried nut" is from c. 1300 of animals; c. 1500 of complexions of women. The mechanical nut that goes onto a bolt is first recorded 1610s, from some fancied resemblance (nut was used of other small mechanical pieces since early 15c.). The figurative nuts and bolts "fundamentals" is by 1952. The American English slang sense of "amount of money required for something" is recorded by 1912.
Meaning "crazy person, crank" is attested from 1903; British form nutter is attested by 1958. Nut-case "crazy person" is from 1959; nut-house "insane asylum" is by 1929. For more on this sense, see nuts. In slang, nut also meant "fashionable or showy young man of affected elegance" [OED], 1904.
<a href="https://www.etymonline.com/word/coconut">Etymology of coconut by etymonline</a>
Harper, D. (n.d.). Etymology of coconut. Online Etymology Dictionary. Retrieved $(datetime), from https://www.etymonline.com/word/coconut