Command-not-found in Debian

I wrote this up years ago, but with the demise of CrunchBang those bits are rotting away. The URL is still good, but my post is mostly gone. I just installed Debian Stretch on my Mom’s old MacBook and the issue is still there, so here it is again.

If you invoke a command that doesn’t exist, most shells will simply tell you so.

$ play
play: command not found

Ubuntu has a utility called command-not-found. If you invoke a command that is not installed, but is available, it will tell you how to install it.

$ play
The program 'play' is currently not installed. You can install it by typing:
sudo apt install play

Nice!

This command is now available in other Debian systems too, including the latest stable: stretch.

sudo apt install command-not-found
sudo apt update
sudo update-command-not-found

But it doesn’t quite work right, as is.

$ play
The program 'play' is currently not installed. To run 'play'
please ask your administrator to install package 'play'

But I am the administrator! Why doesn’t it think so? It seems that Ubuntu uses different groups than Debian. In particular, command-not-found is looking for membership in group “admin”, but Debian doesn’t use that. We want it to check for membership in group “sudo” instead. We can fix that!

sudoedit /usr/share/command-not-found/CommandNotFound/CommandNotFound.py
# change "admin" to "sudo" on line 93

Most programs transition from Debian to Ubuntu. This one transitioned the other way. I guess the trip isn’t as smooth, since this was years ago and it’s still not fixed (indeed, it’s still line 93). I think this affects at least Debian wheezy, jessie, and stretch. It looks like it’s fixed on github and in Ubuntu (checks for either “admin” or “sudo”), but has not been backported to Debian yet.

Advertisements
Command-not-found in Debian

Hello, PowerShell!

Last week, while I was at Abstractions, I heard that PowerShell for Linux was released. Today, I tried it out!

My desktop machine at home is currently running Xubuntu 16.04.1, which is one of the platforms already packaged up. I downloaded the .deb, checked its sum

$ sha256sum Downloads/powershell_6.0.0-alpha.9-1ubuntu1.16.04.1_amd64.deb 
5d56a0419c23ce879dd4ddaca009f03e888355fccc9eecf882b64d63da5f38e3 Downloads/powershell_6.0.0-alpha.9-1ubuntu1.16.04.1_amd64.deb

and followed their instructions. I already had the two dependencies, so

$ sudo apt install libunwind8 libicu55

had no effect. Installing their deb

$ sudo dpkg -i ~/Downloads/powershell_6.0.0-alpha.9-1ubuntu1.16.04.1_amd64.deb

gave me a powershell executable.

$ which powershell
/usr/bin/powershell

Writing a quick hello world in PowerShell with that as the shebang line

#!/usr/bin/powershell

$name = $args[0]
if (!$name) {
    $name = "World"
}

write-host "Hello, $name!"

worked great!

$ ./hello.ps1
Hello, World!

$ ./hello.ps1  foo
Hello, foo!

Okay, how about those regexes with multiple named captures I talked about a while back? If we write this in multicapture.ps1

#!/usr/bin/powershell

$string = 'foo bar baz'
$pat = [regex] "(?:(?<word>\w+)\W*)+"
$m = $pat.match($string)
$m.groups["word"].captures | %{$_.value}

then lo and behold we get

$ ./multicapture.ps1 
foo
bar
baz

Now that I don’t have to boot Windows to do it, I might play with PowerShell a lot more! Thanks, Microsoft!

Hello, PowerShell!

Hello, Stretch!

This weekend I installed Debian 9 (stretch) on my little blue netbook. I love it!

pic of netbook

It has breathed new life into this tired little soldier. I bought this netbook a little over five years ago because I was sick of lugging around the 15 inch laptop (pictured with it) at conferences and whatnot. I had just gone to a conference with my friend Nate, who had a little netbook with a 10 inch screen, when I spotted this little blue guy for like 250 bones. Sold!

I currently also have a 17 inch laptop (Diana’s old one) with Debian 8 (jessie) installed on it and that’s perhaps the nicest operating system I’ve ever used. Until now. Stretch has several nice improvements over jessie.

First, wifi. Getting wifi working remains a bit of a challenge in Linux. When I installed jessie, I did the whole install from CD. Then I hooked up the ethernet cable to get internet access so that I could enable the non-free repository and install the driver I needed for wifi. Only then could I disconnect the ethernet and use the wifi. When I installed stretch, I started the install from a thumb drive (the netbook has no CD) and it stopped me and said I needed non-free driver rtlwifi/rtl8192cfw.bin for wifi and if I had the removable media with it to insert it now. So I went to another computer and grabbed that file off the internet, wrote it to another thumb drive, inserted that into the netbook, and hit “yes”. Voila! I did the rest of the install with wifi— no ethernet required! This seems like a really nice compromise between Debian not wanting to include non-free software and the rest of us wanting to use our wifi. It’s a win-win!

Second, sudo. When I installed jessie, I had a root user and made user tim a sudoer later. After that, I never really used the root account again. When I installed stretch, I made user tim a sudoer just by leaving the root password blank. There is no root account and tim has admin priviledges. Done and done.

Third, perl6. On my jessie box, I did the whole rakudobrew thing. In stretch, there’s a recent version of rakudo all packaged up!

sudo apt install rakudo

Done! Wow!

tim@zog:~$ which perl6
/usr/bin/perl6
tim@zog:~$ perl6 -v
This is Rakudo version 2016.04 built on MoarVM version 2016.04
implementing Perl 6.c.

This is the computer I’ll be taking to YAPC::NA next month, so I had to have that installed. I’ll be taking Damian’s Perl 6 class on Sunday.

Fourth, the printer. In jessie, I had to do a little research to determine that I needed to install system-config-printer and then use it to install my printer. In stretch, this was already there and “Settings -> Print Settings -> Add -> Network Printer” was all it took to discover my wireless printer and to correctly guess and install the driver for it.

During the stretch install, the touchpad of the netbook didn’t work. I was all set to research drivers or something for it, but upon booting the system, the touchpad worked. Still not sure why it didn’t work during the install.

The command-not-found utility still doesn’t work, but just installing it and then changing admin to sudo still fixes it.

I am still tinkering, but I can already tell I’m going to love stretch! I was toying with the idea of getting a fancy new laptop, but now I think I will keep using this little blue netbook for a while longer.

Shiny new 4.5 kernel!

pic of desktop with uname

Hello, Stretch!