No sandbox user '_apt' on the system, can not drop privileges

26,341

Solution 1

Add the _apt user back to /etc/passwd and /etc/shadow:

$ sudo grep _apt /etc/passwd /etc/shadow
/etc/passwd:_apt:x:168:65534::/nonexistent:/bin/false
/etc/shadow:_apt:*:17121:0:99999:7:::

YMMV: The _apt UID on my system is 168, and yours may not be 168 on your system - the value should be unique, and greater than 100.

Solution 2

You can re-create the _apt user by using the following command:

sudo adduser _apt --force-badname

It doesn't matter what you put for the password or any other fields.

Then, apt will continue to work as normal.

Share:
26,341

Related videos on Youtube

E.A
Author by

E.A

love embedded system and C ;

Updated on September 18, 2022

Comments

  • E.A
    E.A over 1 year

    I removed the _apt user by accident, and every time I update the software, I get this message: No sandbox user '_apt' on the system, can not drop privileges. How can I solve this problem ?

    • Thomas Ward
      Thomas Ward about 7 years
      Just an FYI: You don't actually need to worry about those warnings, in the long term, _apt is just used in sandboxes for building and such; what you're seeing is just a warning and not an actual error, everything should work fine as-is. (I get the same exact message in my older sbuild chroots where I build Ubuntu packaging, when the system didn't have the _apt user by default, even though my system is 16.04.)
  • E.A
    E.A over 7 years
    can you type specific steps
  • E.A
    E.A over 7 years
    I suspect the existence of the users in my terminal after writing compgen -u then i decided to remove them and i removed _apt and this problem show up
  • BrianBlaze
    BrianBlaze about 5 years
    awesome, just by creating the user, it fixed this issue.
  • hackerb9
    hackerb9 about 3 years
    I like that you gave an answer with a simple cut and paste command to solve the problem. However, you may wish to improve the answer as currently you are creating a normal user named _apt which is allowed to log in to your system. For example, I would suggest something like this: sudo adduser --force-badname --system --no-create-home _apt