They seem similar to me. I want to know how to use them. What's the difference in structure?
Being brief (a small book could be written on the topic), maybe it is useful to think like this:
cpis for duplicating stuff and by default only ensures files have unique full path names
rsyncis for synchronising stuff and uses the size and timestamp of files to decide if they should be replaced. It has many more options and capabilities than
Using their various options, you can use either of them for many tasks, for example
cp -u can replace only files that are newer, as
rsync is used to do.
But there are some tasks where one has advantages over the other
You might as well use
cp when you want to make a local duplicate file or directory. For example, you want to edit an important file, so you make a backup first:
cp .bashrc bashrc-bak
rsync do this would require three more keystrokes, so why bother? If you want to duplicate a directory
cp -r ~/Desktop/cakes ~/Recipes/cakes
serves you well. Why bother typing
rsync -a? Well you might, since its
-v verbose option gives more interesting and useful output.
However, let's say you're updating a backup of some directory on your system on a flash drive. The directory already exists on the flash drive, and you just want to sync the files so it has the latest version of your stuff.
rsync is much faster than
cp for this, because it will check file sizes and timestamps to see which ones need to be updated, and you can add more refinements. You can even make it do a checksum instead of the default 'quick check', although this will take longer.
You can also use
rsync to copy or sync files to a remote machine, or make is run as a daemon. Humble
cp can't do such fancy things.
To learn the options and syntax ("structure"?) (which is very similar) read
info pages and practise!
cp is simple tool that was here since ever and it is used for simply copy from one place to another on your local filesystem. It does just blind copy and might ask for overwriting the files.
On the other side,
rsync is complex tool to syncing two directories/files, not necessarily on the same filesystem (you can
ftp, ...) and it has a lot of features to save your bandwidth or time (does not have to copy everything, if the files are the same).