LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   apt-get update resulted in "Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)" (https://www.linuxquestions.org/questions/linux-newbie-8/apt-get-update-resulted-in-could-not-open-lock-file-var-lib-apt-lists-lock-open-13-permission-denied-4175701862/)

magster 10-11-2021 09:29 PM

apt-get update resulted in "Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)"
 
No response to my post yesterday yet. I am thinking it was too long.
This thread contains one part of the earlier thread. One step at a time,right ?
Maybe fixing this is all I need....

maggie@linux ~ $ apt-get update
Reading package lists... Done
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)
maggie@linux ~ $

I found a possible fix online and tried it

maggie@linux ~ $ sudo apt-get update && sudo apt-get upgrade
[sudo] password for maggie:
Hit:1 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:2 http://archive.canonical.com/ubuntu focal InRelease
Hit:3 https://repo.skype.com/deb stable InRelease
Hit:4 http://archive.ubuntu.com/ubuntu focal InRelease
Get:5 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Ign:6 http://packages.linuxmint.com uma InRelease
Hit:7 http://packages.linuxmint.com uma Release
Get:8 http://archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]
Fetched 214 kB in 2s (87.0 kB/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
maggie@linux ~ $

There are no errors, yet no fix either. I ran apt-get update again, and it was identical to the first time above...
I found there are some root fixes possible, but I also read one false move in root and I could ruin my system.

#2 Question What is the significance in the E: and the W: ?
#3 And how do I get my terminal results in their own box in this thread ?

I can use some help to fix this. Any takers ? :)

craigevil 10-11-2021 09:53 PM

You have to be root or use sudo to update.

PsychoHermit 10-11-2021 09:59 PM

sudo apt-get update sudo apt-get upgrade
 
Welcome to the world of Linux. I love it, everything on my 7 year old laptop just works.

I'm confused, you got errors running apt-get as maggie but when you used sudo everything worked normally. I don't see your problem. To paste terminal output into a post use {code} paste contents {/code}. Use [] instead of the {} I used.

You can highlight the contents of the terminal session with your mouse and then middle click in the post to paste the terminal contents.

--glenn

magster 10-11-2021 11:45 PM

