apt-get install 的问题

apt-get install 的问题

我最近安装了 Ubuntu,并且一直尝试使用 apt-get 安装一些程序,但是它似乎从来没有起作用,甚至 apt-get update 也不起作用,这是我在尝试安装某些东西时得到的结果,在这种情况下:java 的 jdk-7 使用:

apt-get install openjdk-7-jre-headless

这是我得到的:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-3.2.0-29 linux-headers-3.2.0-29-generic-pae
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 24 not upgraded.
mkhas@mkhas-Inspiron-3520:~/Downloads$ sudo apt-get install openjdk-7-jre-headless
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-3.2.0-29 linux-headers-3.2.0-29-generic-pae
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  ca-certificates-java icedtea-7-jre-jamvm java-common openjdk-7-jre-lib tzdata-java
Suggested packages:
  default-jre equivs sun-java6-fonts ttf-dejavu-extra fonts-ipafont-gothic
  fonts-ipafont-mincho ttf-telugu-fonts ttf-oriya-fonts ttf-kannada-fonts
  ttf-bengali-fonts
The following NEW packages will be installed:
  ca-certificates-java icedtea-7-jre-jamvm java-common openjdk-7-jre-headless
  openjdk-7-jre-lib tzdata-java
 0 upgraded, 6 newly installed, 0 to remove and 24 not upgraded.
 Need to get 44.1 MB of archives.
 After this operation, 63.5 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
 WARNING: The following packages cannot be authenticated!
   openjdk-7-jre-lib ca-certificates-java tzdata-java java-common openjdk-7-jre-         headless
  icedtea-7-jre-jamvm
Install these packages without verification [y/N]? y
0% [Connecting to lb.archive.ubuntu.com (91.189.91.13)] 

然后就一直停留在 0%

编辑:是的,我的系统上的互联网运行良好。

我尝试过的一件事是将镜像服务器(它本来应该从 lb.archives.ubuntu.com 检索软件包)更改为 /etc/apt/sources.list 中的 archives.ubuntu.com,但它说该文件是只读的,我无法对其进行任何更改。

我尝试通过 apt-get 更新

apt-get update 

但每当我尝试这样做时,我都会得到这个:

E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

编辑:问题已解决,我没有使用 sudo apt-get update,而只是使用 apt-get update

答案1

apt-get命令需要 root 权限,因此您需要使用 来运行它sudo。例如:

sudo apt-get update

然后你可以安装你的软件包:

sudo apt-get install openjdk-7-jre-headless

相关内容