Skip to content

Instantly share code, notes, and snippets.

@rmoyano
Last active August 27, 2025 13:07
Show Gist options
  • Select an option

  • Save rmoyano/2eba71c7dde50f1d6b30f09323d5b204 to your computer and use it in GitHub Desktop.

Select an option

Save rmoyano/2eba71c7dde50f1d6b30f09323d5b204 to your computer and use it in GitHub Desktop.
APT

Installation

Listado de programas en L15:
bpython vscodium keepassxc cmus qmmp matecalculator tilix - terminator chromium firefox solaar kolourpaint qbittorrent vlc wicd fish gparted geany document viewer xscreensaver

Assume yes to all prompts:

$ apt-get install ca-certificates curl -y

apt-get -y install One side effect of using -y is that it will skip downgrades, whereas if the user entered y, it would perform the downgrades. So if you want -y to execute the same thing as a user entering y,you also need to add --allow-downgrades

Man page:

-y, --yes, --assume-yes
       Automatic yes to prompts; assume "yes" as answer to all prompts and
       run non-interactively. If an undesirable situation, such as
       changing a held package, trying to install an unauthenticated
       package or removing an essential package occurs then apt-get will
       abort. Configuration Item: APT::Get::Assume-Yes

Simulate package installation

apt-get -s install <package>: You can run a simulation in apt or apt-get using the -s or --simulate option to see what would happen if you upgrade/install a package:

user@dell:/home/laptop$ apt-get -s install <package>

Simulate possible package upgrade

To see all possible upgrades, run an upgrade in verbose mode and (to be safe) with simulation; press n to cancel:

user@dell:/home/laptop$ apt-get -V -s upgrade

Check installed and remote version available

apt-cache policy <package>: The option policy can show the installed and the remote version (install candidate) of a package.

user@dell:/home/laptop$ apt-cache policy bpython
bpython:
  Installed: 0.22.1-2
  Candidate: 0.22.1-2
  Version table:
 *** 0.22.1-2 500
        500 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
        500 http://archive.ubuntu.com/ubuntu jammy/universe i386 Packages
        100 /var/lib/dpkg/status
user@dell:/home/laptop$ apt-cache policy ansible
ansible:
  Installed: (none)
  Candidate: 2.10.7+merged+base+2.10.8+dfsg-1
  Version table:
     2.10.7+merged+base+2.10.8+dfsg-1 500
        500 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
        500 http://archive.ubuntu.com/ubuntu jammy/universe i386 Packages

Check package version

dpkg -s <package> | grep Version: For this case, you need to have installed the package on your system.

user@dell:/home/laptop$ dpkg -s bpython | grep Version
Version: 0.22.1-2

Remove package

The commands apt remove and apt purge are used to uninstall software packages on Debian-based Linux systems, such as Ubuntu. The primary difference between them lies in how they handle configuration files.

apt remove <package_name>:
This command removes the specified package's binary files and other associated files, but it retains the package's 
system-  wide configuration files. This can be useful if the user intends to reinstall the package later and wants 
to preserve their previous settings.

apt purge <package_name>:
This command removes the specified package and its system-wide configuration files. This provides a cleaner 
uninstallation, as it attempts to remove all traces of the package from the system, except for user-specific 
configuration files located in the user's home directory (e.g., ~/.config). 

In summary, apt remove is for a basic uninstallation, while apt purge offers a more complete removal, including system-wide configuration files. The choice between them depends on whether the user desires to keep or remove the configuration files for a potential future reinstallation or to achieve a cleaner system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment