i need your help very much. I have debian 10 server with 2 users: root and user (added to sudo group). I use user account with RDP, and 'sudo' command always worked well.

The problem started when I tried to do (from user account):

$ echo 'deb http://ftp.de.debian.org/debian bookworm main' >> /etc/apt/sources.list

There was some errors about libcrypt and I tried something like that (dont remember exactly):

$ sudo echo 'deb http://ftp.de.debian.org/debian bookworm main' >> sudo /etc/apt/sources.list

I think the problem, that I echoed something to 'sudo'? I`m no very familiar with linux, I googled few days, but I cant solve the problem. Most command with sudo i receive this output instantly, without giving me a promt for password:

$ sudo whoami
Sorry, try again.
Sorry, try again.
sudo: 3 incorrect password attempts

If I try:

$ cat /etc/sudoers
cat: /etc/sudoers: Permission denied

Every command with sudo access denied. I cant change config files, that I googled about. So I only have access to user account through RDP, and if I try without sudo i receive:

$ apt 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)

Please help me to understand the problem and to fix it.

  • You may have locked yourself out of using sudo. What does faillock return? Jan 7 at 20:08
  • Btw, all of the commands you tried without sudo are failing by design (root-only permissions). Jan 7 at 20:14
  • ajgring619: $ faillock bash: faillock: command not found
    – Daniel
    Jan 7 at 20:19
  • ajgring619: also I know my root password, but i cant ssh or rdp to root account and something like - $ echo -n 'password' | sudo -S -k --- gives error of 3 failed login attemps, like I describe in the post.
    – Daniel
    Jan 7 at 20:26
  • 1
    ssh to your user account, then run su - to get a root prompt. Jan 7 at 20:50

1 Answer 1


Adding the bookworm (= will be Debian 12 once it's released) repository to Debian 10 would have been a bad idea, since you can't skip over releases when upgrading: you must first upgrade to Debian 11 "bullseye" before going for "bookworm".

Fortunately your first attempt (without sudo) would have failed because /etc/apt/sources.list requires root access to write.

Your remembered version of the second command should not have caused any major problems either, assuming that you were not already root and in /usr/bin when executing it.

sudo echo 'deb http://ftp.de.debian.org/debian bookworm main' >> sudo /etc/apt/sources.list

This command actually means "use root privileges to write the text in single quotes to standard output, then (as a regular user) append it to a file named "sudo" in the current directory (creating the file if it doesn't exist). So this should not have caused any major harm either, unless your memory was wrong.

Without (successfully) using sudo or otherwise having root access, you won't be able to use apt or other package management commands, as those require root privileges to work.

I would suggest checking several things:

What is the actual status of /etc/apt/sources.list?

Run less /etc/apt/sources.list to view it. You should be able to do it as a regular user without any special permissions.

What did you actually do?

Use the history command to view the command history, instead of relying on your memory.

What is happening now?

You could run type sudo to see what is actually being run when you use the sudo command. Normally it should respond with:

sudo is /usr/bin/sudo

or perhaps

sudo is hashed (/usr/bin/sudo)

If it tells you something different, you either have something non-standard named sudo in your $PATH before the /usr/bin directory, or you have managed to define a shell alias or function with the name sudo and it is getting executed instead of the real sudo command.

If that is the problem, you should be able to use the real sudo command by specifying it by full path, i.e. /usr/bin/sudo instead of just sudo.

It looks like you managed to add bookworm repository to /etc/apt/sources.list. If you also have unattended-upgrades package installed, the system may have begun attempting to upgrade itself from Debian 10 "buster" straight to "bookworm" (future Debian 12, still in testing phase), skipping over Debian 11... which is not going to work.

By trying to install python3-dev, python3.10-dev, libpython3.10, libpython3.10-dev and python3.10 after adding bookworm repository you may also have caused a dependency cascade which triggered an upgrade of many (but not all) system libraries.

Effectively, you may have made a FrankenDebian: a freakish combination of packages from different releases that were never promised to work together.

/var/log/dpkg.log is a low-level package management log that should record all recent package management operations, whether manual or automatic. It should be readable by a regular user. Do you see anything recorded in there at about the time the problem started?

Each line should begin with a timestamp, followed by a word that describes the particular action. The interesting lines should have the action word as install, upgrade, remove and/or purge.

After the action word, there should be the package name, then old version (or <none> if not applicable) and a new version (or <none>).

If you take the lines with timestamps after adding the bookworm repository (check the modification time of /etc/apt/sources.list), these lines should tell you exactly which packages have been replaced, most likely with corresponding packages from bookworm.

Unfortunately, since you apparently have only RDP access to the system, gaining root access and downgrading the packages back to buster-appropriate versions might not be possible to you without help from someone who can access the bootloader of the system.

To recover, it might be necessary to boot the system to rescue mode from an external media, then activate network interfaces and chroot into the damaged system as root. Then it should be possible to downgrade the mis-upgraded packages, by reversing the install/update/remove actions listed in the /var/log/dpkg.log file at or after the point of you adding the bookworm repository.

  • thank you for such a detailed answer! the status of sources.list is : deb http://deb.debian.org/debian/ buster main deb-src http://deb.debian.org/debian/ buster main deb http://security.debian.org/debian-security buster/updates main contrib deb-src http://security.debian.org/debian-security buster/updates main contrib deb http://deb.debian.org/debian/ buster-updates main contrib deb-src http://deb.debian.org/debian/ buster-updates main contrib deb http://ftp.de.debian.org/debian bookworm main
    – Daniel
    Jan 8 at 0:03
  • 1
    ajgringo619 says that maybe it something with PAM, i found in history that i opened (and i think redacted) this file - /etc/pam.d/sudo the content of this file at the moment is: #%PAM-1.0 @include common-auth @include common-account @include common-session-noninteractive
    – Daniel
    Jan 8 at 0:04
  • there is a limit of chrachters, so i will try to show you the output with the pastebin - pastebin.com/LzFnLUrf
    – Daniel
    Jan 8 at 0:08
  • type sudo - give output sudo is hashed (/usr/bin/sudo) /usr/bin/sudo apt update Sorry, try again. Sorry, try again. sudo: 3 incorrect password attempts - without giving password promt.
    – Daniel
    Jan 8 at 0:10
  • output of /var/log/dpkg.log is also huge, and unfortunately i dont understand a most part of it. If i understand correctly, iv managed to add bookworm to sources, maybe this is the main problem? Also, the output of `type sudo' is not exactly what it should be.Once again thank you for such a great answer and i hope you will be able help me to solve this problem from hell
    – Daniel
    Jan 8 at 0:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .