LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 11-28-2018, 02:23 AM   #16
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762

Whilst we are here and I have deviated off topic, why not one more pet peeve related to tar.

I also think that 'tar xvf archive' (v = Verbose[list on extraction—in this context]) is almost always pointless. I don't need a list of files flying past my screen as I extract. If I know the archive and its contents, I can just extract. If I do not know what is inside, I should have run a 'tar tf archive' first, before I committed to extraction. Because if I was worried about over writing files … then too late. The 'x' (extract) just made that happen, while I watched it (and probably screamed at myself for not doing a 'tf' in the first place).

Last edited by ruario; 11-28-2018 at 02:34 AM. Reason: clarifications
 
Old 11-28-2018, 02:45 AM   #17
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762
Quote:
Originally Posted by MadeInGermany View Post
Delete the files that were extracted from a tarball? Loop over its contents!
Code:
 [ -f "$f" ] && echo rm -f "$f"
Actually, the problem with this, is that your "-f" only matches "regular" files, i.e. not symlinks. Thus any symlinks within a package would not be deleted by your suggestion. You could expand the test to [ -f "$f" -o -h "$f" ] and it will be better but of course there are other file types that could potentially be included in a tar archive. This is why I do "! -type d" in my find command. I am looking for any type of file that is not a directory. You would need the equivalent of that to be entirely correct.

Last edited by ruario; 11-28-2018 at 04:27 AM. Reason: s/times/types/
 
Old 11-28-2018, 04:05 AM   #18
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762
@MadeInGermany One other issue with your suggestion is that you only covered how to remove files and didn't talk about installation in the first place. This is important because there are two obvious ways to install. Extract the package over the / directory or extract the files somewhere else and move them into place. Only the latter is viable IMHO because installable tar packages like this tend to contain both package specific files (+directories) and shared (read: 'system') directories.

Distributions can have different defaults for permissions and ownership, so even if the author of such a package does their best to use sensible defaults, there might still be wrong for some distributions. Having an ownership or permissions issues with package specific files is a lesser issue, with the most likely problem being with the package does not run correctly. Having ownership or permissions issues with "system directories" (e.g. usr) could be catastrophic. You might not even be able to boot. Thus the user should always extract somewhere else and move files into place, creating only the needed new directories with distro defaults. This is something that is easy with cpio (or a tar pipe). To accurately select files to move, you are likely to use a find command and if you are doing that you might as well create the removal log at that point anyway. You also get the benefit of not having to keep around the old install package just for the sake of helping you remove.

P.S. Since I wrote my answer above, I realise there is an even better find command for creating a log. You could create a nice null separated log like this:

Code:
find etc opt usr ! -type d -printf '/%p\0' > ~/SpiderOakONE-7.3.0-install.log
This has the advantage that it also handles any really weirdly named files (i.e. not just spaces in their names but even stuff like names that include line breaks).

Then to uninstall you would simply issue:

Code:
sudo xargs -0 rm -v < ~/SpiderOakONE-7.3.0-install.log
I use this method for the instructions in the sample tar package I offered to the SpiderOak team.
 
Old 11-29-2018, 10:50 AM   #19
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,804

Rep: Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203Reputation: 1203
This thread is about uninstall/delete.

I wouldn't go as far as extracting to a different location, and use a subsequent relocation command. Every (further) prilileged command bares a (further) risk.
But I second your suggestion to first run a tar tvf and look at the files and their owners/permissions. Do not blindly trust anyone/anything that is not you/made by you!

Removing a directory is not easy. One should first ensure it is not provided by a package, before removing it with rmdir.
Perhaps one should do this even for plain files and other file types (before removing them with rm).
 
Old 11-29-2018, 12:47 PM   #20
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762
Quote:
Originally Posted by MadeInGermany View Post
I wouldn't go as far as extracting to a different location, and use a subsequent relocation command. Every (further) privileged command bares a (further) risk.
Who said anything about extracting privileged? Extract as a normal user, install with cpio (privileged) changing ownership of files to root (and default group for root) on the fly. Read my example.

Quote:
Originally Posted by ruario View Post
you can install the package via this method:
Code:
find etc opt usr ! -type d -print0 | sudo cpio --owner root: -p0mdv /
Quote:
Originally Posted by MadeInGermany View Post
Removing a directory is not easy. One should first ensure it is not provided by a package, before removing it with.
(and make sure it is empty).

