-1

This is the error that I get after executing sudo apt-get update && apt-get install -y

Hit:1 http://ir.archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://ir.archive.ubuntu.com/ubuntu focal-updates InRelease
Get:3 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:4 http://ir.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Hit:5 https://repo.steampowered.com/steam stable InRelease 
Get:6 http://dl.google.com/linux/chrome/deb stable InRelease [1,811 B]
Fetched 224 kB in 20s (11.0 kB/s) 
Reading package lists... Done 
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13:Permission denied) 
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
Nmath
  • 12,333

2 Answers2

2

You forgot to add sudo in the second command so you did not have privileges to run the second command. The install command also did not include the name of a package to install.

The correct syntax for the command you tried to run is:

sudo apt-get update && sudo apt-get install -y packagename

However this command is problematic for a few reasons:

  • When you chain commands with && you do not get to see if the first command was successful or if it needs attention before the second command is executed.

  • When you use the -y option, you ignore confirmation prompts that would let you halt the process if something is not right.

  • sudo apt-get install needs a target package.

It's almost always better to run the commands separately, without the -y option. So one at a time, run:

sudo apt-get update
sudo apt-get install packagename

Replace packagename with the name of the package you are trying to install.

Nmath
  • 12,333
1

It is most likely because you aren't using correct syntax when writing the command. Assuming you are trying to install a package and update apt. sudo apt update && sudo apt install <package>. Also, you might want to try to add sudo in front of apt install to run it as root.