I am using Ubuntu 16LTS and performed a regular upgrade with apt. The upgrade failed with openssh-server and apt complained it could not upgrade because it cannot make a backup of /usr/sbin/sshd

I removed openssh-server and tried to reinstall it. No luck and apt comes back with the same message. I remove openssh-server again.

When I try to manually change or remove /usr/sbin/sshd I get the message that "Operation is not permitted". I tried to remove the attribute chattr -a -i /usr/sbin/sshd but it keeps responding that the operation not permitted. An other annoying issue is that lsattr does not give back any info.

How can I force a delete or move of the /usr/sbin/sshd file?

2 Answers 2


The following command will show you which process lock a specific file:

sudo lsof /usr/sbin/sshd

If the result of lsof will give you sshd service than you should stop the service before performing the upgrade.

Assuming the you tried to remove sshd while it is still running, you can try to stop sshd first.


sudo /etc/init.d/ssh stop


sudo service ssh stop

After the service is stopped, you can try to upgrade via apt or remove the folder manually.

  • When I run the lsof /usr/sbin/sshd command I do not get anything back. The sshd process is not running, so it could not lock the file. May 18, 2017 at 9:23
  • @FreddeGoede - okay, so now the file is not locked. what happened when you try to execute the apt command (or move/delete the file)?
    – Yaron
    May 18, 2017 at 9:26
  • When I execute the apt command it says it cannot install openssh-server because it cannot make a backup of /usr/sbin/sshd May 18, 2017 at 9:32
  • When I try to delete it, it says "Operation not permitted" May 18, 2017 at 9:32

I found the solution myself. Apearently the lsattr and chattr files where damaged. Maybe I was hacked. When I replaced the two files with the correct version I could remove the -i flag and I could remove sshd.

Thanks for the help Yaron.

You must log in to answer this question.

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