When you say your new at cad, how new?
Also What version of Autocad are you using, just helps us out when
you are asking questions.
its pretty simple. set your snaps for endpoint,mid point and perpendicular, then use the move tool,hit f3 to enable your snap tool,select the rectangle,on the mid point or endpoint, move the rectangle to the line.
one of the biggest tips to know about Autocad, Keep an eye out whats going on at the Command Line. it will tell you what stage the program its at.