How can make things go up and down?

Your description lacks specifics. How large is your cylinder and how fast is it expected to move, over what distance range?

You could use some simple motor and pulley and string to move things. You could use a motor and an arm so if you rotate the motor, the arm's one end goes up and down so reciprocating if you keep the motor spinning.