LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   uninstalling all files which have been installed using tar xjf (https://www.linuxquestions.org/questions/linux-newbie-8/uninstalling-all-files-which-have-been-installed-using-tar-xjf-619075/)

babu198649 02-06-2008 06:53 AM

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



now how to uninstall this package

pixellany 02-06-2008 07:14 AM

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.

jschiwal 02-06-2008 07:17 AM

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.

Code:

tar --list -jf  sourceryvsipl++-1.3-linux-x86.tar.bz2 | tr '\n' '\000' | xargs -0 rm -v
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.

jschiwal 02-06-2008 07:22 AM

Quote:

Originally Posted by pixellany (Post 3047881)
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.

pixellany 02-06-2008 07:47 AM

Are you saying that tar -x unpacks an archive and puts files into the various directories? I've never seen this. What is the mechanism?

babu198649 02-06-2008 07:49 AM

thank u jschiwal

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.

babu198649 02-06-2008 08:06 AM

hi

tar --list -jf sourceryvsipl++-1.3-linux-x86.tar.bz2 | tr '\n' '\000' | xargs -0 rm -v

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.

is there any way to recover it.

snap shot of removed files.
removed `usr//share/locale/ru/LC_MESSAGES/knotes.mo'
removed `usr//share/locale/ru/LC_MESSAGES/kabcformat_binary.mo'
removed `usr//share/locale/ru/LC_MESSAGES/kdeprint_part.mo'
removed `usr//share/locale/ru/LC_MESSAGES/kcmmidi.mo'
removed `usr//share/locale/ru/LC_MESSAGES/kdbg.mo'
removed `usr//share/locale/ru/LC_MESSAGES/ffrs.mo'
removed `usr//share/locale/ru/LC_MESSAGES/kwin_b2_config.mo'
removed `usr//share/locale/ru/LC_MESSAGES/kcmlayout.mo'
removed `usr//share/locale/ru/LC_MESSAGES/alarmdaemonctrl.mo'
removed `usr//share/locale/ru/LC_MESSAGES/kcmcrypto.mo'
removed `usr//share/locale/ru/LC_MESSAGES/qeditor.mo'
removed `usr//share/locale/ru/LC_MESSAGES/kcmemail.mo'
removed `usr//share/locale/ru/LC_MESSAGES/system-config-keyboard.mo'
removed `usr//share/locale/ru/LC_MESSAGES/kfile_gif.mo'
removed `usr//share/locale/ru/LC_MESSAGES/kcmxinerama.mo'
removed `usr//share/locale/ru/LC_MESSAGES/kodo.mo'
removed `usr//share/locale/ru/LC_MESSAGES/system-config-nfs.mo'
removed `usr//share/locale/ru/LC_MESSAGES/synaescope.m

jschiwal 02-08-2008 05:32 AM

Which distro are you running?

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.

babu198649 02-08-2008 08:31 AM

hi jschiwal



my distro is Red Hat 3.4.4-2

[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 .


All times are GMT -5. The time now is 05:42 PM.