"dpkg: error: requested operation requires superuser privilege". Cannot remove all configuration info from removed packages, sudo doesn't work

84,055

Solution 1

try to login as root, to gain the super-power, you can do this by typing:

sudo -i

then write (copy/paste :: Ctrl + C / Ctrl + Shift + V <-- paste in terminal) your command in terminal, and it should work

Solution 2

sudo only applies to a single command, not the whole pipeline. In your case, the command ran as superuser was dpkg -l – which is not necessary.

On the contrary, the command really requiring the superuser access in your pipeline is dpkg --purge, so prepend sudo directly to it.

dpkg -l | grep '^rc' | awk '{print $2}' | xargs sudo dpkg --purge

By the way, awk can filter rows using regular expressions just like grep does, so you can save one command:

dpkg -l | awk '/^rc/{print $2}' | xargs sudo dpkg --purge

Solution 3

sudo -i dpkg -l | grep '^rc' | awk '{print $2}' | xargs dpkg --purge

This may run your command with ROOT priviliges. Sudo and root is different. Reference

Share:
84,055

Related videos on Youtube

Garri Sumalapao Farol
Author by

Garri Sumalapao Farol

Updated on September 18, 2022

Comments

  • Garri Sumalapao Farol
    Garri Sumalapao Farol almost 2 years

    I want to run this command (see section 4 from here https://help.ubuntu.com/community/AptGet/Howto#Removal_commands):

    dpkg -l | grep '^rc' | awk '{print $2}' | xargs dpkg --purge
    

    I use sudo at the beginning but anyway I get an error:

    user@user-desktop:~$ sudo dpkg -l | grep '^rc' | awk '{print $2}' | xargs dpkg --purge
    [sudo] password for user:
    dpkg: error: requested operation requires superuser privilege
    

    Why sudo doesn't work? What else should I type?

  • Olaf Dietsche
    Olaf Dietsche almost 5 years
    This neither explains why it isn't working, nor what to do instead. See @Melebius answer for both.