But again, I covered all that in my first response.

Quote:
Originally Posted by ruario View Post
For the most part, empty directories cause no problems and generally have negligible space requirements. So you could just ignore them.

But… if you are the type of person who feels ‘uncomfortable’ with a non-pristine system, the obvious non-shared directories for SpiderOakONE 7.3.0 are “/opt/SpiderOakONE” and its sub-directories, plus “/usr/share/doc/SpiderOakONE”. You could get rid of them with this command:

Code:
sudo find /opt/SpiderOakONE /usr/share/doc/SpiderOakONE -depth -type d -empty -exec rmdir -v {} \;
 
Old 11-29-2018, 12:50 PM   #21
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762
Quote:
Originally Posted by MadeInGermany View Post
Perhaps one should do this even for plain files and other file types (before removing them with rm).
Better yet, do that before you install. This is why it is best to talk about install and uninstall together.

Quote:
Originally Posted by ruario View Post
After reviewing that log file [...] to make sure it lists nothing odd and does not have clashes with existing files on your system, you can install the package...
 
Old 11-29-2018, 02:20 PM   #22
ruario
Senior Member
 
Registered: Jan 2011
Location: Oslo, Norway
Distribution: Slackware
Posts: 2,557

Rep: Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762Reputation: 1762
For anyone wondering how I got to this:

Quote:
Originally Posted by ruario View Post
... the obvious non-shared directories for SpiderOakONE 7.3.0 are “/opt/SpiderOakONE” and its sub-directories, plus “/usr/share/doc/SpiderOakONE”. You could get rid of them with this command:

Code:
sudo find /opt/SpiderOakONE /usr/share/doc/SpiderOakONE -depth -type d -empty -exec rmdir -v {} \;
Issuing the following inside a directory of the extracted tar contents, will get you in the ballpark of what might be a non-standard directory.:

Code:
find . -type d | sed -n 's,^\./,/,p' | grep -vxE '/(etc|lib(32|64)?|opt|s?bin|usr((/local)?(/include|/info|/lib(32|64)?|/s?bin|/share(/doc|/info|/man(/man[1-9n])?)?|/src)?)?|var)'
The regex based of a very quick peruse of the FHS 3.0. Of course there are lots of shared directories not covered by FHS but rather other standards like Fdo/XDG (e.g. applications and icons directories in share or the xdg directory and subdirectories in etc). So I considered expanding the regex further but at some point I realised I was overthinking it. If you have a passing familiarity with packaging and 'normal directories' on a Linux distributions, it is quite easy to see that /opt/SpiderOakONE (and its subdirectories) and /usr/share/doc/SpiderOakONE are the odd ones out.

And this actually gives a nice rule of thumb, "the unique directories are generally named after the package" (at least at their highest level) and are thus are actually very easy to spot, even without any fancy regex. In fact, they are easy to find even after install IMHO. Just run a find command on common install locations with "-type d" and "-empty" and look out for the obvious.

Once you have found the "highest level" package specific directories, just approach deleting them after removing the files and based on greatest depth first. Then they are simple to clear down. In addition, you can't go too far wrong with "rmdir" commands. They are pretty safe because they will not remove a directory that contains something. Also even if you do delete something that should have remained as a shared directory (because it happened to be empty right now), the next install of a software that needs it will generally just re-create it without issue.

But again... you could just ignore the directories altogether because empty directories generally cause no problems and have negligible space requirements. So I would personally always focus on the files, first and foremost. These can be scattered all over the place, don't always have obvious names and are (usually) unique. They are also the ones taking up all the space. Handle them and you are generally good.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you uninstall software which doesn't have an uninstall-file? lagu2653 Linux - Software 2 12-08-2005 12:36 PM
uninstall from src if no make uninstall dtra Linux - Software 3 04-29-2005 09:13 AM
how to uninstall source tarball packages ? xround Linux - Software 2 10-20-2004 09:18 AM
Source uninstall with 'make uninstall' HOWTO! Creeps Linux - Newbie 6 09-14-2004 11:03 AM
How to uninstall programs from compiled from tarball? timberwolf Linux - Software 4 12-10-2003 03:05 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration