1

I am trying to run sudo apt-get update && apt-get upgrade -y but it is throwing series of errors. I am new to Linux environment.

I am using Ubuntu 18.04 Bionic Beaver

sudo apt-get update && apt-get upgrade -y
Ign:1 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:2 http://ppa.launchpad.net/persepolis/ppa/ubuntu bionic InRelease  
Hit:3 http://dl.google.com/linux/chrome/deb stable Release                
Err:5 http://archive.canonical.com/ubuntu bionic InRelease             
502  Connection timed out [IP: 2001:67c:1360:8c01::16 80]
Err:6 http://security.ubuntu.com/ubuntu bionic-security InRelease   
502  Connection timed out [IP: 2001:67c:1562::16 80]
Err:7 http://in.archive.ubuntu.com/ubuntu bionic InRelease
502  Connection timed out [IP: 2001:67c:1360:8001::21 80]
Err:8 http://in.archive.ubuntu.com/ubuntu bionic-updates InRelease
502  Connection timed out [IP: 2001:67c:1360:8001::21 80]
Err:9 http://security.ubuntu.com/ubuntu artful-security InRelease
502  Connection timed out [IP: 2001:67c:1562::16 80]
Err:10 http://in.archive.ubuntu.com/ubuntu artful InRelease
502  Connection timed out [IP: 2001:67c:1360:8001::21 80]
Err:11 http://in.archive.ubuntu.com/ubuntu artful-updates InRelease
502  Connection timed out [IP: 2001:67c:1360:8001::21 80]
Err:12 http://in.archive.ubuntu.com/ubuntu bionic-backports InRelease
502  Connection timed out [IP: 2001:67c:1360:8001::21 80]
Reading package lists... Done
W: Failed to fetch 
http://in.archive.ubuntu.com/ubuntu/dists/bionic/InRelease  502  
Connection timed out [IP: 2001:67c:1360:8001::21 80]
W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/bionic- 
updates/InRelease  502  Connection timed out [IP: 
2001:67c:1360:8001::21 80]
W: Failed to fetch 
http://in.archive.ubuntu.com/ubuntu/dists/artful/InRelease  502  
Connection timed out [IP: 2001:67c:1360:8001::21 80]
W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/artful- 
updates/InRelease  502  Connection timed out [IP: 
2001:67c:1360:8001::21 80]
W: Failed to fetch http://in.archive.ubuntu.com/ubuntu/dists/bionic- 
backports/InRelease  502  Connection timed out [IP: 
2001:67c:1360:8001::21 80]
W: Failed to fetch 
http://archive.canonical.com/ubuntu/dists/bionic/InRelease  502  
Connection timed out [IP: 2001:67c:1360:8c01::16 80]
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic- 
security/InRelease  502  Connection timed out [IP: 2001:67c:1562::16 
80]
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/artful- 
security/InRelease  502  Connection timed out [IP: 2001:67c:1562::16 
80]
W: Some index files failed to download. They have been ignored, or old 
ones used instead.
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?

Thank You

Amit Singh Gaur
  • 141
  • 2
  • 5
  • Old unanswered question https://askubuntu.com/questions/1046228/problem-occurred-while-updating-ubuntu-18-04 for the main bunch of errors. For the root errors you need to put sudo in front of the 2nd command (sudo apt-get update && sudo apt-get upgrade. Is this the first/only time you have had connection errors? – Wilf Jun 29 '18 at 09:07
  • I am getting these errors from tomorrow after I installed VirtualBox. Is there any mirror to these sources? And how can I change them? Thank you – Amit Singh Gaur Jun 29 '18 at 09:11
  • It looks like you don't have a working internet connection. Is this a real machine or are you running a virtual machine in virtual box (I don't understand your virtualbox reference sorry). I'd suggest trying to ping a web site using ip.address (say 8.8.8.8 or google.dns), then try with a human.address (say google.com) - do any get thru. If first does, second doesn't you have a DNS error. If none get thru you have networking issues you must correct first. – guiverc Jun 29 '18 at 09:17
  • I do have a working internet connection. I am able to ping www.google.com. I am running Ubuntu on the physical machine. Is there any chance that the error is because of Ubuntu server problem ? – Amit Singh Gaur Jun 29 '18 at 09:40
  • 1
    You are unwisely using sources from different releases of Ubuntu: artful and bionic. Don't do that. Stick with one release. While not responsible for your network problem today, mixing versions will surely break your system someday. – user535733 Jun 29 '18 at 13:37
  • If the unlikely event it is the servers (should only be temporary if it is!), you can change the mirrors https://askubuntu.com/questions/104695/how-do-i-change-mirrors-in-ubuntu-server-from-regional-to-main otherwise, you may have a networking issue, especially if you have to sign into the network or proxy through a browser or similar, or a weird firewall/filtering somewhere. – Wilf Jun 29 '18 at 14:20

2 Answers2

2

Your command line contains one occurrence of sudo but also &&. In this case, sudo only applies to the former command, not the part after &&. Add sudo to the latter command, too.

sudo apt-get update && sudo apt-get upgrade -y

However, there is at least one more problem:

502  Connection timed out [IP: 2001:67c:1360:8001::21 80]

which means you should check your network connection.

Generally, you should run commands manually one by one (i.e. avoid &&, -y etc.) to diagnose problems.

Melebius
  • 11,431
  • 9
  • 52
  • 78
-1

Try these commands:

sudo -i
apt-get clean
cd /var/lib/apt
mv lists lists.old
mkdir -p lists/partial
apt-get clean
apt-get update
karel
  • 114,770
  • 2
    Won't solve a timeout issue. – Thomas Ward Sep 24 '19 at 20:58
  • Welcome to [ubuntu.se]! Thank you for this code, which might provide some limited, immediate help. A proper explanation would greatly improve its long-term value by showing why this is a good solution to the problem and would make it more useful to future readers with other, similar questions. Please [edit] your answer to add some explanation, including the assumptions you’ve made. – Melebius Sep 25 '19 at 09:27