i am created tar bal file for Documents directory. comressed file is stored in Picture directory
$ tar czf /home/buvanesh/Pictures/tar.tgz /home/buvanesh/Documents
when i open the tar bal file. it contains home,buvanesh & Documents directory. but i want Documents directory only. any one have idea about that?
You have typed incorrect command
Do you know that Linux bash is very case sensitive any incorrect commands does not work in terminal
correct command is
# tar cvzf /home/buvanesh/Pictures/tar.tgz /home/buvanesh/Documents
please try with this command -
tar -czf /home/buvanesh/Pictures/tar.tgz /home/buvanesh/Documents
it’ll works …
@gopalr007, @Ritesh Works fine. But still again home, buvanesh directories are created in the tar ball file. Any solution?
Hi
Use --exclude along withe the command
try this
#tar -cvzf /home/buvanesh/Pictures/tar.tgz /home/buvanesh/Documents --exclude=’/home/buvanesh/’
otherwise just move to the folder /home/buvnesh and create the tar file
#cd /home/buvanesh
#tar -cvzf /buvanesh/Pictures/tar.tgz Documents
@raghuu Still i have same problem after trying #tar -cvzf /home/buvanesh/Pictures/tar.tgz /home/buvanesh/Documents --exclude='/home/buvanesh/'
please change the Directory and go exact path - 1
then run the command then it’ll add only those folder .
Dear Buvanesh
Do one thing extract content what do you want for ex once look at the below screen shot which shows the tar file content
by using the --strip-components you can skip the path /mnt/raghu/stuff and extract only the files (1 2 3 4).
here you don’t get the entire path like /mnt/raghu…
Hm in this case i suggest you to use -C
#tar -cvzf /home/buvanesh/pictures/tar.gz -C /home/buvanesh Documents
Here–
-C will change the directory and create the tar file of Documents
once look at the below screen shot
in this way you can avoid the path what do you want
In terms of availability, 7zip is widely available across UNIX (Linux/BSD/MacOS) and Windows systems. Therefore a zip file is highly portable. xz and [7zip] are known to have a better compression algorithm than gzip, but use more memory and time to compress/decompress. when backing up I would recommend tar.7z as it has the highest compression rate saving you space but uses an extra program (7zip). .tar.gz will be larger files and do the same job, you could also use bzip (.tar.bz/bz2) although i’m not sure if that would suit you better as I use gzip or 7zip