The best way to learn barre chords on guitar is to start by forming your major chord shapes, the open position chords you already learned as a beginner. For example, if we form a C. major chord that you merely to place your fourth finger down upon the fourth string third fret in order to produce a C dominant seven chord which can then become a movable shapes across the fretboard. While this is not strictly classify the as a true barre chord provides an invaluable little steppingstone which will help you get used to the idea of moving chord shapes up and down the guitar neck.
From there the next step would be to form an E major chord however you need to form its using fingers 2, 3 and 4 instead of what is normally used (fingers 1, 2 and 3). This means you will be holding an E major chord which will sound perfectly correct however your first finger is now left free. The next step is to move that entire E chord shape further up the fretboard, say to the 5th fret, and then put your first finger across all six strings along the third fret. You can find a free barre chords chart online to help you find all the shapes available.
You will find that your first attempts may sound pretty awful especially if you have not yet developed enough strength in your left hand in order to push all six strings down at the same time while also having the necessary dexterity in your fingers in order to stretch the distance is required to form the typical kinds of Maj barre chords.
As always however there are plenty of free guitar chords online to learn from and the answer is to simply keep trying even though at first it may seem like an impossible task. With regular practice these chords will become much easier to do.
Try not to become too emotionally involved in your practice time. The trick is to simply do your daily practice and regardless of whether you notice an improvement or not to simply forget about until the next day. It’s only when you start to invest your emotional self into your practicing to become open to disappointment which in turn will lead to a significant drop in motivation and if at that point that you are in danger of giving up.
Many people give up on guitar with the false belief that they have the talent for playing it simply because they could not make the progress expected as quickly as they wanted it. Even the most talented of guitar players must work extremely hard in order to become good on guitar. It’s something which everyone has to earn, it cannot be simply bought that matter how rich you are.