Uncompress tar.gz file [closed] - linux

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
With the usage of wget command line I got a tar.gz file. I downloaded it in the root#raspberrypi. Is there any way to uncompress it in the /usr/src folder?

Use -C option of tar:
tar zxvf <yourfile>.tar.gz -C /usr/src/
and then, the content of the tar should be in:
/usr/src/<yourfile>

Try this:
tar -zxvf file.tar.gz

gunzip <filename>
then
tar -xvf <tar-file-name>

Related

When I compress a tar gz file using paths, folders get included [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
When I compress a tar gz file using paths, folders get included. However, I want to just compress the file only. This is what I tried:
$ tar -czf ../coolfile.tar.gz newfol/coolfile
When I uncompress this tar.gz, I get the coolfile file in newfol folder. I would like compress coolfile only.
Uncompress tar gz command:
$ tar -xvf coolfile.tar.gz`
tar -C newfol -cvzf coolfile.tar.gz coolfile
Note: you specify the tar.gz file relative to the current directory, and you specify the file(s) to be tarred relative to the directory that is argument to the -C option, and that tar will cd into to perform the tar.

How to make a tar backup of a root filesystem? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I have linux installed on SD card, I used this command to install the rootfs
tar xpjf rootfs.tar.bz -C /mnt/rootfs/
Now, I made some changes to the rootfs and I would like to create a backup that I can use with the same command above, I tried using:
tar cpjf rootfs.tar.bz2 /mnt/rootfs
and
tar cpjf rootfs.tar.bz2 -C / mnt/rootfs
I also tried
tar cpjf rootfs.tar.bz2 /mnt/rootfs/*
And tried:
cd /mnt/rootfs
tar -cvpjf rootfs.tar.bz2 --exclude=/rootfs.tar.bz2 .
tar: ./rootfs.tar.bz2: file changed as we read it
but I end up with an archive that has two levels before the file system i.e mnt/rootfs/files What am I doing wrong ?
That's because it starts from current working directory, you can do:
cd /mnt/rootfs
tar cpjf /rootfs.tar.bz2 .
And that should create an archive at /rootfs.tar.bz2 with its root at the contents of /mnt/rootfs/

How to strip path while archiving with TAR [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I have a file that contain list of files I want to archive with tar.
Let's call it mylist.txt
It contains:
/path1/path2/file1.txt
/path1/path2/file3.txt
...
/path1/path2/file10.txt
What I want to do is to archive this file into a tarball but excluding /path1/path2/.
Currently by doing this:
tar -cvf allfiles.tar -T mylist.txt
preserves the path after unarchiving.
I tried this but won't work too:
tar -cvf -C /path1/path2 allfiles.tar -T mylist.txt
It archives all the files in /path1/path2 even those which are not in mylist.txt
Is there a way to do it?
In your "Extraction phase" you can use the strip-components flag like
tar xvf tarname.tar --strip-components=n
which will remove the first n leading components of the file name. Although if you have different file-path-components this will not work for all cases.
If you want to do it while archiving, only one thing comes to mind, and I will share
INPUT: list of files + full paths
1) for each line, split the path out of the filename
2) execute cd to that path and tar on that filename
3) repeat for each line

Using tar option to extract the contents of a rar file [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I have uploaded a rar file under linux server .
When i used unrar -e filename.rar or rar -e filename.rar , i got this error Command not found rar.
As i am not a root user , i dont have permissions to install unrar Into linux machiene .
So please tell me is it possible to use tar option to extract the contents of a rar file ??
When i used unrar under Linux machiene i got this
-bash-3.00$ unrar
-bash: unrar: command not found
-bash-3.00$
Thank you
You must install the unrar or unrar-free packets from a repository.

tar --files-from complains "Cannot stat: No such file or directory" [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 12 years ago.
Improve this question
When I type " tar -cvf ~/changeset.tar --files-from ~/changeset.txt", It responds with this output: http://pastie.org/1071080. Here is the contents of ~/changeset.txt: http://pastie.org/1071084 . In other words, a bunch of relative paths. As a sanity check,
$ ls admin/memberinformation.php admin/memberinformation.php
Why can't tar find any of these files even though they are clearly reachable from the current directory with the relative paths given?
FYI: $ tar --version tar (GNU tar) 1.15.1
The clue is the position of the colon in the tar output.
You've got a bad case of the trailing spaces. Get rid of them in your changeset file.

Resources