Toggling GPIO pins

I have been looking everywhere and haven't found any code that'll just let me turn a GPIO pin on or off! I have the raspberry pi 2b, and I have a small fan plugged into GPIO pins 4 and 6. 4 is a power pin and 6 is a ground pin. I want to be able to turn my fan on and off in the command line, how would I do that?