I am new to Ubuntu (terminal especially) and I am experimenting with the tar
command.
I have created a /test
folder containing one single /test.txt
file at /var/www/html/test/test.txt
.
I would like to tar only the /test
folder (and its contents) to /home/jo/backup
.
My process so far is as follows:
cd ~
tar cvf testBackup.tar /var/www/html/test/
This successfully creates a testBackup.tar
located at /home/jo/backup
.
However when I extract the tar using the following command:
tar cvf testBackup.tar /var/www/html/test/
The folder var
is visible, and I have to cd to the /test
directory (/var/www/html/test) in order to see the contents.
Basically I only want to tar the test
folder, not the three before (/var/www/html
)
Am I doing something wrong or is this how the command works?
cd /var/www/html/;tar cvf testBackup.tar ./test;mv testBackup.tar ~/backup/
test
. see also:man tar
I'll make an answer