uninstalling all files which have been installed using tar xjf
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.
uninstalling all files which have been installed using tar xjf
hi
i have downloaded a binary tar file and installed it by giving command shown below(which is told in the manual)
[root@localhost /]# tar xjf sourceryvsipl++-1.3-linux-x86.tar.bz2
tar xjf does not "install' anything. It simply de-compresses and unpacks the archive. After running it, there should be a folder with the same or similar name. simply delete that folder and its contents.
You can list the contents of the tarball with "tar --list -jf sourceryvsipl++-1.3-linux-x86.tar.bz2"
Consider piping the output to "less" and examining the contents. Make sure that none of the files look like something that you need to keep. Look at how the directories are listed. If they don't begin with a slash, then you need to cd to '/' before removing the files.
You can pipe the output of the listing to xargs to delete the files in the list. However, if any of the filenames contain spaces or other special characters, it would be better to use the NULL character as the line separator in xargs.
It would probably have been better if you used /usr/local/ as the base of the installation as per the installation instructions. That is the proper place to install non-distro packages, and you are also guaranteed that the distro won't touch these files.
Sometimes if there is a large number of files in various locations, using /opt/ is a good choice. For example, You might use /opt/kde4/ if you were to install kde4 from source.
tar xjf does not "install' anything. It simply de-compresses and unpacks the archive. After running it, there should be a folder with the same or similar name. simply delete that folder and its contents.
I searched on the web and looked in the quick start guide.
Code:
`-- usr
`-- local
|-- include
| `-- vsip // Sourcery VSIPL++ Headers
| `-- vsip_csl // CodeSourcery extensions.
|-- lib
| |-- [arch] // Arch specific library files
| | `-- [variant] // Variant specific library files
| | `-- pkgconfig // Variant specific pkg-config
| `-- pkgconfig // Pkg-config links for all variants.
`-- share // Documentation and user files
|-- doc
| `-- sourceryvsipl++
| |-- quickstart // Quickstart (this document)
| |-- reference // Interactive API documentation
| `-- tutorial // Tutorial and Reference manual.
`-- sourceryvsipl++
There are libraries that would be extracted into /usr/local/lib/. The others in /usr/local/include/{vsip,vsip_csl} and /usr/local/share/sourcerysipl++ could be deleted easily, if the file locations in the quickguide are correct.
i was first shocked to find the directory structure of vsipl++ in this post.thanks for the risk taken.
and as for the command is considered its simply marvellous, this is what exactly i was looking.
what i understood from the command( tar --list -jf sourceryvsipl++-1.3-linux-x86.tar.bz2 | tr '\n' '\000' | xargs -0 rm -v) is the directory strucure is sent to rm for deletion.
this command worked well but the only prob was it was not removing the directories.
hence i added rm -Rfv which resulted in disaster.
ie, tar --list -jf sourceryvsipl++-1.3-linux-x86.tar.bz2 | tr '\n' '\000' | xargs -0 rm -Rfv
i normally use -Rf option to remove directories.
now since i used these options without thinking my share folder started to delete.
is there any way to recover the deleted files.
the good news is it has just started to delete and possibly within 10 seconds i had stopped it.
If you have an rpm distro, and you know the name of the file, you can find out which package supplies the file this way:
rpm -qf <path/to/file/filename>
You can also validate all of your files with:
rpm -qaV
It will indicate which files are missing.
Of course if you have a current backup, you could restore from that.
I would get the list of directories like this:
tar --list -jf sourceryvsipl++-1.3-linux-x86.tar.bz2 | sed -e 's|/[^/]*$||' | sort | uniq
or to delete them if empty:
tar --list -jf sourceryvsipl++-1.3-linux-x86.tar.bz2 | sed -e 's|/[^/]*$||' | sort | uniq | tr '\n' '\000' | xargs -0 rmdir
If it would be OK to delete all of the empty directories found:
find /usr/share/ -type d -exec rmdir '{}' +;
This command will only remove the bottom layer of (empty) directories each time, so you may need to run it more than once.
I'll do something like this one step at a time, first getting the files listed. Then I'll write a filter to remove the filename parts, then the sort and uniq parts will remove the repeats.
I always use the "rmdir" command instead of "rm -R". That way if a directory isn't empty as I thought, it won't be deleted.
Something else you can use is the find command to locate empty directories:
find /usr/local -type d -empty
If you want to cross match these directories with the contents, I find the <(command ...) form as a handy stand-in for a filename:
comm -12 <(tar --list -jf sourceryvsipl++-1.3-linux-x86.tar.bz2 | sed -e 's|/[^/]*$||' | sort | uniq) <(find /usr/local -type d -empty | sort)
I could have used
grep -f <(find /usr/local -type d -empty | sort) <(tar --list -jf sourceryvsipl++-1.3-linux-x86.tar.bz2 | sed -e 's|/[^/]*$||' | sort | uniq)
instead.
But for directories, there where not so many so simply using the list from the tarball listing would have provided the info to remove the directories manually.
[babu@localhost ~]$ cat /proc/version
Linux version 2.6.9-22.ELsmp (bhcompile@porky.build.redhat.com) (gcc version 3.4.4 20050721 (Red Hat 3.4.4-2)) #1 SMP Mon Sep 19 18:32:14 EDT 2005
u r post has been very useful . thank u for the post detailed explanation of the post .
i have found that my system uses ext3 file system and in one site i have seen that ext3 files can not be recovered .is it true . because most of the recovery s/w (which is commercial) says that they support ext3 file system also .
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.