Ubuntu uninstall installed package

This article lists three ways to uninstall packages already installed in ubuntu.

apt-get command
If the installed package is installed by apt-get install package-name, you can use the following two commands to uninstall:

apt-get remove package-name : Remove package.
apt-get purge package-name : Uninstall packages and configuration files (complete uninstall).
As for whether the package to be uninstalled was installed through the apt-get install command, you can use the apt-get list --installed command to view all the packages that have been installed through apt-get.

More apt-get commands can be viewed through the apt-get --help command.

make uninstall command
Many packages on Ubuntu are installed through source code, such as downloading a release of Repository from github. The source code installation method is generally:

cd source-code-root-dir
./config
make 
make install

If you manually install the package through the source code and  apt-get remove/purge package-name uninstall it using the method, the system will prompt that the package-name is not installed, and there is no need to uninstall it. (In fact, apt-get does not know that this package is installed).

If we want to uninstall, we should do this:

# 进入源码根目录
cd source-code-root-dir
# 重新执行一遍 config 文件
./config
# 执行卸载命令
make uninstall

Rude way: directly delete the file
The second way also has a condition: the package must be in the root directory of the source code before it can be uninstalled. But in many cases, the developer completes the installation in the first step, and the test is no problem, and then deletes the source code in the second step. This is embarrassing when uninstalling. If you can find out where the source code is, download it again, and then follow the second method, you can still uninstall it.

Where is the source code if I can't find it?

There is also a way~~~

You can use the locate package-name command:
 

root@master-aliyun:~# locate lxcfs
/usr/local/bin/lxcfs
/usr/local/etc/init/lxcfs.conf
/usr/local/etc/rc.d/init.d/lxcfs
/usr/local/lib/lxcfs
/usr/local/lib/lxcfs/liblxcfs.la
/usr/local/lib/lxcfs/liblxcfs.so
/usr/local/share/lxcfs
/usr/local/share/lxc/config/common.conf.d/00-lxcfs.conf
/usr/local/share/lxcfs/lxc.mount.hook
/usr/local/share/lxcfs/lxc.reboot.hook
/var/lib/lxcfs

Find out what are the files related to the package, and delete these files to uninstall. However, this method is suitable for smaller packages. If there are too many files found, it will be very troublesome to delete.

Is there an easier way?

There are also! ! !

After the package is installed, an executable file will be generated and stored in a certain path (usually under the path of ..../bin). Use the which command to find the executable file and delete it.
 

root@worker2-aliyun:~# which lxcfs
/usr/local/bin/lxcfs
root@worker2-aliyun:~# rm -rf /usr/local/bin/lxcfs

It is a rude way to delete. This uninstallation method will leave some configuration files, but it will not affect the use of other functions. It is equivalent to saving some useless files in the computer. Don't mind taking up storage. One is that the storage of computers is very large now, and the other is that there are not too many useless files on the computer. Of course, it would be great if developers could find and delete these useless files.

I have tested it myself, directly delete the executable file to uninstall the software, and then change the version to reinstall, it can work~~~.

Crazy little test
There are several methods introduced above, here is an open source project, you can use it to practice~~~

Practice: lxcfs

Install lxcfs from source code

Guess you like

Origin blog.csdn.net/weixin_48345177/article/details/131900902