Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: * no longer a wild card in apt?

  1. #11
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: * no longer a wild card in apt?

    Not sure when, but apt added some regex support in the last 1-2 months similar to what apt-get has.
    I use it mostly to purge unwanted package like nano, network-manager, apt-notifier.
    Code:
    sudo apt purge nm-*
    is an example.

    It can be handy to get a list of old kernels, headers, modules to be purged so that /boot/ doesn't get filled by having 2+ lines of kernels updated.
    Last edited by TheFu; January 27th, 2021 at 08:58 PM.

  2. #12
    Join Date
    Apr 2008
    Beans
    11,705

    Re: * no longer a wild card in apt?

    Quote Originally Posted by TheFu View Post
    Not sure when, but apt added some regex support in the last 1-2 months similar to what apt-get has.
    I use it mostly to purge unwanted package like nano, network-manager, apt-notifier.
    Code:
    sudo apt purge nm-*
    is an example.

    It can be handy to get a list of old kernels, headers, modules to be purged so that /boot/ doesn't get filled by having 2+ lines of kernels updated.
    I'll have to experiment a bit with that. One recent project involved purging nvidia drivers from TTY but it took me a long time to figure out exactly what version and what the full package name was.

  3. #13
    Join Date
    Mar 2011
    Beans
    1,687

    Re: * no longer a wild card in apt?

    Of course, it never hurts to quote the name with the wildcard, to avoid any possible expansion into a local filename. ;^)

  4. #14
    Join Date
    Mar 2010
    Location
    Squidbilly-Land
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: * no longer a wild card in apt?

    Quote Originally Posted by kansasnoob View Post
    but it took me a long time to figure out exactly what version and what the full package name was.
    There are multiple ways to have APT tell us things. My most common things are:

    What package is this file in? $ dpkg -S /bin/ls
    What packages are related to kernels I have installed?
    Code:
    $ dpkg -S  /boot/vmlinuz-4.15.0-129-generic
    linux-image-4.15.0-129-generic: /boot/vmlinuz-4.15.0-129-generic
    From that answer, what older kernel packages should I remove?
    Code:
    $ dpkg -l|egrep linux-image-4.15
    rc  linux-image-4.15.0-122-generic              4.15.0-122.124~16.04.1                          amd64        Signed kernel image generic
    rc  linux-image-4.15.0-123-generic              4.15.0-123.126~16.04.1                          amd64        Signed kernel image generic
    rc  linux-image-4.15.0-126-generic              4.15.0-126.129~16.04.1                          amd64        Signed kernel image generic
    rc  linux-image-4.15.0-128-generic              4.15.0-128.131~16.04.1                          amd64        Signed kernel image generic
    ii  linux-image-4.15.0-129-generic              4.15.0-129.132~16.04.1                          amd64        Signed kernel image generic
    ii  linux-image-4.15.0-132-generic              4.15.0-132.136~16.04.1                          amd64        Signed kernel image generic
    ii  linux-image-4.15.0-70-generic               4.15.0-70.79~16.04.1                            amd64        Signed kernel image generic
    The 'ii' answers are still installed. The 'rc' answers have been removed, but may have left some cruft around - purging will remove them from the list.
    To do that,
    Code:
    $ sudo apt purge linux-image-4.15.0-70-generic linux-image-4.15.0-12[0-8]
    ....
    The following package was automatically installed and is no longer required:
      linux-modules-4.15.0-70-generic
    Use 'sudo apt autoremove' to remove it.
    The following packages will be REMOVED:
      linux-image-4.15.0-122-generic* linux-image-4.15.0-123-generic*
      linux-image-4.15.0-126-generic* linux-image-4.15.0-128-generic*
      linux-image-4.15.0-70-generic*
    0 upgraded, 0 newly installed, 5 to remove and 0 not upgraded.
    After this operation, 8,205 kB disk space will be freed.
    Do you want to continue? [Y/n] Y
    ...
    And to clean up the kernel modules, ...
    Code:
    $ sudo apt autoremove 
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following packages will be REMOVED:
      linux-modules-4.15.0-70-generic
    0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
    After this operation, 64.6 MB disk space will be freed.
    Do you want to continue? [Y/n] Y
    ....
    Now those extra kernel modules aren't in the list causing cruft:
    Code:
    $ dpkg -l|egrep linux-image-4.15
    ii  linux-image-4.15.0-129-generic              4.15.0-129.132~16.04.1                          amd64        Signed kernel image generic
    ii  linux-image-4.15.0-132-generic              4.15.0-132.136~16.04.1                          amd64        Signed kernel image generic
    If you don't use grep/egrep, some changes are needed to the dpkg commands:
    Code:
    $ dpkg -l  linux-image-4.15
    dpkg-query: no packages found matching linux-image-4.15
    It appears to perform an exact-match search, which is not what I need/want.
    Code:
    $ dpkg -l  linux-image-4.15*
    Desired=Unknown/Install/Remove/Purge/Hold
    | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
    |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
    ||/ Name           Version      Architecture Description
    +++-==============-============-============-==================================
    un  linux-image-4. <none>       <none>       (no description available)
    un  linux-image-4. <none>       <none>       (no description available)
    un  linux-image-4. <none>       <none>       (no description available)
    un  linux-image-4. <none>       <none>       (no description available)
    ii  linux-image-4. 4.15.0-129.1 amd64        Signed kernel image generic
    ii  linux-image-4. 4.15.0-132.1 amd64        Signed kernel image generic
    Add the linux-image-4.15* with or without quotes, and we get nicer output?

    And apt can install .deb packages AND all the dependencies now.
    Code:
    sudo apt install ./Kewl-new-package-0.1.deb
    But, as always, directly installing .deb files that aren't specific to the Ubuntu release will probably lead to a stuck "APT" packaging system due to dependencies in 3-6 months.
    Last edited by TheFu; January 28th, 2021 at 03:12 PM.

  5. #15
    Join Date
    May 2008
    Location
    United Kingdom
    Beans
    4,717
    Distro
    Lubuntu 18.04 Bionic Beaver

    Re: * no longer a wild card in apt?

    Quote Originally Posted by TheFu View Post
    Code:
    sudo apt purge nm-*
    Quote Originally Posted by ubfan1 View Post
    Of course, it never hurts to quote the name with the wildcard, to avoid any possible expansion into a local filename. ;^)
    This is important. Always quote your wildcards when using apt, dpkg, etc.

    Example: I have a file called fontana.odt. When I run dpkg-query --list font*, instead of getting a list of installed fonts, I get the message, "dpkg-query: no packages found matching fontana". I avoid this with dpkg-query --list 'font*'.

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •