Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Wednesday, September 5, 2018

Updating the Ubuntu installation in Bash on Ubuntu on Windows

Recently I had some trouble installing a package inside the Bash on Ubuntu on Windows environment. I found that I needed to update my Ubuntu distribution. As I read in this Super User answer, that can be accomplished with:

sudo do-release-upgrade -d

In the process, there will probably be some prompts about replacing altered configuration files. I found that choosing any option other than a simple yes or no (the ones that let you explore the differences between the two config versions) makes it extremely easy to get stuck and unintentionally terminate the whole procedure. When I accidentally did that, I found that just running the upgrade command again mostly picked up from where it left off.

Monday, July 16, 2018

Using an existing CSR in Let's Encrypt

I recently needed to get an SSL certificate for a site whose hosting provider generates the CSR. I use Let's Encrypt to get free SSL certificates. I was happy to find that the Certbot client is easily able to request certificates based on a CSR:

certbot certonly -d example.com --csr /path/to/file.csr

Wednesday, May 3, 2017

Not all of PowerShell works on Linux

As great as it is that PowerShell has a Linux version, not all features are there quite yet. There are two major classes of things that are only supported on Windows:

  • Types provided by unmanaged libraries, especially COM. The ParsedHtml property on the objects returned by Invoke-WebRequest, for example, is of a COM class provided by mshtml.dll - an Internet Explorer component. Since that functionality has not been ported, that property is null on other platforms.
  • Cmdlets to manage Windows-only systems. Linux doesn't have the Windows concept of Modern apps, so all the Appx-related cmdlets aren't there. Similarly, Linux PowerShell is missing cmdlets for Hyper-V, Windows Firewall, and so on.
Though lots of things do work perfectly fine on any platform, it's advisable to test a script on at least one non-Windows OS. I find Bash on Ubuntu on Windows a convenient way of doing that - installing PowerShell in there is just the same as on a real Ubuntu machine.

Friday, November 25, 2016

A guide to installing Abiathar on Ubuntu 14.04

Last time I tried Ubuntu, I never got anything interesting running on it. Today I tried again, and after a ton of fiddling I managed to get Abiathar running on it. Note that I barely know anything about Linux and I'm just compiling a bunch of instructions into one place.

First, you'll need to download the update client (EXE link), which fetches the newest version. Your Downloads folder is a good place for that. Fire up a Terminal and navigate to wherever you put it. Mark it executable with chmod +x AbiatharUpdater.exe.

Now you need Mono, which is like .NET for Linux. Open the Ubuntu Software Center application, then find and install the Mono Runtime (searching for "mono" should pull it up). You need some extra packages:

sudo apt-get install mono-vbnc
sudo apt-get install mono-devel

Unfortunately, those don't include the SSL certificates that Mono needs to fetch HTTPS files, and mozroots is no more, so we need to add another repository?
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update
sudo apt-get install ca-certificates-mono

For reasons unknown, installing that last certificates package takes a really long time and pokes at a bunch of other packages. Once it's done, you can finally run the Abiathar updater.

mono AbiatharUpdater.exe

If everything goes well, it will download three files. It fails with "The method or operation is not supported" at the very end, but that's OK; it was trying to launch Abiathar using a Windows function that doesn't exist on Linux.

OK, now we need WINE, which is a Windows emulator. (Abiathar needs a UI, which means window handles and stuff that isn't .NET, so just Mono won't do it.) Before we do that, mark Abiathar executable with chmod +x Abiathar.exe.

sudo apt-get install wine
sudo apt-add-repository ppa:wine/wine-builds
sudo apt-get update
sudo apt-get install winehq-staging

That installs the normal WINE package, then it gets the staging (development) branch, which has features we need. Now we need to configure stuff to get the .NET framework running inside WINE.

rm -rf ~/.wine
export WINEARCH=win32
export WINEPREFIX="/home/USER/.wine"
winecfg

