4

I use zsh. when I try to upgrade the system, some packages related to php pop up, I want to remove them

$ sudo apt-get upgrade              
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  fonts-opensymbol kdelibs-bin kdelibs5-data kdelibs5-plugins kdoctools
  libkcmutils4 libkde3support4 libkdeclarative5 libkdecore5 libkdesu5
  libkdeui5 libkdewebkit5 libkdnssd4 libkemoticons4 libkfile4 libkhtml5
  libkidletime4 libkio5 libkjsapi4 libkjsembed4 libkmediaplayer4
  libknewstuff3-4 libknotifyconfig4 libkntlm4 libkparts4 libkprintutils4
  libkpty4 libkrosscore4 libktexteditor4 libnepomuk4 libnepomukquery4a
  libnepomukutils4 libplasma3 libsolid4 libssl1.0.0 libssl1.0.0:i386
  libthreadweaver4 openssl php-pear php5-cli php5-common php5-curl php5-fpm
  php5-gd php5-intl php5-mysql php5-pspell php5-readline php5-recode php5-snmp
  php5-sqlite php5-tidy php5-xmlrpc php5-xsl
54 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 18.4 MB/20.0 MB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] 

What I tried:

 sudo apt-get remove php
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package php

▶ sudo apt-get remove php*
zsh: no matches found: php*

sudo apt-get remove php *
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package 'dropbox' is not installed, so not removed
E: Unable to locate package php
E: Unable to locate package avlfolder
E: Unable to locate package boot-scripts
E: Unable to locate package Calibre Library
E: Unable to locate package Desktop
E: Unable to locate package Documents
E: Unable to locate package Downloads
E: Unable to locate package Dungeons and Dragons Online
E: Unable to locate package Games
E: Unable to locate package java ide
E: Unable to locate package jdownloader
E: Unable to locate package lello
E: Unable to locate package liberam
E: Unable to locate package Music
E: Unable to locate package netbeans-8.0
E: Couldn't find any package by regex 'netbeans-8.0'
E: Unable to locate package netbeans-8.0.desktop
E: Couldn't find any package by regex 'netbeans-8.0.desktop'
E: Unable to locate package Pictures
E: Unable to locate package PlayOnLinux's virtual drives
E: Unable to locate package projects
E: Unable to locate package Public
E: Unable to locate package qtprojects
E: Unable to locate package Savage2
E: Unable to locate package sketchbook
E: Unable to locate package Templates
E: Unable to locate package text.txt
E: Couldn't find any package by regex 'text.txt'
E: Unable to locate package themes
E: Unable to locate package tor-browser-linux64-3.6.1_en-US.tar.xz
E: Couldn't find any package by regex 'tor-browser-linux64-3.6.1_en-US.tar.xz'
E: Unable to locate package Videos
E: Unable to locate package VirtualBox VMs
E: Unable to locate package workspace
E: Unable to locate package xal

And I tried the same with php5 and with purge, nothing has changed. autoremove didn't work either

Update

Since I had no answer so far, I ran

sudo apt-get remove --purge php-pear php5-cli php5-common php5-curl php5-fpmphp5-gd php5-intl php5-mysql php5-pspell php5-readline php5-recode php5-snmpphp5-sqlite php5-tidy php5-xmlrpc php5-xsl
[sudo] password for elie: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package php5-fpmphp5-gd
E: Unable to locate package php5-snmpphp5-sqlite

I was looking for a better solution, anyway I don't understand how php5-fpmphp5-gd and php5-snmpphp5-sqlite need to be upgraded if they aren't installed. How could the system detect that they need to be upgraded, but didn't detect them when I tried to remove them?

