Score:3

apt upgrade gives "Operation not permitted"

fi flag

While trying to upgrade Ubuntu 21.10 by running apt upgrade as root, I get the following error:

dpkg: error processing archive /var/cache/apt/archives/login_1%3a4.8.1-1ubuntu9_amd64.deb (--unpack):
 unable to create '/usr/share/man/zh_CN/man1/login.1.gz.dpkg-new' (while processing './usr/share/man/zh_CN/man1/login.1.gz'): Operation not permitted
Errors were encountered while processing:
 /var/cache/apt/archives/login_1%3a4.8.1-1ubuntu9_amd64.deb

Further inspection suggests it may have to do with the extended attributes of /usr/share/man/zh_CN/man1.

When running lsattr -ld /usr/share/man/zh_CN/man1/ it outputs:

/usr/share/man/zh_CN/man1/   Synchronous_Updates, Immutable, Append_Only, Compression_Requested, Extents

Can I safely remove these attributes (I expect them to be there for a reason)? Or is there some other upgrade command I need to perform?

mobilityguy avatar
de flag
I had this problem running apt upgrade. All packages except linux-firmware upgraded fine, but upgrading that package gave me an "Operation not permitted" error opening the .deb, with an "unable to open" message for a file in /lib/firmware. What was odd was that on each attempt it flagged a different file. Two I captured were /lib/firmware/intel/irci_irci_ecr-master_20161208_0213_20170112_1500.bin.dpkg-new and /lib/firmware/iwlwifi-9260-th-b0-jf-b0-38.ucode.dpkg-new. Since the problem didn't seem isolated to one file, I ran apt upgrade again and it worked. Not a fix, but a lucky workaround.
fi flag
I reinstalled the system, since it started crashing consistently and at some point would no longer start.
Score:0
my flag

As I can see, you're using an antivirus! Disable that antivirus and proceed.

Note: I'm pretty sure this is due to McAfee, so, please run every suggested command step by step until the problem is fixed.

  1. First, run the following commands to disable any instance of antivirus:

    sudo dpkg --purge mfedx 
    sudo dpkg --purge mcafeetp 
    sudo dpkg --purge mcafeeespaac 
    sudo dpkg --purge mcafeeespfileaccess 
    Sudo dpkg --purge mcafeeesp 
    sudo dpkg --purge mcafeert 
    sudo dpkg --purge mfecma 
    sudo dpkg --purge mfert
    
  2. Remove any antivirus/security/blocker program you're using.

  3. Run the following commands:

    sudo apt --fix-broken install
    sudo apt upgrade  
    

  1. If the upgrade still showed errors, then also run:

    sudo apt clean 
    sudo apt autoremove 
    sudo dpkg -i ./var/cache/apt/archives*.deb
    sudo dpkg -i --force-overwrite /var/cache/apt/archives/login_1%3a4.8.1-1ubuntu9_amd64.deb
    
  2. Now update and upgrade:

    sudo apt update
    sudo apt full-upgrade
    

Still not fixed?

  1. If it's still showing errors, I'd recommend reinstalling the packages.

    sudo rm -r /var/cache/apt/archives/*.deb
    sudo apt update
    sudo apt upgrade
    
  2. Check if you have all the dependencies installed.

    The package login depends on:

    • libaudit1 (>= 1:2.2.1)
      Dynamic library for security auditing

    • libc6 (>= 2.33)
      GNU C Library: Shared libraries

    • libcrypt1 (>= 1:4.1.0)
      libcrypt shared library

    • libpam-modules (>= 1.1.8-1)
      Pluggable Authentication Modules for PAM

    • libpam-runtime
      Runtime support for the PAM library

    • libpam0g (>= 0.99.7.1)
      Pluggable Authentication Modules library


If it isn't fixed till now then purge-reinstall the login package:

sudo dpkg -P login
sudo apt remove --purge login
sudo apt autoremove
sudo apt install login

Feel free to ask me anything in comments or chat.

fi flag
Unfortunately, I do not have a virusscanner running. I tried `apt --fix-broken install` but got the same error
fi flag
`dpkg -P login` errors out with `this is an essential package; it should not be removed`
Someone avatar
my flag
@SergeFonville Have you ran other commands?
Someone avatar
my flag
@SergeFonville Let's continue this [discussion in chat](https://chat.stackexchange.com/rooms/133026/discussion-on-operattion-not-permitted),
fi flag
I executed all commands and that gave the same error message.
Someone avatar
my flag
@SergeFonville OK! Run `sudo rm -rf /var/cache/apt/archives/*.deb && sudo apt-mark hold login && sudo apt upgrade`
Someone avatar
my flag
@SergeFonville BTW I wrote such a big answer just to hear "It didn't work"? :/ Please provide errors you got, other details about how my answer didn't work? Please avoid extended discussion is comments, let's move this discussion to [chat](https://chat.stackexchange.com/rooms/133026/discussion-on-operattion-not-permitted)
Score:-2
ng flag

apt commands require administrator privileges.

You need to preface the command with sudo.

You should also run sudo apt update before you do anything else in apt to make sure that you are working with the current list of software.

For example:

sudo apt update
sudo apt upgrade
hr flag
The OP says they are *"running `apt upgrade` as root"* already - in any case, the error from not being root would be "permission denied" (EACCES) rather than "operation not permitted" (EPERM) I think?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.