Replace "USER" with your home folder's name. The last command produces a GUI configuration utility. While it's loading, it might ask to install some things; install them. Once the dialog comes up, change the Windows version dropdown to Windows 7, then OK out. Now we need extra WINE-related utilities to get .NET.
mkdir Winetricks
cd Winetricks
wget -r -c -N https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks

That downloads a script from the Winetricks GitHub repository. cd down through all the new folders.

chmod +x winetricks
sh winetricks

When you get a GUI, choose to "Select the default wineprefix", then choose "Install a Windows DLL or component." Scroll through the list and find dotnet40. It'll warn you about lacking support, but that's OK. Soon, you'll get the normal .NET 4 installer. Go through it as usual, and once done, cancel out of Winetricks.

Finally, cd back to where you put Abiathar, and run it.

wine Abiathar.exe

Abiathar running on Ubuntu

Saturday, August 27, 2016

Running PowerShell on Ubuntu

A while ago, Microsoft open-sourced PowerShell and made it cross-platform. You can download the appropriate installation package on the Releases page of that GitHub repository. For instance, if you want to install it on Ubuntu 14.04, you would download the DEB file and run these commands:

sudo apt-get install libunwind8 libicu52
sudo dpkg -i powershell_6.0.0-alpha.9-1ubuntu1.14.04.1_amd64.deb

Oh, and in case you're wondering, you can totally run it in Bash on Ubuntu on Windows 10.

It's a little confused about the cursor position, but it runs!

Wednesday, July 20, 2016

I set up phpBB3 on Ubuntu Server

I agreed to put together a quick web forum for a group in which I participate, and I figured that phpBB3 would be a safe choice. Since PHP is (in my understanding) usually run on Linux platforms, I decided to try Ubuntu again, despite my previous problems with it. This time, though, I went with Ubuntu Server. I'll note that Ubuntu Server doesn't have a GUI (by default), so everything I did was from the command line.

Starting fresh, I grabbed the official Ubuntu Server 16 ISO from the official web site and put it in a Generation 1 Hyper-V machine with 512 MB of RAM. Setup went smoothly; the pseudo-GUI guided me through the whole process. It gave me a list of optional features to install, and since I was going to need a web stack, I chose to add LAMP. When the system came online, I updated all the things that wanted it. To set a static IP, I used nano to adjust some config file somewhere, and then I just rebooted. Nano is a very easy-to-use text editor, though I couldn't figure out how to select anything for copy/pasting.

Installing phpBB3 was as simple as sudo apt-get install phpbb3. It asked me for some configuration, I provided it, and it installed. I then deviated slightly from the instructions to make phpBB accessible from the root of my website rather than a subdirectory, and then everything went south. Neither the intended path nor the root path worked from a web browser, and browsing to things that should have been there produced permission errors. I did manage to bump into a phpBB component, but it threw an error about not having mysql_connect. I tried various things, but probably only broke it more.

So I uninstalled and reinstalled phpBB3. That might have been a little much, since I think I had only messed up its registration with Apache. I followed the instructions to the letter this time, but still got the MySQL error. Some Googling determined that the function it's trying to use is so deprecated as to be completely gone. I had to hunt down yet another textual configuration file and set the database provider to a more modern one. That worked, and I got to use a web browser to configure phpBB as I wanted.

When I tried to register a new user, though, I got a 500 server error. When I finally found a relevant log file with useful errors (which was difficult given my lack of Linux command line experience), I saw that there was a PHP syntax issue in the captcha module. Since I'll be manually approving new members anyway, I just disabled anti-spam features in the phpBB web controls, and that fixed the problem.

And with that, I had a working phpBB forum. (Well, I jumped through some hoops splitting a PFX certificate into CER and KEY and getting Apache to serve my site using it, a procedure which also happened to remove the extra subdirectory in web paths. Hooray!) All in all, I was moderately inconvenienced in that I had to finagle stuff to work around phpBB problems, but at least this episode of Linux adventuring ended well.

Wednesday, November 11, 2015

My Linux Saga: A Drama in Four Acts

A couple days ago, I figured I would give Linux a go. Several people I know love the whole open-source philosophy and therefore Linux, but I was primarily interested in producing a set of steps with which Abiathar can be installed on a Linux machine. Prior to this experience, I had used Linux about five times, and never in a serious capacity.

I tell the story in present tense for dramatic effect.

Act I: Hardware


I happen to have an Ubuntu GNOME 14.04 installation ISO laying around my drive for some reason, so I'll go with that. I'm not super interested in blowing away any real machines for this experiment, so virtualization it is. I've had success with VirtualBox, so we'll start with that. I create a new VM, give it 2GB of RAM, a single CPU, a 30GB SATA hard drive, and a DVD drive for the ISO. 

I turn it on and a purple-ish screen appears with a little keyboard and a person-looking logo thing at the bottom. Keyboard equals happy man? I think I'll start with the GUI, thanks, so I press nothing. A text screen appears with some dots that animate between blue and white. I wait a while and am rewarded for my patience with an error message about intel_rapl.

Welcome to Linux?

I wait a couple seconds, try pressing some buttons, try Ctrl+Alt+Delete, and nothing happens. I try a reset and get the same thing.

Fast-forward through thirty minutes of fiddling with hardware settings in VirtualBox, most of which either produced the same error or something else that sounds bad. I also try upgrading VirtualBox to the newest version, which gives me more buttons to press, but none of them help. So I abandon VirtualBox and try Microsoft Hyper-V, which I have used successfully exactly once. Does Hyper-V even work with non-Windows OSes? Beats me.

This should be good.

I create a new VM with similar specs. There doesn't appear to be a way to insert a SATA controller in Generation 1 Hyper-V machines, so IDE it is. I start the VM, connect to it with the Virtual Machine Connection, and receive the same error. Huh. Some Googling told me that the message is actually non-obstructive (read: spurious) despite how scary it looks. Perhaps VirtualBox would have worked after all. Oh well, we're with Hyper-V now.

After waiting several minutes, I receive a textured background and a setup utility-ish UI thing that tells me I should have an Internet connection for best results. Whoops, I forgot to install a network adapter. So I do that, and reboot the VM.

Act II: Setup


Both recommendation lights are green in the setup-starting dialog. Let's do this!

Setup asks me for a username, a password, and a computer name. Interestingly, after I fill in my username, it appends "-Virtual-Machine" to it for the computer name. I change the name to something more creative, like linuxvm. It thinks my password is weak, but I don't care, and it seems to be OK with that.

There is then a checkbox that allows the installation of proprietary components (some media player or codec or something). It is cleared by default. Heaven forfend there be non-open-source software on my machine! I check the box. Viva closed-source.

I start the installation. A progress bar dialog appears, spewing a bunch of piped text into the details box that I expanded for curiosity's sake. Hard drive activity is solid for quite a few minutes, and eventually I am presented with a logon screen. I type my password, press Enter, and receive what I believe to be a desktop. It is blank save for a black menu-bar thing at the top (which contains a single full word, "Activities") and a neat background in the main area.

Act III: Upgrades


At this point I am still feeling good about achieving my goal of running .NET software on Linux. The only thing I know is that sudo apt-get installs stuff, but I'm sure Google will help me figure out what stuff I need to install and what other line noise I need to put on a command line. Before I do that, though, I download the .NET software I would like to run and try double-clicking it for laughs. As expected, it doesn't work - Archive Manager attempts to open it, but fails, which makes sense considering that EXEs aren't archives.

Sometime during that experiment a Software Updater message made an appearance, so I figure I might as well make sure I'm running the most up-to-date version of everything before I begin in earnest. I press the Update button, and it prompts me for my password. I provide it, but I have no idea how to verify whether the prompt is legit. Good thing I'm not running any unvetted software yet.

Another progress bar appears, so I wait a while, then get some water, and when I come back the desktop has locked itself. Security is nice. I am pleased. I enter my password and press Enter to unlock. The UI clears the password box and does nothing else. I am not pleased. I try several more times, and receive nothing but a cleared text field. Deliberately entering the password wrong does produce a suitable message. There's a little link to log in as a different user - there are no other users, unless you count root - which I press. I get a list of users, which contains only me. I click me, and enter my password. It unlocks. Huh.

When the updater is done, Ubuntu tells me I should reboot. (See, even Linux needs to restart after important operations!) I do so using the little power icon in the upper-right of the desktop.

When the system comes back up, I get a kernel panic.

I stress that I have done essentially nothing to my system other than updating, much less anything questionable/unsupported. I haven't even opened Terminal yet! All I did was do what the GUI wanted me to.

I Google up some instructions to fix this. There is a boot menu that appears before GNOME (the desktop, I suppose) that contains an entry with "advanced options." The resulting advanced menu lets me boot from the old version. Neat! Everything is good.

While I was waiting for the Software Updater, I discovered on the Internet that there is a new Ubuntu version, Ubuntu 15. I figure now is a good a time as ever to upgrade to that, hopefully skipping all incremental "updates." Following some instructions, I change a line in a config file using an elevated (sudo'd) instance of gedit and then run a command to do the update. A bunch of stuff downloads and lots of text comes flying down the terminal.

In the middle of all that, a message box appears informing me that do-release-upgrade has encountered a problem and needs to close. I choose to send the error report, and it sends, but the text spew continues, as does hard drive activity. I let it run to completion, at which point it tells me that some errors occurred during the upgrade, but it seems that the errors only have to do with fontconfig, which can't be too critical, right?

I use the GUI to restart, but the system hangs in text mode at "Waiting for processes to terminate." I wait a good long while, but it stays there, with 0% CPU utilization (as reported by Hyper-V) and no visible disk usage. I cut the virtual power.

When the system comes back up, I get another kernel panic. I try the old version. Kernel panic. I try the recovery mode. Kernel panic. I give up and erase the virtual hard drive.

Act IV: Fresh start


Maybe things will work better if I'm on version 15 from the start. I download an ISO from the Ubuntu web site and put it in Hyper-V in a machine with the same specs. The purple screen and intel_rapl message appear again, followed by a black screen with a flashing text-mode cursor. Not good.

I reset. Wanting to be a happy man, I use my keyboard when indicated and fiddle around with some advanced settings in accordance with some other instructions I found somewhere. The black screen continues no matter what settings I choose or how long I wait. I am not a happy man, and my keyboard does nothing helpful.

I try the same in VirtualBox and experience the same failure.

Epilogue


I give up.

I tried, I really did. I wanted to like Linux, but I can't like something that I just can't make work. Maybe I picked a bad distro. Maybe there's something up with these hypervisors. Who knows.

Windows it is. 

Tuesday, November 10, 2015

Tips for Running Ubuntu Linux Under Hyper-V

Just today I got an Ubuntu installation running under Microsoft Hyper-V, and along the way I discovered some tips that may be helpful to others:

  • The VM, for easiest setup, should be Generation 1. (This option only appears on the Windows 8 or newer edition of Hyper-V. Don't worry about it if you don't see anything about generations.)
  • The hard drive image should be presented to the VM as a SATA or IDE drive. Bizarre error messages will result if you try to present it as SCSI.
  • There will be error-looking messages about intel_rapl, both in setup and during normal boot. They appear to not matter. Just wait while the message is on the screen during setup; the process will continue normally.
  • If there's a kernel panic, the Caps Lock and Scroll Lock lights will blink rapidly and will not return to their original states even after you click out of the Hyper-V Virtual Machine Connection window.
  • There are Integration Services for several Linux distributions, including Ubuntu, which allow dynamic resizing of the view window, among other things.