Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
======================================================================
[ricardo@localhost ~]$ tar --gzip --create --verbose --file=/home/ricardo/tmp/xxx.tar.gz /home/ricardo/testesfpc/teste.pas /home/ricardo/testesfpc/h.pas --recursion
tar: Removing leading `/' from member names
/home/ricardo/testesfpc/teste.pas
/home/ricardo/testesfpc/h.pas
tar: --recursion: It is not possible stat: File or directory not found
tar: Saída por erro atrasada pelos erros anteriores
[ricardo@localhost ~]$
=====================================================================
Why I receive an error in the --recursion?
I guarantee that there are sub directories in the /home/ricardo/testesfpc.
I try to put --recursion before the --file parameter. The error disappear but no recursion takes place
All files and directories of testesfpc has read permission in the three diectory levels...
The GNU manual says that --recursion is the default but the recursion never occurs.
First of all tar does recurse through files and directories as the default. This command should work:
tar --gzip --create --verbose --file=/home/ricardo/tmp/xxx.tar.gz /home/ricardo/testesfpc/teste.pas /home/ricardo/testesfpc/h.pas
Remove the --recurse from after the files names. Tar is treating "--recurse" as a file name and cannot find it. Are the names you specified (/home/ricardo/testesfpc/teste.pas /home/ricardo/testesfpc/h.pas) directories or files?
If they are:
* the 2 files will placed into the archive.
* directories it will put all files and sub-directories into the archive
In the page 102, item 6.9 "Descending into Directories" is written:
"Usually, tar will recursively explore all directories".
May I suppose that --recursion is the default, or not?
Second of all:
You forgot to expose how would be the command line for include the two files listed and recurse all subdirectories of the /home/ricardo/testesfpc directory.
tar --gzip --create --verbose --file=/home/ricardo/tmp/xxx.tar.gz /home/ricardo/testesfpc
This will tar the whole /home/ricardo/testesfpc directory and all its sub-directories. Since the two files you specified are inside this directory they will also get backed up.
The manual for the tar command and all the other Linux commands should be on your computer already. At the command prompt you can type:
man tar
or
info tar
If you are running KDE you can get access to these commands by typing directly into the Location: area:
man:tar
or
info:tar
I don't run Gnome so I don't know whether this works in Gnome or not. Hope this helps.
I want to tar the file tar_help.txt from the /home/ricardo/doc and all directories that exist under /home/ricardo/doc. I repeat: one file and all the directories under /home/ricardo/doc.
Honestly, I use Bzip2 just because "j" is easier for me to hit than "z". >_>
What I would do(Maybe not the best, but oh well) is make a new directoy in your HOME, and copy all the stuff you want tarred into it. Then, tar that folder.
When it comes time to untar it,
tar -xvzf FILE.tar.gz -C /path/to/target/dir
Replace "z" with "j" if you tarred it with "j". "-C" says "I want all files and folders in the tar file to be unzipped to /path/to/target/dir"
In each of your tar commands you are only giving tar a file name(tar_help.txt) not a directory (/home/ricardo/doc). Tar copies every file or directory you specify on the command line. If you give tar a directory name it will tar that directory and everything inside it which in your case includes tar_help.txt:
tar --gzip --create --verbose --file /home/ricardo/tmp/xxx.tar.gz /home/ricardo/doc
This command will tar the directory /home/ricardo/doc and all the files in it which includes tar_help.txt.
Bzip2 is a different algorithm and is better for large tar files because it compresses things smaller than gzip can. If you ever check out the kernel sources at www.kernel.org, you'll see that the sources come as gz or bz2 tar files. It's the exact same tree but the bz2 files are like 10MB smaller.
That is going to put the whole directory structure starting at /home/user/docs into a tar file. That means that everything in docs, all the folders in docs, and all the files in those folders are all included. JohnDoe and others have already posted to this effect.
I guess you can just start out by going to /home/user and just tar czvf docs.tar.gz docs/ it does the same thing.
I think you may be looking too much into this one. If you aren't getting errors than it should be working fine. I'm getting confused.
One last try using the example directory listing you gave.
==================================================================
[ricardo@localhost doc]$ ls -al
total 52
drwxrwxr-x 4 ricardo ricardo 4096 Dez 20 10:36 .
drwx------ 34 ricardo ricardo 4096 Dez 20 10:33 ..
drwxrwxr-x 2 ricardo ricardo 4096 Ago 4 18:39 DocumentaçãoFreePascalLazarus
-rw-rw-r-- 1 ricardo ricardo 17793 Ago 30 09:28 fast_guide_to_linux.odt
drwxrwxr-x 2 ricardo ricardo 4096 Dez 18 15:14 Manual_do_Tarball
-rw-rw-r-- 1 ricardo ricardo 9238 Nov 30 15:42 tar_help.txt
[ricardo@localhost doc]$ tar --gzip --create --verbose --file /home/ricardo/tmp/xxx.tar.gz tar_help.txt
tar_help.txt
[ricardo@localhost doc]$ tar -ztf /home/ricardo/tmp/xxx.tar.gz
tar_help.txt
[ricardo@localhost doc]$
==================================================================
If you want to tar one file and a directory and all its contents here is what you would type:
cd /home/ricardo/doc
tar --gzip --create --verbose --file /home/ricardo/tmp/xxx.tar.gz /home/ricardo/doc/DocumentaçãoFreePascalLazarus tar_help.txt
(The tar command including the directory and file name is all on one line even though you may see is as two lines in this message)
This command will tar the directory /home/ricardo/doc/DocumentaçãoFreePascalLazarus and all the files in it and also tar the one file tar_help.txt. I you specified other files or directory names on the tar command line it will put all the specified files and directories into the tar file.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.