Free Hosting Online for WorkStations

< Previous | Contents | Next >

8.2.4. Removing and Purging Packages‌


Removing a package is even simpler than installing one. Let’s take a look at how to remove a package with dpkg and apt.

To remove a package with dpkg, supply the -r or --remove option, followed by the name of a pack- age. This removal is not, however, complete: all of the configuration files, maintainer scripts, log files (system logs), data generated by the daemon (such as the content of an LDAP server directory or the content of a database for an SQL server), and most other user data handled by the package remain intact. The remove option makes it easy to uninstall a program and later re-install it with the same configuration. Also remember that dependencies are not removed. Consider this exam- ple:


# dpkg --remove kali-linux-gpu

(Reading database ... 317681 files and directories currently installed.) Removing kali-linux-gpu (2016.3.2) ...

# dpkg --remove kali-linux-gpu

(Reading database ... 317681 files and directories currently installed.) Removing kali-linux-gpu (2016.3.2) ...


You can also remove packages from the system with apt remove package. APT will automatically delete the packages that depend on the package that is being removed. Like the dpkg example, configuration files and user data will not be removed.

Through the addition of suffixes to package names, you can use apt (or apt-get and aptitude) to install certain packages and remove others on the same command line. With an apt inst all command, add “-” to the names of the packages you wish to remove. With an apt remove command, add “+” to the names of the packages you wish to install.

The next example shows two different ways to install package1 and to remove package2.


# apt install package1 package2-

[...]

# apt remove package1+ package2

[...]

# apt install package1 package2-

[...]

# apt remove package1+ package2

[...]


This can also be used to exclude packages that would otherwise be installed, for example due to a Recommends (discussed later). In general, the dependency solver will use that information as a hint to look for alternative solutions.

To remove all data associated with a package, you can purge the package with the dpkg -P package, or apt purge package commands. This will completely remove the package and all user data, and in the case of apt, will delete dependencies as well.


# dpkg -r debian-cd

(Reading database ... 97747 files and directories currently installed.) Removing debian-cd (3.1.17) ...

# dpkg -P debian-cd

(Reading database ... 97401 files and directories currently installed.) Removing debian-cd (3.1.17) ...

Purging configuration files for debian-cd (3.1.17) ...

# dpkg -r debian-cd

(Reading database ... 97747 files and directories currently installed.) Removing debian-cd (3.1.17) ...

# dpkg -P debian-cd

(Reading database ... 97401 files and directories currently installed.) Removing debian-cd (3.1.17) ...

Purging configuration files for debian-cd (3.1.17) ...


Warning! Given the definitive nature of purge, do not execute it lightly. You will lose everything associated with that package.


Top OS Cloud Computing at OnWorks: