I'm trying to tar my website files that are on my test server to be able to upload them to 'real' server.

tar -cf mysite.tar /var/www

It creates archive fine... but when I open that archive it has var directory, which contains www directory... How do I create archive that has /var/www content in its root, not in subfolders like it's right now?


I think you are wanting all the files and folders that are in the www folder. If I am misunderstanding you im sorry. If that is what you want you could cd into the www directory and run

tar -cvf backup.tar *

You can use the -C (capital c) option to make tar change to a directory before it begins it's work. This will effectively remove the directory parents from the archive.

Your other option is to simply run the command from inside the /var/www directory itself and avoid this altogether.