tar interview questions
Top tar frequently asked interview questions
I normally compress using tar zcvf
and decompress using tar zxvf
(using gzip due to habit).
I've recently gotten a quad core CPU with hyperthreading, so I have 8 logical cores, and I notice that many of the cores are unused during compression/decompression.
Is there any way I can utilize the unused cores to make it faster?
Source: (StackOverflow)
I have a directory that I want to compress to send it by e-mail, I've tried this:
tar -cvf filename.tar.gz directory_to_compress/
But when I try send it by e-mail, Google says:
filename.tar.gz contains an executable file. For security reasons, Gmail does not allow you to send this type of file.
How to compress a directory into a tar.gz file from command line?
Source: (StackOverflow)
I've found tons of pages saying how to untar tar.bz2 files, but how would one untar a tar.bz file?
Source: (StackOverflow)
I want to extract an archive named filename.tar.gz
.
Using tar -xzvf filename.tar.gz
doesn't extract the file. it is gives this error:
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error exit delayed from previous errors
Source: (StackOverflow)
On my Linux machine, I wish to create a .tar.bz2 file of a certain folder. Once I place myself in that folder (in the terminal), what do I type in the terminal command line to place the compressed folder in the home directory of my machine?
Let's say I am in the folder /home/user/folder. In the folder "folder" are several files (txt, .c etc). How do I compress that folder of type .tar.bz2 and place it in my /home directory?
In the /home/user/folder, I've tried sudo tar -cvjSf folder.tar.bz2
but get an error:
tar: Cowardly refusing to create an empty archive
Source: (StackOverflow)
I typically do:
tar -czvf my_directory.tar.gz my_directory
What if I just want to include everything (including any hidden system files) in my_directory, but not the directory itself? I don't want:
my_directory
--- my_file
--- my_file
--- my_file
I want:
my_file
my_file
my_file
Source: (StackOverflow)
I have a tar.gz-file with the following structure:
folder1/img.gif
folder2/img2.gif
folder3/img3.gif
I want to extract the image files without the folder hierarchy so the extracted result looks like:
/img.gif
/img2.gif
/img3.gif
I need to do this with a combination of Unix and PHP. Here is what I have so far, it works to extract them to the specified directory but keeps the folder hierarchy:
exec('gtar --keep-newer-files -xzf images.tgz -C /home/user/public_html/images/',$ret);
Source: (StackOverflow)
I try to tar.gz a directory and use
tar -czf workspace.tar.gz *
The resulting tar includes .svn
directories in subdirs but NOT in the current directory (as *
gets expanded to only 'visible' files before it is passed to tar
I tried to
tar -czf workspace.tar.gz .
instead but then I am getting an error because '.' has changed while reading:
tar: ./workspace.tar.gz: file changed as we read it
Is there a trick so that *
matches all files (including dot-prefixed) in a directory?
(using bash on Linux SLES-11 (2.6.27.19)
Source: (StackOverflow)
I am running a PHP script that gets me the absolute paths of files I want to tar up. This is the syntax I have:
tar -cf tarname.tar -C /www/path/path/file1.txt /www/path/path2/path3/file2.xls
when I untar it create the absolute path to the files. How do I get just /path
with everything under it to show?
Source: (StackOverflow)
I'm working on a backup script and want to tar up a file directory:
tar czf ~/backup.tgz /home/username/drupal/sites/default/files
This tars it up, but when I untar the resulting file, it includes the full file structure: the files are in home/username/drupal/sites/default/files
.
Is there a way to exclude the parent directories, so that the resulting tar just knows about the last directory (files
)?
Source: (StackOverflow)
I have a bunch of tar
files in a directory and I want to extract all the files from them at once. But this doesn't seem to do anything:
$ tar xf *.tar
What's going on here? How do I untar a bunch of files at once?
Source: (StackOverflow)