Ex­per­i­ment with Ubuntu Linux in­side Win­dows

Cu­ri­ous about Linux? Neil Mohr shows how you can play with a ver­sion of Ubuntu in the com­fort of your Win­dows ma­chine.

APC Australia - - Contents -

No one wants to in­stall a whole op­er­at­ing sys­tem, just to mess around with a bit of ter­mi­nal-based garbage, so Mi­crosoft did the right thing, and brought Linux in­side Win­dows, us­ing the Win­dows Sub­sys­tem for Linux. Part­ner­ing with one of the lead­ing Linux de­vel­op­ers, Canon­i­cal, it de­vel­oped the WSL to en­able you to ef­fec­tively in­stall the core of the Ubuntu Linux OS in­side of Win­dows. No mess, no fuss, just pure, sim­ple Win­dows, with added Linux on top... uh, in­side.

“Why?” we hear you ask. Be­cause de­vel­op­ers love it. It en­ables them to di­rectly in­stall and run com­mon open-source tools, com­mands and server ser­vices with­out leav­ing Win­dows. It also en­ables you to mon­key around with Linux from the com­fort of Win­dows, with­out even need­ing to fire up a vir­tual ma­chine. So it’s free, it’s easy to get up and run­ning, won’t take up much space, it’ll ex­pand your knowl­edge, and help freak out your friends! What’s not to love? Let’s give it a try, and ex­plain how you can have some open-source fun along the way.


Set­ting up and run­ning the WSL has be­come some­what sim­pler than when it was first in­tro­duced back in 2016, as long as your ver­sion of Win­dows 10 has the Fall 2017 Cre­ators Up­date, which is Win­dows build 16215 (aka Red­stone 3). The most com­plex step is do­ing the fol­low­ing: In search, type “pow­er­shell,” right-click this, and se­lect ‘Run as ad­min­is­tra­tor’ [ Im­age A]. En­ter the fol­low­ing com­mand, and restart your sys­tem. En­ableWin­dows Op­tional Fea­ture-On­line -Fea­ture Name Mi­crosoft-Win­dows-Sub­sys­temLinux


Head to the Win­dows Store and search for ‘Linux’. Boom — a whole new sec­tion ded­i­cated to Linux on Win­dows. Will won­ders never cease? We’re only in­ter­ested in Ubuntu here — OpenSUSE is an­other ma­jor Linux dis­tro, but it uses a dif­fer­ent in­staller sys­tem (known as pack­age man­age­ment) to Ubuntu. So choose Ubuntu, and click ‘Get it’ [ Im­age B]. If you run into an er­ror at this point, en­sure you ran the Pow­er­Shell com­mand, you have a 64-bit CPU, that you have the cor­rect build of Win­dows 10, and it’s in­stalled on the C: drive un­der ‘De­fault Save Lo­ca­tions’ in Set­tings.


Be­fore you can do any­thing, you need to cre­ate a user ac­count for Ubuntu; en­ter a suit­able user­name and pass­word. Now be­gin the ob­scure ter­mi­nal in­can­ta­tions to start the Linux magic. These first two en­sure Ubuntu has the lat­est pack­ages, and is up to date, so type: sudo apt-get up­date sudo apt-get up­grade You’ll see a list of scrolling text, which refers to the on­line repos­i­to­ries where Ubuntu stores OS files, en­sur­ing you have the lat­est list,

then en­sur­ing Ubuntu has them in­stalled [ Im­age C]. Typ­i­cally, once it’s up­dated them, it asks you whether it’s OK to in­stall the up­dates.


At this point, all you have is the ba­sic Bash shell — that’s the text-based ter­mi­nal, which is su­per-pow­er­ful, but more for de­vel­op­ers and server en­vi­ron­ments, which we’re likely not liv­ing with or in. The cool part is that the Linux world uses a graph­i­cal sys­tem called X to gen­er­ate its GUI. X uses a server/client model, which means you can ac­cess in­ter­faces over net­work con­nec­tions or across sub­sys­tems. We’ll in­stall a Win­dows-based X server, and the Linux client will be able to launch GUI-based X tools. Down­load and in­stall Xming [ Im­age D] from source­forge.net/projects/xming/. Al­low the fire­wall ex­cep­tion as well.


That’s the Win­dows side taken care of. On the Linux side — you’ve run Ubuntu, right? — we need to point any GUI ac­tiv­ity at the cor­rect dis­play. Type ex­port DIS­PLAY=:0.0 . To per­ma­nently set this dis­play en­vi­ron­men­tal vari­able, type: echo “ex­port DIS­PLAY=:0.0” >> ~/.bashrc That adds the di­rec­tive to a script that’s run each time you start Ubuntu, tech­ni­cally the Bash shell part. Now we need to in­stall a graph­i­cal pro­gram: sudo apt-get in­stall gedit This takes a while. Type gedit to run the pro­gram [ Im­age E].


If you re­search this on­line, you may find ref­er­ences to Dbus fixes; these are no longer re­quired, be­cause it’s now part of the de­fault Ubuntu in­stall. This means we’re able to dive in and in­stall a Linux desk­top — we’re opt­ing for a lightweight one called Xfce4. Run each com­mand here in turn: sudo apt in­stall xfce4 sudo apt in­stall gnomethemes-stan­dard sudo apt in­stall conky


We’re go­ing to do a bit of house­keep­ing to keep things neat, so run the com­mand nano ~/. xini­trc and, in the text ed­i­tor, en­ter the lines of code that fol­low. When done, press ‘Ctrl-O’ and hit Re­turn to save it, and ‘Ctrl-X’ to exit the text ed­i­tor. #!/usr/bin/env bash ex­port LANG=”en_ US.UTF-8” ex­port LC_ ALL=”en_ US.UTF-8” exec startxfce4 Run chmod +x ~/.xini­trc to make the file we’ve just cre­ated ex­e­cutable, then use ln -s ~/. xini­trc ~/.xses­sion to ‘link’ that file with an­other stan­dard X con­fig­u­ra­tion file. Start your newly in­stalled Linux desk­top with: dbus-launch --exit-with­ses­sion ~/.xses­sion On the first run, a di­a­log pops up — se­lect to use the de­fault. The Xfce4 desk­top ap­pears over the Win­dows 10 one, so you might want to en­sure the Ubuntu win­dow isn’t full-screen, be­cause the win­dow bar can be blocked. You should spot an Ap­pli­ca­tion menu top-left, there’s a dock at the bot­tom, with a taskbar run­ning along the top. To quit, use the ‘Log out’ op­tion in the top-left menu [ Im­age F]. You won’t find too much to play with at this point, be­cause it’s a Linux desk­top run­ning on a largely sparse dis­tro. You can add pro­grams, such as Fire­fox, via sudo apt-get in­stall fire­fox and this then ap­pears un­der the ‘In­ter­net’ menu.

“It’s free, it’s easy to get up and run­ning, won’t take up much space, it’ll ex­pand your knowl­edge, and help freak out your friends! What’s not to love?”

Newspapers in English

Newspapers from Australia

© PressReader. All rights reserved.