In order to be able to immediately hold down any chord that comes along, you need to remember where the root note is. So far, we have discussed the 6th string root chord, the 5th string root chord, and the 4th string root chord, but it is especially useful to remember just the 6th and 5th strings. These are good enough to hold most chords.
As for how to learn it, first of all, learn the positions without sharp(#) or flat(b). If you increase by one fret you get a # sound, while if you decrease by one fret you get a flat sound. If you learn just the finger numbers below the 10th fret, you will be able to play all octaves.
And if possible, I recommend learning the positions on the second string as well. Guitars have a special tuning for the 2nd string. The other strings are tuned in intervals of perfect fourths with the upper strings, but only the second string is tuned in intervals of major third degrees. Therefore, I think it is a good idea to learn the 2nd individually.
As for the 4th, 3rd, and 1st strings, their positions are easily found through the above positions. The 4th string is just a two-fret advance of the 6th string, the 3rd string is just a two-fret advance of the 5th string, and the 1st string is the same as the 6th string. That is to say, once you have memorized the positions shown in the diagram above, you have memorized everything from the first to the sixth strings!
Rather than memorizing these notes, I think you will learn them on your own as you play various pieces while trying to remember them, so be patient. It is a good idea to be conscious of what notes you are playing now.