4

I did a sudo apt-get remove ruby* and then I saw that some grub packages were being removed too so I went to installed back those packages which log showed to have removed

I set grub to work on my /sda (in general, not any number) when was installing back.

Should all be ok or should I fear for my system and plan installing/reconfiguring more of grub.

And, why did this happpen?

Braiam
  • 66,947
  • 30
  • 177
  • 264
diegoaguilar
  • 195
  • 1
  • 1
  • 11
  • 2
    Apt-get works with regular expressions, which means that `ruby*` selects all packages that contain _rub_ in their name. The correct way to remove all packages starting with _ruby_ is: `apt-get remove ^ruby`. – Andrea Corbellini Mar 09 '14 at 17:08
  • Related: [How to fix Ubuntu after accidentally uninstalling many packages?](https://askubuntu.com/questions/249367/how-to-fix-ubuntu-after-accidentally-uninstalling-many-packages) – Eliah Kagan Aug 23 '17 at 19:23

3 Answers3

8

If you don't know exactly what you are doing, you should not use:

sudo apt-get remove package.*
#                          ⤷ or any other character in the place of dot

as this can delete unintended packages and cause more problems than it solves. The package.* will match all packages (and their dependencies) containing the string package in their name. This is from man apt-get, somewhere at the line 110:

       If no package matches the given expression and the expression
       contains one of '.', '?' or '*' then it is assumed to be a POSIX
       regular expression, and it is applied to all package names in the
       database. Any matches are then installed (or removed). Note that
       matching is done by substring so 'lo.*' matches 'how-lo' and
       'lowest'. If this is undesired, anchor the regular expression with
       a '^' or '$' character, or create a more specific regular
       expression.

And this is from Regular Expressions/POSIX Basic Regular Expressions Wikibooks:

* Matches the preceding element zero or more times. For example, ab*c matches "ac", "abc", "abbbc", etc. [xyz]* matches "", "x", "y", "z", "zx", "zyx", "xyzzy", and so on. \(ab\)* matches "", "ab", "abab", "ababab", and so on.

Anyway, if you really want to run something like sudo apt-get remove package.* (or sudo apt-get remove packagey*, or sudo apt-get remove packagec* - all are in this case the same), first run it with -s (--simulate) option to see exactly what it will do (see man apt-get for more info).

Now, I think that you can solve your problem using the following two steps:

  1. Reinstall all the packages that you have removed

  2. Remove only ruby:

    sudo apt-get remove ruby
    

    Or, if you want to remove all packages starting their names with ruby:

    sudo apt-get remove ^ruby
    

    But better to simulate first with:

    apt-get -s remove ^ruby
    
Radu Rădeanu
  • 166,822
  • 48
  • 327
  • 400
4

Apt-get works with regular expressions, which means that ruby* selects all packages that contain rub in their name. The correct way to remove all packages starting with ruby is:

apt-get remove ^ruby
Andrea Corbellini
  • 15,616
  • 2
  • 64
  • 81
2

Try this command on terminal,

sudo grub-install /dev/sda

It will reinstall grub2 on your disk.

If you want to configure your grub then install grub-pc package.Try the below command to install grub-pc package,

sudo apt-get install grub-pc

Note: Install this package only if you installed Ubuntu in Legacy mode.

Avinash Raj
  • 77,204
  • 56
  • 214
  • 254
  • Even if I already did some other grub packages install (same which were removed)? – diegoaguilar Mar 09 '14 at 05:24
  • Are you installed Ubuntu in legacy mode?post the output of `[ -d /sys/firmware/efi ] && echo "EFI boot on HDD" || echo "Legacy boot on HDD"` command. – Avinash Raj Mar 09 '14 at 05:25
  • `Legacy boot on HDD` – diegoaguilar Mar 09 '14 at 05:27
  • 1
    Install `grub-pc` package to configure your grub.Run this command to install grub-pc package, `sudo apt-get install grub-pc` – Avinash Raj Mar 09 '14 at 05:28
  • 1
    I will do and trust, and by the way: Why would `sudo apt-get remove ruby*` end up removing grub packages? (I suggest you to post right on the answer) – diegoaguilar Mar 09 '14 at 05:31
  • @RaduRădeanu you answered for [this](http://askubuntu.com/questions/431604/why-does-apt-removes-unwanted-packages-when-giving-as-suffix/431605?noredirect=1#comment560377_431605) comment only, i think. – Avinash Raj Mar 09 '14 at 14:55
  • Don't step back Raj :P And btw it worked, thanks so much! – diegoaguilar Mar 09 '14 at 15:08
  • @diegoaguilar see [this](http://askubuntu.com/questions/431604/why-does-apt-removes-unwanted-packages-when-giving-as-suffix/431605?noredirect=1#comment560592_431605) comment.I don't know what to do. – Avinash Raj Mar 09 '14 at 15:10
  • let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/13475/discussion-between-diegoaguilar-and-avinash-raj) – diegoaguilar Mar 09 '14 at 15:31