pick a square brush, then under "brush tip shape" set the spacing to 200%. Then just draw a line. If you want the squares to follow the line instead of all being a 0 degrees, you need to click "shape dynamics" on and under "angel jitter", set control to "direction" and jitter to 0%.