In Debian system, if you want to uninstall the software package without removing its dependencies, you can use the command sudo apt remove --no-remove packagename, which will retain all dependencies; 1. Use the --no-remove option to prevent automatic deletion of dependencies; 2. If the dependencies have been deleted by mistake, you can manually reinstall them through apt history check records; 3. Before uninstalling, you can use the --simulate or -s parameters to simulate operations to confirm the scope of impact; 4. For dependencies that need to be retained, you can use sudo apt install dependencyname to mark as manual installation.
Sometimes when you're cleaning up your system or trying to uninstall a specific package, you might find that the default uninstall command also tries to remove a bunch of dependencies. If you want to get rid of just the package and leave its dependencies behind, there's a straightforward way to do it — especially on Debian-based systems like Ubuntu.
The trick is to use apt
with a specific flag that tells it not to remove dependencies automatically.
Use apt remove --no-remove
to keep dependencies
By default, apt remove packagename
may also remove packages that were installed as dependencies unless they're required by other software. To prevent that, you can add the --no-remove
option:
sudo apt remove --no-remove packagename
This tells APT not to remove any dependencies, even if they were only pulled in by the package you're uninstalling. It's helpful if you installed something temporarily but want to keep related libraries or tools around.
Just be aware: this won't work if removing the package would break something else. In that case, APT will warn you and refuse to proceed.
What if you already removed it?
If you've already uninstalled the package using the regular method and noticed that it took some dependencies with it, you can try reinstalling those dependencies manually if needed. Just run:
-
sudo apt install dependency-package-name
You'll need to know which ones were removed, though. One way to check is by looking at the APT history:
apt history
That shows what was removed along with the main package. From there, you can pick out the dependencies you still need and reinstall them.
Double-check what will be removed
Before running any removal command, it's always good to see what's going to happen. You can simulate the action with:
sudo apt remove --simulate packagename
Or, more briefly:
sudo apt -s remove packagename
This shows you a list of packages that would be removed without actually making any changes. It's especially useful if you're unsure whether important dependencies will go with it.
Also, remember that some packages are marked as "automatically installed" (because they were pulled in as dependencies), and they tend to get removed more easily. If you want to keep them, make sure to mark them as manually installed:
sudo apt install dependencyname
Doing that tells APT you want to keep it around regardless of what depends on it.
That's basically how you remove a package without pulling out its dependencies. The key is using the right flags and double-checking what gets affected. Not complicated, but definitely worth knowing if you're managing a system where keeping certain libraries matters.
The above is the detailed content of How to remove a package without its dependencies?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The key to updating the CentOS kernel is to use the ELRepo repository and set up the startup items correctly. 1. First run uname-r to view the current kernel version; 2. Install the ELRepo repository and import the key; 3. Use yum to install kernel-lt (long-term support version) or kernel-ml (main version); 4. After the installation is completed, check the available kernels through the awk command and use grub2-set-default to set the default startup item; 5. Generate a new GRUB configuration file grub2-mkconfig-o/boot/grub2/grub.cfg; 6. Finally restart the system and run uname-r again to confirm whether the kernel version is effective. The whole process requires

To configure the CentOS7 static IP address, you need to edit the ifcfg file of the corresponding network card. 1. First confirm the network card name such as ens33 through iplinkshow or ls/sys/class/net; 2. Edit the /etc/sysconfig/network-scripts/ifcfg-ens33 file to set BOOTPROTO=static and fill in IPADDR, NETMASK, GATEWAY and other parameters; 3. After saving, restart the network service to make the configuration take effect; 4. Use the ipaddrshow and ping commands to verify whether the configuration is successful. Be careful to avoid IP conflicts and restart the network service after modification. If you use NetworkM

In Linux system, using the usermod command to add users to the secondary group is: 1. Execute the sudousermod-a-G group name username command to add, where -a means append to avoid overwriting the original secondary group; 2. Use groups username or grep group name /etc/group to verify whether the operation is successful; 3. Note that the modification only takes effect after the user logs in again, and the main group modification should use the -g parameter; 4. You can also manually edit the /etc/group file to add users, but be careful to avoid system abnormalities caused by format errors.

To migrate from CentOS8 to AlmaLinux or RockyLinux, follow the clear steps. First, choose AlmaLinux (suitable for long-term enterprise support) or RockyLinux (emphasizing exactly the same as RHEL) according to your needs. Secondly, prepare the system environment: update the software package, back up key data, check third-party repositories and disk space. Then, the conversion is automatically completed using the official migration script. RockyLinux needs to clone the repository and run the switch-to-rocky.sh script. AlmaLinux replaces the repository and upgrades with one click through the remote deployment script. Finally, verify system information, clean up residual packets, and update GRUB and ini if ??necessary

To correctly install the local RPM file and handle dependencies, you should first use dnf to install it directly, because it can automatically obtain the required dependencies from the configured repository; if the system does not support dnf, you can use yum's localinstall command instead; if the dependency cannot be resolved, you can manually download and install all related packages; finally, you can also forcefully ignore the dependency installation, but this method is not recommended. 1. Use sudodnfinstall./package-name.rpm to automatically resolve dependencies; 2. If there is no dnf, you can use sudoyumlocalinstall./package-name.rpm; 3. Force installation and execute sudorpm-ivh--nod

How to set a static IP address using nmcli on CentOS8 or 9? 1. First run the nmcliconnectionshow and ipa commands to view the current network interface and its configuration; 2. Use the nmcliconnectionmodify command to modify the connection configuration, specify parameters such as ipv4.methodmanual, ipv4.addresses (such as 192.168.1.100/24), ipv4.gateway (such as 192.168.1.1), and ipv4.dns (such as 8.8.8.8). 3. Run the nmcliconnectiondown and up commands to restart the connection to make the changes take effect, or

AminimalinstallofCentOSisalightweightsetupthatincludesonlyessentialcomponents,makingitidealforserversorsystemsrequiringfullcontrol.Itcontainscoreutilitieslikebash,yum/dnf,networkingtools,andsecuritypackages,whileexcludingdesktopenvironments,webserver

The current running mode of SELinux can be viewed through the command line. Use getenforce command to directly display the current status, and the output is Enforcing, Permissive or Disabled; view the /etc/selinux/config file to know the default startup mode; temporarily change the mode can be setenforce1 (enforcing) or setenforce0 (permissive), but restore the configuration file settings after restart; in actual applications, you need to pay attention to service compatibility issues, and switch modes to troubleshoot problems if necessary.
