Enhancing Skills

apt-get remove: Remove a specific package

Command: apt-get remove

Used to remove a specific package from your system. This command removes the package but leaves configuration files, so the package can be reinstalled later without losing its settings.


Sample Command and Output:

$ sudo apt-get remove vim
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  vim vim-common vim-runtime xxd
0 upgraded, 0 newly installed, 4 to remove and 0 not upgraded.
Need to get 0 B of archives.
After this operation, 11.0 MB of disk space will be freed.
Do you want to continue? [Y/n]

Description:

  • sudo apt-get remove <package_name>: Removes the specified package (vim in this example). The command also lists additional packages that will be removed due to dependencies. Configuration files for the removed package are not deleted.

Additional Commands and Sample Outputs:

  • apt-get remove --dry-run <package_name>: Simulate the removal of a package without making any changes. Sample Command and Output:
  $ sudo apt-get remove --dry-run vim
  Reading package lists... Done
  Building dependency tree       
  Reading state information... Done
  The following packages would be REMOVED:
    vim vim-common vim-runtime xxd

Description:

  • apt-get remove --dry-run <package_name>: Shows what would be removed if the command were executed, without actually performing the removal. Useful for verifying what changes will occur.
  • apt-get remove <package_name> --auto-remove: Remove the specified package and automatically remove packages that were installed as dependencies but are no longer needed. Sample Command and Output:
  $ sudo apt-get remove --auto-remove vim
  Reading package lists... Done
  Building dependency tree       
  Reading state information... Done
  The following packages will be REMOVED:
    vim vim-common vim-runtime xxd
  The following packages will be automatically removed:
    vim-gtk vim-tiny
  0 upgraded, 0 newly installed, 4 to remove and 2 to auto-remove.
  Need to get 0 B of archives.
  After this operation, 15.0 MB of disk space will be freed.

Description:

  • apt-get remove <package_name> --auto-remove: Removes the specified package and any other packages that were installed as dependencies and are no longer needed by any other installed package.
  • apt-get remove --purge <package_name>: Remove the specified package and its configuration files. Sample Command and Output:
  $ sudo apt-get remove --purge vim
  Reading package lists... Done
  Building dependency tree       
  Reading state information... Done
  The following packages will be REMOVED:
    vim vim-common vim-runtime xxd
  The following packages will be automatically removed:
    vim-gtk vim-tiny
  0 upgraded, 0 newly installed, 4 to remove and 2 to auto-remove.
  After this operation, 15.0 MB of disk space will be freed.

Description:

  • apt-get remove --purge <package_name>: Removes the specified package and its configuration files, freeing up additional space but losing any custom settings.

Note: Use apt-get remove for routine package removal when you might want to keep configuration files. Use apt-get purge if you want to completely remove the package, including configuration files.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.