First, you need a working raspberry pi and a webcam. Just about any webcam will do, and there are tons of tutorials on getting a pi up and running.
sudo apt-get install motion
Enable the motion dameon in this file
sudo nano /etc/default/motion
Backup the original conf file
sudo cp /etc/motion/motion.conf /etc/motion/motion.conf.originalbackup
Edit the conf file to your liking this may take quite some time, as there are a TON of options.
sudo nano /etc/motion/motion.conf
Plan on spending quite some time figuring out this really long conf file if you want to customize the thing. The software is good for the running right out of the box, so if you want you can fiddle with the options later. Turn it on!!
sudo /etc/init.d/motion restart
There we have it! It’s recording now. It won’t record much with a 4Gb card. I would recommend anything 16Gb or higher. This is because the disk can fill up. To see how much disk space is available. You might need to expand the filesystem in raspi-config, if you don’t see the right stuff.
If you want to see the captures go to the directory that they are being saved
Connecting via ftp is another task altogether, but if you want to clean out the images in this folder simply delete them.
sudo rm -r /tmp/motion/*