craigevil,
Thanks for responding. "You have to be root or use sudo to update." So, sudo commands are safer then. Good to know.
And the "apt-get update" command requires I be root. Got it. Not ready to be root yet lol !
When I used sudo apt-get update && sudo apt-get upgrade I have questions about the result
Fetched 214 kB in 2s (87.0 kB/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Since 214kb were fetched, why is it 0 upgraded ?
And is the combined sudo apt-get update && sudo apt-get upgrade
the best command to get both update and upgrade all at once ? Finally, is using update manager alone pretty reliable ?

PsychoHermit,Sorry, I did not follow/ " use {code} paste contents. " Where do I find "code" ?
And what does "ign" stand for in #6 on $ sudo apt-get update && sudo apt-get upgrade ?
Thanks to both of you !!!

ondoho 10-12-2021 02:51 AM

Quote:

Originally Posted by magster (Post 6291260)
So, sudo commands are safer then.

Nobody said that. Do not jump to conclusions.
Remove that idea from your mind please, because it is wrong.
Quote:

Originally Posted by magster (Post 6291260)
Since 214kb were fetched, why is it 0 upgraded ?

The 214kB (Byte, not bit) are just the list of packages.

Quote:

Originally Posted by magster (Post 6291260)
And is the combined sudo apt-get update && sudo apt-get upgrade the best command to get both update and upgrade all at once ?

Not sure it's the best, but it's valid.

BTW, this is OP's earlier thread.

sundialsvcs 10-12-2021 08:56 AM

I always set up exactly one user which is "an administrator" – that is, "a member of the wheel group." Every other user, including all of the ones that I daily use, are not a member of that group and therefore do not have the power to gain root access no matter how hard they may try.

Anytime I need to put on blue tights and fly around, I walk into that telephone booth. I use it for no other purposes. You will never guess its random password, and you cannot log into it remotely even if you did know the magic word.

"Computers are terrible at knowing when to say 'yes,' but they are wonderful at saying 'no.'" Therefore I use this principle of least privilege on a daily basis. If you sneak some program into my account and try to run it on my behalf to do nasty things to my system, you will find that it doesn't work – my user does not have the power. And, if you try to snoop around into other users' /home/xxx directories, you will find that you have no access to them.

Rickkkk 10-12-2021 09:34 AM

Hi magster,

Concerning privileges / sudo / root :
  • Certain commands (basically those affecting system files) need to be run with higher privileges. Updating your system is one of those types of commands.

  • The "root" user is analogous to "local administrator" in the Windows world. The code has all privileges on everything. If needed, most distros let you log in using the root user, but that is not necessary in everyday situations (see next point).

  • The "sudo" and "su" commands temporarily enable a non-root user to execute the above type of commands by temporarily "substituting" their user for another to execute the command. If no specific user is specified, the system presumes you want to substitute "root". The difference between the 2 commands is that "sudo" (short for substitute user do) is a preface for a specific command and su is simply the command that will bring you a command prompt under the substituted user code (useful if you have several tasks to accomplish ...).
... so as mentioned above by ondoho, "sudo" (or "su") isn't a "safer" way of executing certain commands, it is rather one of the options you have to acquire the required privileges to execute certain commands.

Finally, as others have mentioned, your "update" and "upgrade" commands seem to be functioning correctly. "Update" simply updates your local package database (what is available in the online repositories - as mentioned, this is the small amount of data downloaded) and "upgrade" will install any new versions of packages already installed on your system (in your case, you don't have anything to upgrade yet).

Hope this helps - let us know if you need further help.

Cheers,

Rick

shruggy 10-12-2021 11:10 AM

Quote:

Originally Posted by Rickkkk (Post 6291358)
The difference between the 2 commands is that "sudo" (short for substitute user do) is a preface for a specific command and su is simply the command that will bring you a command prompt under the substituted user code (useful if you have several tasks to accomplish ...).

That's the common usage, but you can bring the command prompt with sudo -i and you can execute a command with su -c some_command. The crucial difference is that su - expects the password of root (and, more generally, su some_user the password of some_user), while sudo always expects your password.

magster 10-12-2021 02:57 PM

Ondoho,
I did not realize sudo DOES have root priveleges. Not as much as full root priveleges. Basically, I Could inadvertantly mess up my computer more easily using full root,I hear what you are saying though...

THanks.

magster 10-12-2021 03:06 PM

sundialsvcs,

Thanks for your input. For now, I feel safer using sudo commands and not even having full root control.
Is there any reason (safety wise) you see that I ought to set it up anyway so I could have full root control b4 I plan to use it ?
THanks.

magster 10-12-2021 03:11 PM

shruggy,

I guess to use su you must have a password. One different from my sudo one....THanks for that info. :)

michaelk 10-12-2021 03:20 PM

I posted a response in your other thread https://www.linuxquestions.org/quest...ma-4175701820/ as to why you might see the posted error.

Yes, it helps to only post one question in a thread and posting multiple threads on the same topic does cause confusion...

magster 10-12-2021 03:29 PM

Rickkkk,

Thanks for your clear explanations !
"Update" simply updates your local package database (what is available in the online repositories - as mentioned, this is the small amount of data downloaded)

That explains why when I see "fetched # kB" in an update, I do not see it reflected at the screen bottom
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

THat is only actual UPDATES that will be listed there. Is that correct ?
Now I understand that !

If in the future I post something, and there is no feedback, or I do not understand what a person replies, is it possible I could message you somehow through this platform? If you are okay with that, how would I do that ?

THanks sooo much !
Maggie

Rickkkk 10-12-2021 04:39 PM

Quote:

Originally Posted by magster (Post 6291444)
Rickkkk,

Thanks for your clear explanations !
"Update" simply updates your local package database (what is available in the online repositories - as mentioned, this is the small amount of data downloaded)

That explains why when I see "fetched # kB" in an update, I do not see it reflected at the screen bottom
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

THat is only actual UPDATES that will be listed there. Is that correct ?
Now I understand that !

If in the future I post something, and there is no feedback, or I do not understand what a person replies, is it possible I could message you somehow through this platform? If you are okay with that, how would I do that ?

THanks sooo much !
Maggie

Hey Maggie - glad that helped. You'll usually get a lot of useful responses from members here, many with much more experience than me. However, feel free to message me anytime - you just click on my user name and choose private message. I will add you to my contacts.

Cheers,

Rick

PsychoHermit 10-12-2021 06:31 PM

Hi Maggie,

Let's try it again. To post something and preserve the formatting you have to use the code tags. I'm substituting {} for [] because using [] would not be visible to you. It would interpret the code tags and make a code block.

{code}
Pasted terminal output.
{/code}

To copy and paste terminal output into your browser you highlight the terminal output with your mouse and then go to your browser and click the middle mouse button. Saves a lot of typing. Update is a script on my machine that does
Code:

sudo apt-get update && sudo apt-get upgrade
Pasted from a terminal session.

Code:

glenn@PsychoBox:~$ update
Hit:1 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:2 http://us.archive.ubuntu.com/ubuntu focal InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:4 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease
Reading package lists... Done
Building dependency tree     
Reading state information... Done
All packages are up to date.
Reading package lists... Done
Building dependency tree     
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Hopefully this made sense, it will save you a lot of typing.

--glenn


All times are GMT -5. The time now is 04:45 AM.