There was a special anointing oil (“shemen hamishcha” in Hebrew), which was used to anoint High Priests and kings of the Davidic dynasty (as opposed to the kings of the northern kingdom after the civil war). In the original dedication of the Mishkan, it was also used to inaugurate Aaron’s sons as priests, though ordinary priests were not anointed after this. The oil was made from a special recipe including cinnamon, myrrh, cassia and other ingredients. As we will see in Mitzvah #109, it was forbidden to make oil according to this recipe for any other purpose. A supply of this oil was kept on hand at all times until the end of the first Temple period. (There was no shemen hamishcha in the second Temple; according to the Talmud in Horayos 12a, it was among the items hidden away for safekeeping when the first Temple was under siege.)
The underlying premise of this mitzvah is that anointing with oil is reserved for things of great importance, such as the king or the Kohein Gadol. Accordingly, these people were anointed when they started their terms of service. (The word “moshiach,” “messiah” in English, means “anointed one.” The Moshiach is so called because he will be a descendant of the Davidic dynasty, who were the anointed kings.)
This mitzvah applies to everyone, as it was a communal responsibility to see to it that there was anointing oil, just as building the Mishkan was a communal responsibility. The anointing oil is discussed in the Talmudic tractates of Kerisos (5a-b) and Horayos (11b-12b). This mitzvah is codified in the Mishneh Torah in the first chapter of Hilchos Klei HaMikdash and is #35 of the 248 positive mitzvos in the Rambam’s Sefer HaMitzvos.