7

While is was installing something with the sudo apt-get install command I accidentally accepted the command

sudo apt-get install python3-

(yeah I know it is stupid to just accept this but I did a lot of those and i just continued to click y).

By executing the command I deleted my whole visual desktop of Ubuntu (I just had the plain shell but I recovered the visual desktop by now). I don't know if I am just stupid but nevertheless I want to create awareness that you shouldn't use the command.

If you can explain to me why happened what happened feel free to explain it to me.

3
  • 8
    Documented features are not bugs.
    – guiverc
    Apr 7, 2019 at 22:24
  • 3
    I’m curious -why- this was decided to be the intended behavior. Seems unnecessary, and as the OP found, destructive.
    – Scot
    Apr 8, 2019 at 4:48
  • 1
    @Scot I agree with you. Since there is already a dedicated command to remove packages I don't see the need for this feature. Seems like somebody wanted to include a "pro feature" that hurts new users and provides basically 0 value... The only case in which it would be useful is when you want to remove a package but your hand types install anyway and you realize at the end... but does this happen often enough to justify this feature? I don't think so. Apr 8, 2019 at 6:11

2 Answers 2

22

This is not a bug; this is documented in the man page. From man apt-get's install section1 (emphasis mine):

If a hyphen is appended to the package name (with no intervening space), the identified package will be removed if it is installed. Similarly a plus sign can be used to designate a package to install.

So, when you did:

sudo apt-get install python3-

you've removed the python3 package and all the dependent packages (which includes the packages you mentioned).


Fix:

Firstly, you can install the ubuntu-desktop metapackage to get the default desktop environment back:

sudo apt-get install ubuntu-desktop

Now, to re-install the removed packages, go to /var/log/apt/history.log, pick the packages, and run sudo apt-get install on them.

You might also want to peek into /var/log/dpkg.log.


1 If you have less as the man pager, you can go to the install section of man apt-get directly:

LESS='+/^[[:blank:]]+install' man apt-get
2
  • 6
    It might be worth mentioning that sudo apt-get install ubuntu-desktop will get most of the desktop environment back with a single command, without needing to hunt down individual package names. (Of course that doesn't cover whatever one has installed manually on top of the defaults, but further recovery can proceed in an environment that may be more familiar than the Linux console). Apr 7, 2019 at 22:21
  • @HenningMakholm Makes sense; edited.
    – heemayl
    Apr 8, 2019 at 6:27
11

No, you didn't find a bug. From man apt-get:

If a hyphen is appended to the package name (with no intervening space), the identified package will be removed if it is installed. Similarly a plus sign can be used to designate a package to install. These latter features may be used to override decisions made by apt-get's conflict resolution system.

It's intentional. I'm not sure it's good design, but it is worth reading what changes apt proposes before proceeding.

Combined with globbing it may produce some rather... spectacular results at times.

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