I've searched the net for such information and found different command lines, like these ones:
sudo apt-get remove application
sudo apt-get remove application*
sudo apt-get remove --purge application
sudo apt-get remove --purge application*
sudo apt-get purge application
sudo apt-get purge application*
So, what is the correct way? Is it necessary to use that "*"?
After that, I also found these commands:
sudo updatedb
sudo locate application
sudo rm -rf (file/folder name)
apt-get remove packagename
will remove the binaries, but not the configuration or data files of the package
packagename
. It will also leave dependencies installed with it on installation time untouched.apt-get purge packagename
orapt-get remove --purge packagename
will remove about everything regarding the package
packagename
, but not the dependencies installed with it on installation. Both commands are equivalent.Particularly useful when you want to 'start all over' with an application because you messed up the configuration. However, it does not remove configuration or data files residing in users home directories, usually in hidden folders there. There is no easy way to get those removed as well.
apt-get autoremove
removes orphaned packages, i.e. installed packages that used to be installed as an dependency, but aren't any longer. Use this after removing a package which had installed dependencies you're no longer interested in.
aptitude remove packagename
oraptitude purge packagename
(likewise)will also attempt to remove other packages which were required by
packagename
on but are not required by any remaining packages. Note thataptitude
only remembers dependency information for packages that it has installed.And many more exist. Lower-level
dpkg
-commands can be used (advanced), or GUI tools like Muon, Synaptic, Software Center, etc. There's no single 'correct way' of removing applications or performing other tasks interacting with your package management.The list you found are just examples. Make sure you understand the meanings and try out what it wants to do before accepting the action (you need to press
Y
before it actually performs the actions as proposed).The asterisk version in the question is probably wrong;
apt-get
accepts a regular expression and not a glob pattern as the shell. So what happens withis the following:
The shell tries to expand
application*
looking at the files in the current directory. If (as is normally the case) it finds nothing, it returns the glob pattern unaltered (supposingbash
with default behavior here ---zsh
will error out).apt-get
will remove the packages whose name contains a string that satisfies the regular expressionapplication*
, that is,applicatio
followed by an arbitrary number ofn
:applicatio
,application
,applicationn
,libapplicatio
, etc.To see how this can be dangerous, try (without root for double safety)
apt-get -s remove "wine*"
(-s
will simulate the thing instead of doing it) --- it will say is going to remove all packages that has "win" in their name and the dependant, almost the entire system...Probably, the command that was meant is really
(note the quotes and the dot) which will remove all packages whose name starts with
application
.These commands,
are completely outside the scope of the package management. Do not remove files belonging to packages without using the package manager! It will get confused and is the wrong way to do things.
If you don't know to which package a file belongs, try this:
For Ubuntu 12.04 and maybe higher, the correct method is:
As detailed here.
Do not use
packagename*
as that can delete unintended packages and cause more problems than it solves. Or if you must, at least run it with a-s
,--simulate
,--dry-run
flag first to see exactly what it will do without doing it.You can use this command:
It will purge required packages along with dependencies that are installed with those packages. The
--auto-remove
option (being an alias ofautoremove
) works similar tosudo apt-get autoremove
. By using this command we can run a single command:Instead of:
You can safely use
sudo apt-get remove --purge application
orsudo apt-get remove applications
99% of the time. When you use thepurge
flag, it simply removes all config files too. Which may or may not be what you want, depending on if you want to reinstall said application. Theapplication*
will match all applications that start withapplication
, which are usually plugins, additional features, etc of the main application you are removing. i.e.would remove
gedit
,gedit-plugins
andgedit-common
. Typically it is not necessary to do this, because most plugins/associated programs are dependent on the main application, and will automatically be removed (or marked for removal) when you uninstall the main application.Your last command is just to remove leftovers from applications that are known to have messy uninstallers, and it is just removing any remnants of the application.
I found this command in internet.
http://www.debian-administration.org/article/Reinstalling_packages_to_fix_problems.
I got some error messages removing a package, the only way I found that worked was this:
I found that although using only
does not remove the package it shows me the correct path to the file to move with:
Substitute package with your application name. Use sudo in Ubuntu, become root in Debian.
I just wanted to clarify one thing that seems to be a source of confusion on here. The
dpkg
utility does not know about or track packages dependencies in relation to one another, which was a big reason thatapt
was developed I believe. You can read about it in section 8.6 on this page The Debian GNU/Linux FAQ - The Debian package management toolsWith apt: If I wanted to purge package A, and it has a dependency called package B, and package B had no other dependent packages, then package A and B will be purged. If package B DID have other dependent packages, then only package A will be purged.
With dpkg: What dependency? You just told me to purge the damn
package so that's what I did! Poor planning on your part does not
constitute an emergency on my part.
With that said, here are two one-liners which can be used for each purge methods:
Remove the
--dry-run
to perform the actual purge operation instead of reporting what actions it would have taken.It depends on the application you want to remove. Always be sure to check its dependencies before issuing the yes command. When you remove something by command line, it will sometimes show a handful of libraries that are no longer needed. These can be removed with apt-get autoremove.
Beware that by using commands such as sudo apt-get remove --purge applicationname may remove some dependencies that are needed by other applications and, as such, might break your system.
If you want to do it in the safer way, you can always remove it using just the software center or apt-get remove applicationname. If the dependencies aren't needed anymore, issue apt-get autoremove later.
To remove everything regarding the package package name like data and configuration, but not the dependencies installed with it on installation use: