E: Could not get lock /var/lib/dpkg/lock

E: Could not get lock /var/lib/dpkg/lock

1、错误描述

yhd@ubuntu:~$ sudo apt-get install oracle-java8-installer
[sudo] password for yhd: 
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
yhd@ubuntu:~$ ps -A | grep apt
   804 ?        00:00:00 apt.systemd.dai
yhd@ubuntu:~$ sudo kill -804 processnumber
yhd@ubuntu:~$ ps -A | grep apt

2、错误原因

在使用apt-get安装java8,之前执行了这个命令然后中断了,再次执行这个命令会提示错误。

3、解决办法

(1)查看apt进程

ps -A | grep apt

(2)kill进程

sudo kill -804 processnumber