# Is there any way to determine if the compound is oxide or peroxide or superoxide?

I know that in an oxide oxygen's oxidation number is $-2$, in a peroxide oxygen's oxidation number is $-1$ and in a superoxide oxygen's oxidation number is $-\frac12$. So, how will I be able to detect that any compound is oxide or peroxide or superoxide?

For example, to get the oxidation number of $\ce{Mn}$ in $\ce{KMnO4}$ how will I determine whether $\ce{KMnO4}$ is an oxide, superoxide or peroxide? Is there any way?

Generally there is no way to detect such things from brutto-formula. For example, compound $\ce{CH2O2}$ may be either dioxirane (methylene peroxide) or formic acid. In practice, however, peroxides are really unstable, so in most cases if compound is not overloaded with oxygen (like, $\ce{H2SO5}$) and is reasonably stable towards thermal decomposition, it is most likely oxide and not peroxide. Peroxides are usually formed either from another peroxide or electrochemically, or (in rare cases) via cold oxidation with molecular oxygen. And there are exactly three common superoxides.
If you want to distinguish oxide, superoxide and peroxide ions, generally you can use their X-ray structure well. Oxide is a single oxygen ion, superoxide and peroxide is $O-O$ with approximate bond distance of 1.33 and 1.49 A respectively. Superoxides also have an unpaired spin which can be often detected (even if it is coupling with some other spins).
If oxygen was with the metals of main group elements, the compound is peroxide, but if it was with nonmetals or other metals except for the metals of main group metals the compound is oxide. For example $$\ce{KMnO4}$$ is oxide it is composed of $$\ce {K+}$$ and $$\ce{MnO4-}$$ because there is manganese which is a metal that isnt among the main group elements group in the polyatomic ion. and the oxidation number of the $$\ce{Mn}$$ is $$7^+$$.