8
  • 2
    Just a caution, this sudo apt-get remove php * IS A REALLY BAD IDEA. Basically you're saying - 'remove package php and everything else'. It will remove ALL your installed programs because of the space between your php and *.
    – Parto
    Jun 24, 2014 at 9:58
  • @Parto oh really? I think that's why zsh escaped the command, I made a somehow similar mistake using bash and it removed everything few month ago :) forgot about it, I was just trying different commands to see what would work askubuntu.com/questions/446651/…
    – Lynob
    Jun 24, 2014 at 10:03
  • @Parto, no it won't. The * in that command is a glob that (in the OP's shell) expands to all the files in the current directory, so if you have files called "myfile.txt" and "otherfile.csv" in the current directory, sudo apt-get remove php * expands to sudo apt-get remove php myfile.txt otherfile.csv which is obviously not what you want because it won't work. Jul 7, 2014 at 4:09
  • @Fischer you have just unwittingly revealed the contents of your home directory ;) Jul 7, 2014 at 4:10
  • You forgot the some space characters : this is not php5-fpmphp5-gd and php5-snmpphp5-sqlite but php5-fpm php5-gd php5-snmp php5-sqlite which are installed if the system wants to update them.
    – Benoit
    Jul 7, 2014 at 10:28

3 Answers 3

7
+50

zsh, unlike bash, has a different glob/wildcard/expansion system, so it works differently so php*might not work as you expect.
So are instead of sudo apt-get remove php*, you could:

  • Quote it:

    sudo apt-get remove "php*"
    
  • Bash it:

    bash -c "sudo apt-get remove php*"
    

N.B. Whilst also being a bad idea (as previously pointed out), sudo apt-get remove php * returned the names of files and foldersin the current working directory (likely your home directory) because of the * - but this also means if you have any files in hte terminal's current working directory beginning with php, you may have a problem using php* to request stuff, as it might include those filenames in the expansion.

Another N.B. php5-fpmphp5-gd and php5-snmpphp5-sqlite might of been part of the update, as some of the packages being updated needed those packages as new dependencies. By php5-fpmphp5-gd and php5-snmpphp5-sqlite, you probably meant php5-fpm, php5-gd, php5-snmp, php5-sqlite... (looking at the output you provided, it was because newlines occurred at those points) you probably should of ran:

sudo apt-get remove --purge php-pear php5-cli php5-common php5-curl php5-fpm php5-gd php5-intl php5-mysql php5-pspell php5-readline php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
4

aptitude is an alternative to apt-get which makes it easy to match multiple package names using regular-expression-like patterns.

For example, to list all installed packages whose package names contain the term "php":

aptitude search ~iphp

Edit: when using zsh shell, quote the argument so it doesn't break on the tilde:

sudo aptitude search "~iphp"

Or to uninstall them:

sudo aptitude remove ~iphp

or

sudo aptitude purge ~iphp

Consult this reference for more on the aptitude search syntax.

Note: aptitude is more powerful than apt-get and therefore makes it easier to hose your system. Always check which packages it is planning to remove, install, or downgrade before you confirm that it should go ahead. For example, sometimes in order to satisfy your request to uninstall a package, aptitude would need to uninstall a bunch of other packages that depend on it.

If you're wondering what caused php packages to be installed in the first place, you can do some detective work by searching for reverse dependencies for a package: which packages depend on a package. Recommended dependencies are installed by default but it is possible to override this and install a package without its "recommends" dependencies, or remove some "recommends" dependencies without removing the original package.

To list packages which are currently installed which also depend on, say, php5-fpm:

aptitude why php5-fpm

This should work most of the time, but for various reasons sometimes it can be impossible for the system to tell what caused a package to be automatically installed - maybe it was once a dependency of something but after an upgrade it's no longer depended on, etc.

If you get a command not found when trying to use aptitude, you need to install it on your system, like this:

sudo apt-get install aptitude

Note: in the past, it was common to warn people not to use apt-get and aptitude interchangeably to actually modify the system, because they couldn't keep track of which packages were automatically installed by each other. This is no longer an issue (since at least 3 years ago), and they both use the same way of recording which packages were automatically installed.

Edit: fixed aptitude why command

1
  • Testing those commands in zsh, I get the zsh: no such user or named directory: iphp error - you need to quote " the ~iphp.
    – Wilf
    Jul 7, 2014 at 4:15
2

You can use purge, autoremove & remove. I am using autoremove as an example for this.

$ sudo apt-get autoremove 'php*'

you can also use aptitude

$ sudo aptitude remove 'php*'

check the installed packages

$ sudo apt-cache policy 'php*'

if all of them are none so all of the php app aren't installed

if there's an installed package you can delete it by

$ sudo apt-get autoremove 'packagename'

Note: purge and remove are not the same. purge removes the package and its configuration and remove removes the package only.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .