Categories
geek linux microsoft programming software tips tools ubuntu windows

WSL setup, tips and tricks

WSL or Windows Subsystem for Linux allows you to run a fully functional Linux environment, inside your Windows 10 system, without having to set up a virtual machine. It’s a lot more lightweight too, and it integrates nicely with the Windows OS, so it’s a great way to explore Linux, or use the two systems side by side for cross-platform development. This also skips the need for setting up Cygwin and whatever hacky way to access those Linux command line tools on Windows.

I’ve been using it for a while, so I’ll list a short setup guide here, and some tips & tricks to help you along.

Installing WSL

Installing WSL is really easy now. Just open an administrator PowerShell or a Command window and type:

wsl --install

That will install WSL with the default Ubuntu distribution. If you prefer something else, like Debian, you can use this command:

wsl --install -d Debian

The username and password for your WSL system is specific to the Linux distribution. So make sure you don’t forget that password. :)

There are 2 versions of WSL. If you can, run on v2. It’s faster, better and euhm, harder? Anyway, it’s faster, so that’s what you want. But sometimes, you might want to run things on v1 anyway. For example, some VPN clients break with the WSL v2 networking. The easiest way is to set your WSL distro to v1, and see if that works. It did the trick in my case with the CheckPoint VPN on my work machine.

To check your WSL version, run:

wsl -l -v

It should show something like this, if you’re on Debian and v2

  NAME                   STATE           VERSION
* Debian                 Stopped         2

To switch the Debian distro to v1, you can run this:

wsl --set-version Debian 1

Makes sense right? But you just have to know.
Switching versions can take a while as it’s being converted, so do this when you have the time for it.

Accessing your files in WSL

Ok, now let’s do some work in WSL, by typing wsl in a PowerShell window.

That’s it, you now have a shell in your local WSL system.
You’ll see something like this on your prompt:

n3wjack@Mjolnir:/mnt/c/Users/n3wjack$

That’s a mount of your Windows C-drive into the Linux system. So you can access any file from your Windows system in your Linux shell. The other way around also works.

Open up an Explorer window and enter \\wsl$ in the address bar and hit return.
You’ll see a folder pop up for each WSL distribution you have installed. So if you’ve installed Debian, you’ll see a Debian folder. From there you can access any file on your WSL system.

Windows Explorere windows showing the Debian distribution folder under the \\wsl$ network drive.

Keep in mind that this cross OS file access is pretty slow, certainly for lots of small files. So if you are planning on working on files, it’s better to choose your OS and stick with it. But it’s super handy that you can easily copy and access files from any system.

Installing software in WSL

Well, this is easy. If you’ve installed Debian or Ubuntu, so you probably know you can install more software using apt or apt-get.
WSL pretty much behaves as it should, and you can just install whatever you like using known tools.
The account you created when setting up your distro is an administrator account, so you can use sudo commands.

Moving your WSL distro to a new PC

So you have your Linux distro all set up the way you want to, and now you’ve got yourself a brand new shiny piece of hardware to work and play on. How do you move that WSL distro over to the new machine?
Luckily, it’s as simple as backup and restore. Really. It’s actually easier than moving your Windows files over.

Creating a backup of WSL works like this:

wsl --export <distribution> <filename.tar>

So if you see that your distro is called Debian after running wsl -l -v, you do this:

wsl --export Debian debian.tar

This takes a while. After it’s done, you copy the tar file over to your new shiny machine and run the following command:

wsl --import <distribution name> <install path> <tar file path>

Or actually:


wsl --import Debian c:\users\YourName\AppData\Local\Packages\Debian c:\temp\debian.tar

That’s it! You now have your full distro moved to a new machine, including all settings and files.

For more info on WSL, see the excellent official Microsoft documentation.

Categories
geek linux society software ubuntu Uncategorized

fight corona with folding@home on a headless ubuntu linux box

I wrote about using Grid computing to fight cancer a while back using leftover Azure credits.
So now with Corona having the world in its grip, it’s time to shift our attention to that nasty virus and throw some CPU cycles at it instead.

If you have an Ubuntu machine running somewhere and you want to install the Folding@Home client on it, you can do so by following the simple steps listed below.

First download the FAH client application:

wget https://download.foldingathome.org/releases/public/release/fahclient/debian-testing-64bit/v7.4/fahclient_7.4.4_amd64.deb

Then, run the installer. It will guide you through the setup process.

sudo dpkg -i --force-depends fahclient_7.4.4_amd64.deb

Just choose a name and an optional team. You best let it start automatically as well.

That’s basically it. Since you’re running it all headless, there’s no need for any of the other packages listed on the site.

You can check if things are running by checking the log file stored in /var/lib/fahclient/log.txt

If you want to change the configuration after installing the client in /etc/fahclient/config.xml you have to start and stop the client like this:

sudo /etc/init.d/FAHClient stop
sudo /etc/init.d/FAHClient start

If you had the World Grid Computing client installed already, you can stop that by using:

sudo /etc/init.d/boinc-client stop

If you want to full install instructions for the FAHclient or installation instructions for other flavors of Linux, check out the official installation guide.
Once it’s running and processed a few work units, you can check your stats at this URL: https://stats.foldingathome.org/donor/yourname

Have fun kicking Corona ass!

Categories
geek linux microsoft opensource programming

why an open sourced .NET framework is huge

free

I was already excited about the recent ASP.NET vNext developments. Things like the fact that you can get the ASP.NET source code on Github, that it’s completely FOSS and that it’s disconnected from the rest of the .NET stack are just plain awesome.

A huge step for ASP.NET vNext is that you don’t need Visual Studio to write software with it. You can use your favourite text editor like Vim, Sublime, Emacs or whatever you like, together with a number of open source command line tools.

A second huge thing is that ASP.NET 5 can now run cross-platform using Mono on Linux and Mac. Not only can you use your development tools of choice to write and build your C# code, you can also do it on the OS of your choice. .NET everywhere. Think about it. *mind blown*

Yesterday however, things got even sweeter as Microsoft is now releasing more of the v5 .NET Framework as open source. This means more and easier cross-platform development and Mono compatibility (as the source can be easily integrated in Mono) for .NET code.

On top of that there is now a new Visual Studio Community edition of Visual Studio available for free. This is equal to the Pro version, so you can ditch those crippled free “Express” versions and write code in the tools you’re used to professionally. I love this one. I’ve messed around with SharpDevelop and the Express version, but if you’re used to the “real thing” it feels like having to work with your hands tied behind your back.

As if this wasn’t enough there’s a bunch of other cool improvements too, like getting only the .NET framework components you need for your project and pull them in using NuGet. Scott Hanselman sums them up nicely.

So if you’ve always wanted to check out .NET or C# but didn’t want to because you had to run it on Windows and in Visual Studio, there’s nothing holding you back any more. For .NET developers this is great. It gives us more freedom than ever without having to learn a new language and framework. For people hacking away on OS X and Ubuntu with Ruby, Python etc. because they want to use FOSS, this is an opportunity to dip into the wealth of .NET resources out there and try something new.

The strategy is clear. They want everyone to use the .NET framework, they want everybody to run that code on Azure (even if you’re not using .NET) and they see that making it open is the only way to get there. Great times are ahead.

Categories
geek linux opensource software windows

windows rescue kit on a usb stick

While cleaning up an old machine, I was first using CCleaner from Windows to wipe some partitions because DBAN crashed on it for some reason. To clean some of the Linux partitions on the drive which Windows can’t access, I dropped them, so I could re-add them as NTFS partitions for further wiping. Problem was I forgot those partitions were also hosting my master boot record, so when I rebooted to confirm my partition changes… I ended up with an unbootable system…

Oops.

Now I had to find a way to wipe those disks from Linux, but first I still wanted to get access to my WinXP setup. I could have just nuked it from orbit (read: boot from a Linux Live CD and shred it) but I was just wondering if I would manage to get it to boot again, just in case I do this on a system that really matters some day. So I started browsing to the ISO’s available on the Universal USB Boot installer and ran into the awesome Trinity Rescue Kit.

I installed it on a very small USB drive (265MB) I had lying around and managed to rewrite a Windows boot record with the tools supplied from the text-based menu. Nice! I also noticed that it has a bunch of disk rescue tools on board like a backup tool, full NTFS support, the Midnight Commander explorer for file recovery and a Windows password reset tool (hackedy-hack). On top of that, it also has a virus scanner on board, ways to set up network file shares and good, detailed documentation.

This distro is certainly one that is getting a nice spot on my PC CPR tool belt. Without exploring all the goodness Trinity has to offer, I’m sure it’s a huge time saver if you need to help out with an unbootable system or one seriously infected with trojans or virii. You can even use this to set up a headless file share server in no time if you want.

Good stuff.

Photo by lilbambi01, cc-licensed.

Categories
geek linux opensource security software

securely wiping your hard drive without dban

Technologic

Well if DBAN doesn’t cut it for some reason there’s always a more native Linux way to do this.

Step one is getting a Linux live CD, DVD or USB stick and boot from that. I used the Debian Live CD myself, which boots into character mode so you don’t end up with XServer not getting your video settings right.

Once you’re in a shell, you can use the shred command to wipe your HD’s data by overwriting it a number of times with random data. I found that out by reading a post by a lad named Jason on the topic which was a nice help. I only had to add the “sudo” call in front of the command to actually allow it to get write access to the disk on Debian.

First figure out what partition/drive you want to wipe by running:

cat /proc/partitions

Then, in my case, I had to run this to wipe sda:

sudo shred -fvz -n 6 /dev/sda

The -fvz basically means, [f]orce write permissions, [v]erbose output so you can see the wiping progress and write [z]ero’s on the last run to hide the wiping. -n 6 tells it to do 6 runs of random data writing.

Using DBAN is still the easier way to get this done, but if that’s causing you trouble you can use this as a backup wiping measure.

Photo by Hugo Chinaglia, cc-licensed.