30 PAGE RASPBERRY PI SPECIAL www.linuxuser.co.uk

THE MONTHLY MAGAZINE FOR THE GNU GENERATION RASPI PROJECTS MADE EASY 10CCTV camera • Media centre • Wi-Fi router • Retro console & more

Speed up your PC Photo Use to optimise your desktop managers Find the perfect package in our How to build super-test a GUI in Python Easy UI creation with Tkinter

ALSO INSIDE » Learn MongoDB » Elementary OS interview exclusive Hacking health care How safe is Can open source save it? your network? Pentest your network like a pro Reviewed in this issue: Raspberry Pi Camera Module MASTER Embedded Pi • AV PUPPET ISSUE 129 WorldMags.net

WorldMags.net WorldMags.net Welcome to issue 129 of Linux User & Developer Get

Mihalis Tsoukalos has over 15 years of Linux User UNIX system administration and This issue programming experience and has for £4.19 been using Linux since 1993. He is also proficient in Oracle database » Speed up your PC per issue administration, Cisco IOS and Cocoa. See his first tutorial for » Pentest your network Linux User about MongoDB, which Page 22 starts on page 64. » Build a GUI with Python

Stuart Burns is an experienced Linux and » Get practical with your RasPi virtualisation specialist for a Fortune 500 company and enjoys Welcome to the latest edition of Linux User & writing about Linux. This month Developer, the UK and America’s favourite high-end he shows us how to make our life easier when it comes to caretaking open source and Linux magazine. multiple machines. You can fi nd his We’ve spent a lot of time wondering over the power excellent Puppet tutorial starting on page 50. and versatility of the Raspberry Pi in Linux User & Developer. As an educational tool it has reignited Liam Fraser is the creator of the hugely popular RaspberryPiTutorials YouTube interest in real bare-metal computing in schools series and is a Linux server admin around the world. As a platform for open source software for the Raspberry Pi Foundation. This month Liam flexes his project- it’s inspired thousands to try Linux for the fi rst time. Best of making muscles by creating two of all, though, is that in its role as a development platform the our ten Raspberry Pi projects which start on page 24. Raspberry Pi has empowered talented makers and tinkerers from all walks of life to create some truly stunning projects. Joey Bernard has been using Linux at home We’re not all blessed with the tools and talent to take pictures for almost 20 years and he’s with our Raspberry Pis from the very edge of space, though, so now getting paid for it as a computational research that’s what this month’s 22-page special feature is all about – consultant with ACEnet. In this really useful projects we mere mortals can do in a day. issue Joey gets serious about pentesting with a four-page We’ve included almost everything you need to give them a tutorial demonstrating the power try and each guide is broken down into manageable bite-sized of (pages 46-49). chunks with full source code if it’s required.

Your team of Linux experts… of Linux team Your Gareth Halfacree is our new resident news Give them a try and get inspired to create your very own reporter and brings us news from Raspberry Pi project – next time it could be your project we’re all over the open source ecosystem starting on page 10. Find out why featuring in the magazine. the EU is probing Google and what Sony has open-sourced. Also this month Gareth reviews both the Russell Barnes, Editor Raspberry Pi Camera Module and the Embedded Pi.

Rob Zwetsloot studied aerospace engineering at university, using Python to Get in touch with the team: model complex simulations in class. Among other things this issue, Rob explains no less [email protected] than four of the projects for our Raspberry Pi cover feature and Buy online finds out which photo manager you should be using (page 70). LinuxUserUK @linuxusermag Visit us online for more news, opinion, tutorials and reviews: www.linuxuser.co.uk

WorldMags.net 3 Issue 129 WorldMags.net Contents Reviews 70 Photo Software manager super-test Which of our open source choices gets you the best results?

digiKam F-Spot

24 Do something amazing with your gThumb Raspberry Pi today! 76 Raspberry Pi Camera Module happy? OpenSource Tutorials 78 Embedded Pi 06 News 46 How safe is your network? The ultimate companion? The biggest stories from the One of the best forms of defence is offence. open source world Tear your network apart with Kali Linux 81 LG Optimus L3 II One of the smallest 14 Opinions 50 Keep all your machines in a line Androids available The latest from your favourite the easy way with Puppet free software columnists Keep your networked machines in sync 82 AV Linux The best in open source 85 B o o k s 54 Speed up Linux with Openbox media editing? The latest Linux reads Install and confi gure Openbox, the FEATURE dissected lightweight 94 Letters Your views on the magazine Developer tutorials and the open source scene 58 Build a GUI with Python Features Get to grips with Tkinter 06 Hacking health care 64 Make a MongoDB database Can open source save it? Master the NoSQL database system 24 10 Raspberry Pi projects made easy On your free disc Dust down your Pi and put it 96 Cover disc to good use The very latest distros on DVD! 70 Photo manager Subscribe super-test Fedora 19 today! Which open source solution 06 Hacking health care should you be using? 22 Save at least 30% on the shop price. This month we’re asking the big question US customers – can open source save the health-care 88 Q & A can subscribe via system? Richard Smedley tackles the Your questions answered by page 84 topic in this month’s news feature… our panel of experts

Join us online for more Linux news, opinion and reviews www.linuxuser.co.uk 4 www.linuxuser.co.uk WorldMags.net WorldMags.net

Can you volunteer for Code Club? Code Club is a nationwide network of volunteer-led after school coding clubs for children aged 9-11.

We need people who know how to program computers to volunteer to run a club at their local primary school, library or community centre for an hour a week.

We create the projects for our volunteers to teach, the projects we make teach children how to program by showing them how to make computer games, animations and websites.

Get involved, let’s teach the next generation to code!

Visit www.codeclub.org.uk to find out more

WorldMags.net WorldMags.net

6 News | 14 Opinion | 94 Letters Can open source save health care? When health care is struggling to meet demand, open source innovation could improve service and save money… Maintaining or increasing real-terms spending And caring, too on health may be a brave decision in austere The NHS has the relative luxury of a ring-fenced times but, despite the public sector wage budget. Adult social care has been hit with freeze, budgets cannot keep pace with the rising unprecedented cuts, and local authorities (who cost of health care and an ageing population. are responsible for most social care provision) However, from pressure to change the way we are dipping a toe in the open source waters and do things to make budgets go further comes fi nding them unexpectedly welcoming (see opportunity for real innovation, and an entry for ‘DALLAS to Liverpool’ boxout). the nimble (did someone say agile?) hackers of It may not please all of the giant corporations the free and open source movement. currently dominating the health and social care The fi gures are so high as to seem near- industries, but the door is opening to small, agile meaningless – with 1,400,000 employees, a competitors and – from the FOSS world – hack budget of more than £100 billion, 2,300 hospitals days are introducing free software coders and and 10,500 GP practices, the NHS deals with startup businesses to health-care professionals over 1 million patients every 36 hours. and decision-makers. Costs are notably high across the sector. LUD Health hack days bring together “developers, was told of a simple tray costing the NHS £75, designers, clinicians, health-care professionals, because it has to be ‘medical grade’ plastic. marketers, project managers, researchers Imagine instead 3D printers in every hospital and coders” to produce working technological producing plastic parts to order from open solutions to health-care problems in a CC: Craig Strong, for NW Health Hack source designs. concentrated session of 24 or 36 hours – often CC: Craig Strong, for NW Health Hack CC: Craig Strong, for NW Health Hack

Q Following the pitches, pitchers had to hustle for developers CC: Craig Strong, for NW Health Hack

6 www.linuxuser.co.uk WorldMags.net WorldMags.net News The latest in the Linux community OPEN SOURCE

Q Max Zadow leading the Liverpool Adult Social Care Hack Day CREDIT: Félix Brassier Félix on CREDIT: behalf Red of Ninja. CC: Craig Strong, for NW Health Hack DALLAS to Liverpool Max Zadow organised the fi rst ever Adult Social Care Hack Day in the UK, in Liverpool, last year – with the co-operation of the local council. Although they were “quite scared by it” Zadow tells us, budget cuts in social care have left authorities genuinely open to new ideas. The council’s internal teams liked the event, as did small providers, and a further hack day was organised, as well as events in other regions. From these events many collaborations Q Pair programming: practitioners and coders collaborating arose. Zadow is now working with Mark running over a weekend. Special interest Chapman on Staff Plan, his rostering groups like Health 2.0 (see boxout on page 9) are “The NHS deals software – it was “fun to meet a fellow bringing together innovators to collaborate on enthusiast” Zadow told LUD, speaking of his health problems at events around the world. One with over one collaborator’s interest in the project for its weekend this June, LUD attended Manchester own sake, not as just another job. Health 2.0’s inaugural North West Health Hack, million patients As well as small-scale projects, at Barclays’ largest Global Technology Centre, technologies and ways of working and near Knutsford in Cheshire. innovating demonstrated at the Liverpool every 36 hours” events have played a big part in Merseyside The Cheshire set understand doctors and other clinicians, and gaining £7 million of Delivering Assisted Barclays hides over 3,000 techies away on their working environment, in much the same Lifestyles Living At Scale (DALLAS) this campus, but recently it has been reaching way that Linux advocates try to orient outsiders programme funding. As we go to press, out to the local tech community – including into the FOSS world. However, the health world Liverpool’s business festival, Accelerate, is sponsoring the Manchester branch of TechHub is one of compliance and paperwork, and teams hosting a fringe event on mHealth, built on (part of a worldwide community of collaborative need to allocate appropriate resources to this. the work done by partnerships formed from spaces for technology entrepreneurs). Hosting Professor Shôn Lewis had some interesting the Adult Social Care Hack Day events. There the North West Health Hack on behalf of statistics comparing the size of health-care is a move, says Zadow, “to see Liverpool as a Manchester TechHub is a further step to domains and the amount spent on research, national centre of excellence for mHealth / supporting the region’s tech community. which showed mental health problems eHealth / assisted living.” Barclays’ Julian Bucknall joined Pascal disproportionately missing out. He introduced Lardier, from Health 2.0 Europe, in compering mobile app ClinTouch, a way for people with Pitches were a pleasant surprise: of the 15 the event, supported by Ben Hookway of psychosis to keep track of any symptoms and one-minute proposals given, the vast majority TechHub, Idalia Dawidowska the Health 2.0 problems, to give users more control over were well-thought-out ideas for solving Manchester Chapter Leader, and a team of managing these through better awareness, and problems, with viable products potentially in TechHub and Barclays staff to keep everyone to enable early intervention. sight by the end of the weekend. We heard them supplied with coffee, pizza and all the other summed up by one of the organisers as “proper accoutrements of an all-night hack. Ideas, please doctors trying to solve proper problems”. Introductory talks included a useful With judges for the apps including a clinician and Pitches were often from practitioners facing a orientation to developing for health care in the a venture capitalist, emphasis for the weekend hurdle in their working day, but some were more form of Quinec CEO Robbie Hughes’s ‘10 Rules was on practical projects that could achieve personal, from those who had encountered a for Health Startups’ – such as “health care is a place in the competitive mHealth/eHealth a system, not a market” – which encouraged market. There were also business mentors on developers and entrepreneurs to try to hand, to complement the more technical help.

WorldMags.net 7 www.linuxuser.co.uk WorldMags.net OpenSource Your source of Linux news and views

www.linuxuser.co.uk Email us directly… For the latest news and views [email protected]

wanted to see patients having the “right data at the right time”. They worked in an expanded team to produce a system helping to empower disease directly. Carey Cameron, of Digital mC2, patients through self-management of data proposed a mobile app to ‘gameify’ screening about symptoms. for bowel cancer – one of the top three cancers This combining forces on similar ideas is by fatality in the UK, which is taking 16,000 lives not unusual at hack days and unconferences per year (and growing in incidence by 10 per cent – a fl exibility not enjoyed by events which are per annum) and costing the NHS more than timetabled and set in advance. However, while £1.1bn annually. agile working may be standard for software 3Squared commercial director James Fox startups, rapid pivoting is not an option for and UX designer Alex Pawlak teamed up with many medical apps, according to Robbie Cameron to produce ‘Gut Feeling’ – to raise Hughes. Practitioners “need to be sure that consumer awareness of symptoms of bowel they’re working and tested, and then signed off,” cancer; engage participation and motivation Hughes told us, adding they had to work with “a CC: Craig Strong, for NW Health Hack among ‘at risk’ target groups; and improve waterfall/agile hybrid” of their own. Q Medical student Vincent Simpson wants to national screening uptake fi gures (currently only end human error in drug dilution – the most 9 per cent). It was singled out for praise by one Tracking winners preventable cause of patient harm of the judges, Dr Ranjit Gill, chief clinical offi cer The eventual winner was the team from from NHS Stockport, and came second overall. Manchester-based developer Click Innovate, Code is at https://github.com/taggr and a who worked through the Saturday night to deliver short video of the app is at clickinnovate.com. Abstrakt & open data Taggr. It uses near-fi eld communication (NFC) Chris Garrett’s team at multi-platform developer – the technology featured in new smartphones Back in the NHS Abstraktion is used to dealing with massive data that is poised to transform payment systems, and While Health 2.0 has come from entrepreneurs sets, so led a team investigating prescription much else, once security niggles are ironed out and coders, and the Liverpool Adult Social Care data to fi nd the best areas for recruiting for new – to track patients’ locations and their medical events were initiated by service users and coders drug trials. By lunchtime on the fi rst day they’d needs, reducing the “administrative burden on in- (although both were well received by health crunched through 15 million lines of data and patient secondary care.” professionals), clinicians have also initiated were discussing data visualisation ideas. In this case the NFC devices are a lightweight hack-day events. Catriona Kennedy, who had proposed a type that can hold 40 bytes, and can be used Dr Carl Reynolds – with David Miller, and more transparent view of patient data, giving in place of stickers and wristbands which are coder Ross Jones – started NHS Hack Days last information about where the data is used, commonly used in NHS wards for tracking year to get doctors talking to the free software teamed up with Idalia Dawidowska, who patients and objects. community about their needs. Events have

Q The taggr.io – using mobile to cut the bureaucracy burden CC: Craig Strong, for NW Health Hack Q Taggr, the winner of NW Health Hack, starts life on the drawing board

8 www.linuxuser.co.uk WorldMags.net WorldMags.net News The latest in the Linux community OPEN SOURCE

Health 2.0 LUD caught up with Idalia Dawidowska, the Polish doctor turned entrepreneur who leads the Manchester Chapter of Health 2.0. Centred on Manchester, the group attracts membership across the North, and contains around a third techies and almost as many clinicians, plus researchers, patient representatives and technology investors. Dawidowska told us “an increasing number of technology companies want to provide to the NHS.” Health 2.0 is helping support an “ecosystem of people from the problem domain: clinicians, patients and NHS managers; meeting with technology people: designers and developers.” They want to “inspire ideas” for solving the plentiful

“burning health-care problems” through technology. CC: Craig Strong, for NW Health Hack In Dawidowska’s case, this is ineffi ciencies that can be Q Idalia Dawidowska recruits team members for her transparent access to overcome simply through access to data. patient data project included London, Liverpool and Oxford, and generated solutions to help with everything “Sometimes only the simplest of from collating faults in the UK health service (NHSBugs.net) to fi nding out what NHS labs are apps are needed to get round painful currently storing and where. Sometimes only the simplest of apps are needed to get round painful practices that NHS practices that NHS inertia has been inertia has been trapping doctors in for years, or even decades. Haematologist Wai Keong was trapping doctors in for years” having to count instances of 11 different types of blood cells in samples using what is essentially an Not all medical software has a political aim, a driver for smart cities through preventative abacus – but one with only eight levers! From the of course. oPortfolio – “a better NHS portfolio” measures – “cities empowered by maker NHS Hack Days came CellCountr, a JavaScript – is simply aimed at helping anyone progressing communities to be healthier and happier”, in the webpage to turn the computer keyboard into an through a medical career and fi nding themselves words of Max Zadow – is a thread running through abacus with enough levers. hampered by the dreadful ePortfolio software much of the assisted living development work. Go to nhshackday.com for upcoming NHS currently available to them. It’s not just the North West – Health Hacks at Hack Days, including Cambridge in September, Indeed the NHS’s ePortfolio is so notoriously both ends of Ireland, and medical technology and get involved. bad that Dr Laura-Jane Smith started the startup companies across Britain, are showing “ePortfolio Data Liberation Front”, and at 2012’s practitioners the way. In 2010, when the Open? Liverpool NHS Hack Day spoke movingly on the comprehensive spending review was launched, Not untypically, the term ‘open source’ is need to “liberate data” from it, inspiring an app a Treasury spokesperson said: “Anyone who sometimes used ambiguously for open APIs worked on with Python hacker Nicholas Tollervey, thinks the review is just about saving money and open data in health care, while describing and Dr Marcus Baw, that won a ScraperWiki prize. is missing the point. This is a once-in-a- software that is not free and open – a problem generation opportunity to transform the way that acknowledged by Health 2.0 Manchester Healthier, happier government works.” with a forthcoming meeting on the topic. There’s much energy and ingenuity going into However, ring-fenced budgets have protected Nevertheless, much of the innovative work solving health problems, particularly in the North the NHS from this, despite pressure coming going on is with explicitly free and open source West, but can hackers save health care? Not from population factors and cuts to social care. software events – and NHS Hack Days, for on their own – the NHS has huge problems in Given this, pressure for change must come from example, “support openness and invite you to particular with management and training – but below, too – and collaboratively produced work share code with us on GitHub.” the kind of agile, low-cost solutions that can of doctors and carers, with FOSS developers, Out of these teams have come FOSS apps make practical differences to people’s lives is responding quickly to real needs, is convincing like RandomiseMe.org, a platform that enables coming out of hack days and free software. many health and social care managers that “individuals and organisations to run trials of Another product is the regional boost to useful changes are not just desirable, but varying sizes” – and backed by Ben Goldacre’s industry, as small tech companies thrive in this actually possible. BetterData.org.uk as it “helps to spread the idea new collaborative health ecosystem. This is Words by: Richard Smedley of randomised trials, advocate for their wider use, particularly the case in the North West, where and normalise them in the public imagination.” Connected Liverpool’s vision of public health as

WorldMags.net 9 www.linuxuser.co.uk WorldMags.net OpenSource Your source of Linux news and views

www.linuxuser.co.uk Email us directly… For the latest news and views [email protected]

GOOGLE Google under EU antitrust probe Competition Commission investigating complaints from Android competitors QThe EU is keeping Google’s Kent Walker busy Advertising and search giant Google is once again facing the glare of an antitrust “The internet is the greatest level probe from the European Union. This follows complaints made by rivals in the mobile space, playing field ever. More and more, including Windows Phone creator Microsoft and its primary licensee Nokia. people are voting with their feet – or The complaints, which first came to light through documents provided to the Financial Kent Walker, Google Times, claim that Google provides licences at least their cursors” to its Linux-based Android and Google Calendar, to cancel or at the least This isn’t the first time the EU has investigated at below cost level – an interesting claim, delay launching smartphones based on rival the company, which draws the bulk of its considering that the bulk of Android is licensed operating systems. revenue from advertising. In 2009, as the result under a permissive licence as part of the Google has been unwilling to comment on the of a US-based class action lawsuit, Google was Android Open Source Project (AOSP) and case so far, but did provide a statement which forced to spend $125 million establishing the is therefore available for even commercial roughly denies the claims made by Microsoft Book Rights Registry service, but came under exploitation free of charge. and others. “Android is an open platform that the EU’s scrutiny due to its effect on European More seriously, the Competition Commission fosters competition. Handset makers, carriers authors and publishers. is looking into charges that Google has asked and consumers can decide how to use Android, The new probe comes as Google is already those who do pay for an Android licence, in order including which applications they want to use,” facing the end of a two-year investigation into to gain access to the Google Play or the company stated, but refused to be drawn on allegedly anti-competitive behaviour relating Google-specific applications such as Gmail the details of the case. to its search engine, which competitors claim unfairly promotes Google’s own products in its results pages without properly marking the results as being ‘promoted’ rather than natural. While a settlement has been offered by Google, complainants claim that the proposals – which would see the company better labelling promoted results – are inadequate and should be reviewed by the EU Commission once again. Google, naturally, disagrees. “Our proposals are meaningful and comprehensive, providing additional choice and information while also leaving room for future innovation,” claimed Kent Walker, general counsel for the company. “As we’ve always said, we build Google for users, not websites. The internet is the greatest level playing field ever. More and more, people are voting with their feet – or at least their cursors. That free flow of information means that millions of websites – including ours – now compete directly for QMicrosoft, Nokia and others claim that Google giving away business, bringing you more information, lower Android is anti-competitive prices and more choice.”

10 www.linuxuser.co.uk WorldMags.net WorldMags.net News The latest in the Linux community OPEN SOURCE

HARDWARE Linux calendar Sony opens its SmartWatch Festival of Code » Various Company looks to interest hackers in its wares » Uk Sony’s SmartWatch products – wrist- warning that the process “is only for advanced » youngrewiredstate.org wearable computers designed to developers [and] normal consumers are strongly Part of Young Rewired State, communicate over short-range radio links advised to keep the offi cial tested and verifi ed the Festival of Code sees under- with an Android smartphone or tablet – Sony fi rmware” on their SmartWatches. 18s across the UK introduced haven’t exactly taken the world by storm, but the More details are available at: to programming and the use of open data before meeting up in company is hoping to enlist some open source tinyurl.com/sonyosw Birmingham on the Friday for talks, help in turning its fortunes around. pizza and an overnight stay. As part of a company-wide programme August 2013 05-11 that has seen Android Open Source Project (AOSP) ports for many of its products, including the high-end Xperia Z smartphone and Xperia Tablet Z, Sony has released code and instructions for creating third-party fi rmware to be installed upon its SmartWatch products. Sony has already released one such fi rmware publicly, providing compatibility with the Arduino Flock IDE following a hack-day collaboration between » College of Charleston, South the two companies in Malmö, Sweden in July. Carolina Other fi rmwares are expected to appear shortly, » USA some of which will likely take advantage of the » flocktofedora.org near-fi eld communication (NFC) capability The successor to the traditional introduced in Sony’s most recent watch model. Fedora Users and Developers

“With the Open SmartWatch project, we’re QSony’s SmartWatch now supports third- 2013 August 09-12 Conference (FUDCon), Flock is a new conference for Fedora party , including one Arduino- opening up the device even more,” the fi rm contributors with a focus on talks, boasted in its announcement of the move, before compatible example networking, feature development, and – for the fi rst time – OPEN SOURCE open hardware. DebConf13 Fantec found guilty in GPL case » Le Camp, Vaumarcus Fantec has been found guilty of breaching of distributing fi rmware containing the » Switzerland the terms of the GNU General Public iptables tool without corresponding source » debconf.org License (GPL) with its 3DFHDL Media Player, code. The court agreed with Welte in its The annual Conference, with the court ordering a penalty payment decision. preceded by a week-long DebCamp starting on 6 August, features and fees to be paid. “It is great to see that the court speakers from around the world The case, brought by GPL-Violations.org acknowledges the fact that vendors and a defi nite technical bent to its founder Harald Welte, accused the company themselves are responsible for checking schedule – including collaborative their products for GNU GPL compliance,” coding parties. 11-18 August 2013 August 11-18 said Welte of his victory. “Every company distributing the software FrOSCon 2013 has to comply,” added Matthias Kirschner » University of Applied Sciences, of the Free Software Foundation Europe. St Augustin “Companies obviously see the benefi t in » Germany building upon free software, and they should » froscon.de stick to these basic and simple rules.” In its eighth year, the Free and Open Source Software Conference has as its focus seamless QFantec’s 3DFHDL Media computing, the role of free Player has been found software in closed ecosystems, in breach of the GNU and the growing popularity of General Public License ‘mechanical turk’ systems for 24-25 August24-25 2013 farming off repetitive tasks.

WorldMags.net 11 www.linuxuser.co.uk WorldMags.net OpenSource Your source of Linux news and views

www.linuxuser.co.uk Email us directly… For the latest news and views [email protected] CC : HP Schaefer, www.reserv-a-rt.de

OPEN SOURCE

QGenoa’s council is to prioritise a shift to open Genoa backs open source source software City looks to save €100,000 over closed-source products The Italian Municipality of Genoa has issued Systems Management) division, outlines projects over their closed-source equivalents a report that changes how its information numerous alternatives to commercial packages when tendering projects. However, moving management department will treat the – The Gimp in place of Adobe Photoshop, existing systems and platforms across to FLOSS software tendering process, shifting from 7Zip instead of WinZip, PdfCreator in place of packages won’t happen overnight, the report’s an equal opportunities stance between Adobe Acrobat and, naturally, Linux in place authors warn. proprietary and open source software to of Microsoft Windows. Other cost-saving “Given the breadth and complexity of the actively favouring the latter. measures proposed by the report include information systems used by the Municipality,” In a report published by the council (tellingly extending the lifespan of computer hardware by the report reads, “the introduction of in the Open Document Format), officials outline switching to Linux over more resource-hungry free software and open source should a stance that will concentrate on the use of free proprietary platforms, with older machines be approached carefully, assessing the and open source software (FOSS) with a view to being provided free of charge to schools with impact on systems in use, compatibility, saving a considerable portion of its budget. educational packages pre-installed. complexity of migration, and potential costs The report, ‘Software Libero’, published by In future, the Municipality will be giving resulting from adjustments of systems and the Direzione Sistemi Informativi (Information stronger consideration to free and open source training needs.” HARDWARE Netflix releases Hadoop ‘Genie’ Continues process of open-sourcing its tools Video streaming giant Netflix has released enough – horizontally or otherwise – to support yet another of its internal tools under an open our usage.” source licence, this time the platform-as-a- Genie is one of several tools Netflix has service (PaaS) tool Genie. released under the Apache Licence Version 2.0 Used by Netflix to manage Hadoop clusters in recent months, including the ‘Chaos Monkey’ it on cloud computing services, Genie is designed uses to disable servers at random in order to test to provide a higher level of abstraction for for single points of failure in its infrastructure. Hadoop, Hive and Pig jobs through a REST-ful Netflix has positioned Genie as an alternative API without needing clients for the services or the to Templeton, part of the Apache HCatalog provisioning of new Hadoop clusters. project, but claims it has several advantages. “Why did we build Genie, as opposed to using “Templeton doesn’t support concurrent job QNetflix continues to promote open source, something else that is already available? The submissions to more than one cluster, is still releasing a Hadoop tool dubbed Genie simple answer is that there was nothing that was evolving, and doesn’t appear quite ready for already out there in the open source community production,” claimed Krishnan. not be suitable for immediate deployment in that handled our requirements,” explained While Netflix is using a modified version of other infrastructures. Netflix’s Sriram Krishnan. “An API to run jobs, Genie in production, the company warns that the The Genie code, along with other projects, is abstraction of back-end clusters, an ability to software is in the very early stages – described available from the Netflix Open Source Centre at: submit jobs to multiple clusters, and scalable in the documentation as ‘Version 0’ – and may netflix.github.io

12 www.linuxuser.co.uk WorldMags.net WorldMags.net News The latest in the Linux community OPEN SOURCE

GAMES DIGITAL PlayStation 4 to run Get All About History – a BSD-based OS historically factual magazine Sony’s next-generation PlayStation 4 games console will run a customised version of the Delve into the past so that you’re not Berkeley System Distribution (BSD,) it has condemned to repeat it with our new sister been revealed. Orbis OS, based on FreeBSD magazine All About History, issue 1 out now 9.0, will include a revamped version of the company’s closed-source XrossMediaBar “[It] probably never will support anything other (XMB) user interface. The OS boots using than AT-hard disks, as that’s all I have” comes 50 other events that changed the world. This GRUB, although this will almost certainly at the end of the famous newsgroup post by includes the American Civil War, which ultimately be locked down. While Sony has not that originally announced Linux. In led to the civil rights movement, along with offi cially commented, its decision to fork hindsight, we know this couldn’t be further from scientifi c and technological advancements that FreeBSD rather than a the truth; however, unlike most history, it’s fully allowed us to land on the Moon. is thought to be related to BSD’s use of documented and permanently archived. All About History issue 1 also delves into permissive licences. Using 64-bit x86 Jaguar Documenting the rest of history is where revolution, a concept well known to free and open processors from AMD, the PS4’s hardware is All About History comes in, delivering the most source software advocates. Issue 1 is out now in theoretically compatible with most modern accurate stories and facts from history in both all good newsagents, from the Imagine Shop and operating systems and kernels. historic print form and futuristic digital editions. digitally via GreatDigitalMags.com. Find out more In the fi rst issue, All About History looks at at historyanswers.co.uk.

CLOUD Oracle and Microsoft Does your current database support provider partner in the cloud guarantee a 15 minute response? Oracle’s various products float on Microsoft’s Azure cloud Rivals Oracle and Microsoft have signed an agreement that will see the former’s products brought to the Azure cloud platform. “This partnership will help customers embrace cloud computing by improving fl exibility and choice,” claimed Satya Nadella, Microsoft’s president of server and tools, of the deal. “As part of this partnership Oracle will certify and support Oracle software on Windows Server Hyper-V and Windows Azure.” That includes, Nadella explains, Infrastructure Services instances of preconfi gured Oracle Database and Oracle WebLogic Servers, available to those who do not have Oracle licences, tĞĚŽ͘ along with the ability to launch instances on the Azure cloud ϮŶĚYƵĂĚƌĂŶƚ͛ƐWůĂƟŶƵŵWƌŽĚƵĐƟŽŶ^ƵƉƉŽƌƚĨŽƌWŽƐƚŐƌĞ^Y> platform. Oracle’s Java is also provides a guaranteed 15 minute (human) response, 4 hour to be integrated into Windows ǁŽƌŬĂƌŽƵŶĚĂŶĚŐƵĂƌĂŶƚĞĞĚďƵŐĮdžǁŝƚŚŝŶϮϰŚŽƵƌƐ͘ Azure, the two companies 24 hours a day, 365 days a year. have confi rmed. WŽƐƚŐƌĞ^Y>ŝƐƵƐĞĚǁŽƌůĚǁŝĚĞĨŽƌŵŝƐƐŝŽŶĐƌŝƟĐĂůĂƉƉůŝĐĂƟŽŶƐ͘EŽǁ “The cloud computing LJŽƵĐĂŶĐŚŽŽƐĞƚŚŝƐŽƉĞŶƐŽƵƌĐĞĚĂƚĂďĂƐĞ͕ƐĂĨĞŝŶƚŚĞŬŶŽǁůĞĚŐĞ era – or, as I like to call it, ƚŚĂƚ ŝĨ LJŽƵ ĞǀĞƌ ŶĞĞĚ ŚĞůƉ͕ ŝƚ͚Ɛ ůĞƐƐ ƚŚĂŶ ϭϱ ŵŝŶƵƚĞƐ ĂǁĂLJ͘ the enterprise cloud era – tŝƚŚŐƵĂƌĂŶƚĞĞĚĮdžƟŵĞƐĂŶĚĂĐĐĞƐƐƚŽůĞĂĚŝŶŐWŽƐƚŐƌĞƐĞdžƉĞƌƚƐ͘ calls for bold, new thinking,” stated Nadella. “It requires companies to 2ndquadrant.com/support rethink what they build, to rethink how they operate and to rethink whom they partner with.” .WŽƐƚŐƌĞ^Y>ĞǀĞůŽƉŵĞŶƚ.Ϯϰdžϳ^ƵƉƉŽƌƚ. Training .^ĞƌǀŝĐĞƐ. ϮŶĚYƵĂĚƌĂŶƚ>ƚĚ͘ϳϮϬϬdŚĞYƵŽƌƵŵ͕EŽƌƚŚ^ŝĚĞ͕KdžĨŽƌĚƵƐŝŶĞƐƐWĂƌŬ͕KdžĨŽƌĚ͕KyϰϮ:͕hE/dнϰϰͲϴϳϬͲϳϲϲͲϳϳϱϲ

WorldMags.net WorldMags.net OpenSource Your source of Linux news and views

THE OPEN SOURCE COLUMN Peace and quiet Simon bought a television. It put him in a bad mood…

man in a fine suit tried picking the exact and menu items to play with and icons to press, I proper word to extract them from their finances. wondered if I was getting old. Never mind selling people a feature they actually I gazed down at my remote control, for wanted: this was seemingly about hitting a instance, and it had the Netflix logo on it. target for selling 3D tellies, ironically at a point Netflix presumably has paid good money to where at least one major broadcaster has given advertise on my remote control, which I don’t up the ghost supporting them. Those kinds of feel the benefit of. Furthermore, it’s a button facts don’t get you Salesperson Of The Month that discriminates against those of a Lovefilm and a holiday to the Med, though. persuasion. I frequent neither, so it was a bit of a Simon Brew is a technology Depressingly, the selling doesn’t stop when waste all round for me. writer and editor, you buy a device now. In the end, I plundered What surprised me, though, was how working across the Linux, Windows and my savings at a quieter online emporium accepting I was of all of that. Even a year ago Mac OS X platforms and took delivery of my new television set. I I would have felt myself getting really quite Buying a new television is a minefield. Buying tend to leave it five or six years between such irritated and rage-filled about it all. I feel like a new television via an excursion to a high-street purchases, and thus the technological jump I they’re wearing me down. Still, no matter, there electrical retailer tends to up the challenge to sit through when I switch my new set on tends was one more surprise that the manufacturer that of an end-of-level boss. Clearly, as is often to be a bit more dramatic than if I were to swap concerned had laid on for me. A pop-up advert! the case, manufacturers have an agenda that things out every year. On my television! I was sat watching the start of flies in the face of what an end consumer might I switched on my newly acquired TV then a programme, and an advert overlaid on it. The actually want. My last visit to an electrical and was hit with an interface that looked as if television found itself back inside the box not retailer was like walking into a bad science- Windows 8 had invaded. Only I wasn’t allowed to that long afterwards. I await the moment when fiction film. A row of people were wearing touch anything. To be fair, put a DVD in and the my fridge door starts trying to flog me some expensive-looking 3D glasses, glaring at screens set defaulted to playing it. But while my children Anchor butter or something next. bearing expensive animations, while a young were -filled with glee at the thought of new Can we, then, as end users, agree a point with manufacturers when the selling can stop and the using can start? This is probably the more forlorn hope I’ve ever had in all the time I’ve “Clearly, as is often the case, written these columns, and all the time you’ve been suffering them. But it’s not just my age and manufacturers have an agenda tolerance levels, I don’t think. Instead, I just think that once you’ve bought the box, you’re entitled that flies in the face of what an end to a bit of bloody peace and quiet… consumer might actually want”

14 www.linuxuser.co.uk WorldMags.net WorldMags.net Opinion The free software column OPEN SOURCE

THE FREE SOFTWARE COLUMN PRISM - a window into our lives Our web movements are being watched – allegedly for our own good – by governments and dissent is not approved

Google, we talk to each other through Facebook and Twitter. We buy through Amazon, and look “The greatest and listen to or TV through YouTube or iTunes. Much of this is possible because these companies track and refine our activities and weapons in the know more about us than we would like to know. Few of these hubs of the internet have retained fight for privacy the idealism of the early web. So the revelation that the NSA and GCHQ are are vigilance and mining the web and scrutinising our data is a disturbing, if not entirely surprising, reflection of transparency” the world we inhabit – and represents the flip side Richard Hillesley writes about of the dream of universal interconnectivity. We no democratic control over how our data may art, music, digital rights, Linux and free software for are being watched – for our own good – (perhaps be used in the future – and bureaucracy’s a variety of publications with the help of Facebook and Google) and definition of what constitutes good and bad dissent is not approved. activity is notoriously unreliable. There are lots of Tim Berners-Lee invented the world wide The convenience of the web as a resource imponderables and few certainties. web in 1990, while working at CERN. It was for the surveillance sector is that everything It is often said that ‘if we have done nothing conceived as a means by which Berners-Lee we put out there can be mined and trawled, wrong we have nothing to fear’ and our concerns and his colleagues could share their research and the problem for us is that there is no about privacy are a diversion from the greater across time and space. However, to its pioneers way round it. Data that uses encryption or end of state security. The whistle-blowers are the web also represented a dream of a better anonymising software is retained and treated demonised, but whistle-blowing is sometimes future, where the sharing of global media would by the NSA as suspicious – and the history the only break on the state’s intrusion into our shrink cultural and material differences and and purpose of GCHQ is that it specialises in daily lives. bring the world together in a common purpose breaking and decoding unbreakable codes. Whistle-blowers keep us aware of the limits on for the betterment of all – an instant medium Historically, free and open source software is our freedom and open a window onto the more where we can speak and share our vision with more secure than its commercial rivals, but as nefarious activities of our governments – and our fellow citizens on the opposite side of the soon as we are on the web we are vulnerable as Bruce Schneier (bit.ly/15Otzqq) observes, globe, without the interference of spokesmen and there are no alternatives that are entirely “whistle-blowing is vital… It’s necessary for or intermediaries. To this end, the internet can safe from unwarranted intrusion. The greatest good government and to protect us from abuse be seen as a democratising force breaking down weapons in the fight for privacy are vigilance of power.” the cultural, racial and religious boundaries that and transparency. Berners-Lee was troubled by the revelations, divide us all – a medium for the free and open At the same time we know little or nothing of and took the time out to tell the Financial Times exchange of ideas. the other technological activities of our secret that “Unwarranted government surveillance is Of course, the universality of the web has services. We hear of hacker exploits undertaken an intrusion on basic human rights that threatens made it a target for corporate exploitation and by Russian or Chinese hackers but know little the very foundations of a democratic society… government control and, for their different of similar practices by the British or Americans, Over the last two decades the web has become reasons, companies and governments have although exploits such as the Stuxnet virus an integral part of our lives. A trace of our use of it sought to direct and control our experience of the (en.wikipedia.org/wiki/Stuxnet), which was can reveal very intimate personal things. A store web to fit their own ends. used to sabotage the Iranian nuclear research of this information about each person is a huge We know the governments of China and programme, may give us some clues. liability: Whom would you trust to decide when to Saudi Arabia limit and censor use of the web It may be that all this data is used entirely for access it, or even to keep it secure?” by their citizens, and we know that a handful good ends, for preventing random acts of violence of firms dominate our interactions, generating and subversion by other states, but experience huge profits in the process. We search with teaches us that there are few limits and almost

WorldMags.net 15 www.linuxuser.co.uk WorldMags.net OpenSource Your source of Linux news and views

JON MASTERS The kernel column Follow along with the latest happenings in the Linux kernel community, including the release of the 3.10 Linux kernel and Google Glass…

changes are accepted for the following kernel no other applications waiting to get some CPU release) for 3.11. Initial new features in 3.11 time) 1,000 times per second. include support for Xen and KVM on the 64-bit Unwanted hardware interrupts also delay the ARM architecture known as AArch64 (or ‘arm64’ ability for the system to enter into a truly low- within the kernel). This is just the initial KVM code power idle state. Modern CPUs will only enter their needed for hardware virtualisation support. It lowest-power runtime states when they have will be necessary to implement a full QEMU- nothing to do and are not experiencing hardware Jon Masters is a Linux kernel hacker based device model in order to have guest virtual interrupts. Indeed, whenever a system CPU is who hasbeen working on Linux for some 18 years, since machines actually make use of the KVM. That idle, it executes a special ‘idle’ kernel thread, the he first attended university work is already begun, and it will be interesting to sole purpose of which is to instruct the CPU that at the age of 13. Jon lives in see it come to fruition. it has nothing to do. On modern x86 systems, this Cambridge, Massachusetts, and works for a large includes making a call to the MWAIT instruction, enterprise Linux vendor. He A truly tickless kernel which will tell the CPU to go into a low-power state publishes a daily Linux kernel Linux 3.10 has a number of new features. The until it is awoken by an interrupt (for example mailing list summary at kernelpodcast.org most interesting of these is perhaps support for coming from another CPU that is instructing this a truly ‘tickless’ kernel. The kernel traditionally CPU to resume its activity). ARM uses a similar relies upon a 1,000-per-second ‘timer tick’. This process involving the WFE and WFI (Wait For Linus Torvalds announced the release of the is implemented using a small piece of hardware Event/Interrupt) sequence of instructions instead; 3.10 Linux kernel, noting that there had been known as the programmable interval timer (PIT). other architectures have similar concepts. a little too much code churn for his liking late in The PIT is simply a countdown clock that counts The challenge of unwanted hardware-timer- the RC stages, but that he had decided there down at a programmable rate. Once it reaches driven interrupts was first tackled in the official wasn’t enough reason to break the normal zero, it triggers a hardware interrupt. Upon Linux kernel back in 2007, with the introduction pattern of “rc7 is the last RC before the release’’. receiving this, the CPU stops running whatever of ‘tickless’ code that stopped the timer tick Linus notes that 3.10 is a “pretty typical” release, application code it is executing and switches whenever a CPU was truly idle (had nothing to and that while there are no new major new into the kernel so that the latter can get some do and was running only the idle thread). This subsystems or architectures, there are the usual time to perform housekeeping activities, handle was a great improvement to overall system raft of new features. This was the busiest kernel the switching from one application to another, power utilisation, but it arguably didn’t go far development cycle ever, with almost 13,500 non- and other things that kernels do. The problem enough. The timer will still be enabled at the first merge changesets pulled into the codebase. with this approach is that these interrupts are sign of any CPU activity. By contrast, a suitably With the release of the 3.10 kernel came the expensive. They introduce unwanted latency configured 3.10 Linux kernel will keep the timer usual near simultaneous opening of the ‘merge by disturbing the currently running application disabled on a given CPU as long as there is only window’ (period of time during which disruptive (which might not need to be switched if there are one task (application process) running on that

16 www.linuxuser.co.uk WorldMags.net WorldMags.net Opinion The kernel column – Jon Masters OPEN SOURCE

“New 3.10 features include support for a truly ‘tickless’ kernel”

CPU at a given time. Once there is more than one (the Google codename for the Glass unit) in standardisation (especially in the non-x86 case), task to run on a given CPU, it will be necessary advance of getting the hardware itself and took but it does introduce new challenges for Linux to resume the timer in order to allow the kernel apart the kernel port in an effort to understand kernel support. One of those is how to handle scheduler code to run (to switch tasks). There what Google had done to put this together. the runtime services interface provided by the is also a need to have a designated ‘boot’ CPU Notle is effectively an almost ‘Galaxy Nexus’ firmware. In the new world order, UEFI abstracts that is always running the timer code such that class cellphone device. Like the Nexus, it is the notion of a ‘System Volume’ containing system housekeeping tasks can still make powered by the Texas Instruments 32-bit ARM- bootable OS kernels and the like such that progress. It is likely that further optimisation will based OMAP4 processor family (in this case, an UEFI-enabled operating system can use occur in the future. the OMAP4430). This is the same processor that standardised methods to request the installation powers the TI PandaBoard (which retails for of a new kernel, and so on, without needing to Google Glass (notle) several hundred dollars and is widely supported know exactly how (or where) that is being stored This author was recently among the lucky few to by Android and other Linux distributions). It’s also – on flash, disk, wherever. To make this work, be given the chance to pick up a pair of Google several years old. In fact, this is generally true of certain ‘runtime services’ must remain accessible Glass(es). This is a new augmented reality HUD- the codebase that is powering notle. It’s based to the kernel after initial booting (and a call to driven system from Google (and powered by upon Linux kernel 3.0.31 (which is ten releases ExitBootServices) has been completed. This Android) that effectively straps cellphone-level old now), as released in Android 4.0.4 (Ice Cream means that a ‘small’ amount of UEFI code must processing capability directly to your head. Sandwich). The notle platform-specific code remain in memory so that it can be called upon by Interaction is driven largely by a combination of is actually based upon the same TI code that the kernel to provide assistance. voice commands (“Okay Glass, Google ‘Linux powers the PandaBoard. Reading the code, it is Once the kernel has booted, it takes control of User’ ”), and by tapping and swiping on the apparent that there have been four hardware system memory management. It needs to find special-purpose Synaptics touchpad surface revisions so far and that the most recent, ‘EVT2’, a location for the UEFI code to live permanently that forms one entire side of the unit. Fun though had a whole bunch of cleanups, including the in kernel virtual memory such that it can be it certainly is to have an unobtainable tech toy (as addition of an FPGA (for some kind of glue/fixup called upon later without interfering with normal an aside, it turns out to be a surprisingly unlikely logic), and fixes to the temperature sensors within activity. To do this, a special ‘Remap’ function way to meet women, as everyone wants to try it the unit. It’s also clear that there is hardware is called that moves the supporting UEFI code out!), it also has shown tremendous promise for which is not yet being heavily used – and there in memory and ‘relocates’ it – patches the what the future might look like. is rumoured to be an ability to implement wink instructions such that they now run at a new The current units are expensive ($1,600), the sensing later, to make use completely hands-free. location. Unfortunately, many of these features battery life is terrible (an hour of constant use, a We’ll write more about the kernel that powers only see aggressive testing by system vendors few hours of light use) and the tilt/touch wake- Glass in a future issue. In the meanwhile, you can on Windows. This means that if Linux differs too up is far from ideal (wink or similar sensing), but take a look at the kernel source code for yourself much in behaviour from the way that Windows very feature-rich and exciting apps are already by visiting: https://android.googlesource.com/ does things, it may lead to unforeseen problems. beginning to appear. As a first-generation kernel/omap/+/glass-omap-xrr88 Consequently, a spirited debate has been taking device, it’s already living up to the typically high place with regard to how much like Windows the standard that Google sets for itself. But perhaps Ongoing development Linux UEFI code should behave, especially with more interesting is that since it runs Android, The last few years have seen the gradual regard to the remapping of UEFI for use with post- the technical specifications and source code introduction of, and transition to, UEFI as boot Runtime Services. powering the technology are available to a wider the system boot firmware of choice for both audience than just those of us with units. In fact, x86 and non-x86 systems alike. UEFI brings I pulled down the Android source code for ‘notle’ many benefits in form of greater system

WorldMags.net 17 www.linuxuser.co.uk WorldMags.net Interview An introduction to Elementary OS

ElementaryIntroducing OS Is it really possible to build an entire OS from an icon set? The answer, it seems, is elementary…

We recently caught up with three key members of the Elementary OS’s home-grown application suite and Elementary project to see how they’re getting on with the design ethics are all very deeply rooted. Plank (its dock, latest build of Elementary OS, ‘Luna’. based on Docky), window manager Gala, an application As you might already be aware, Elementary started life launcher built to complement a bespoke top panel – as little more than a popular icon set. From that set came every aspect is built to very specific design guidelines. grander plans with themes, then a suite of apps built using Unsurprisingly, the core Elementary team are a Elementary’s strong design and usability ethics. In May this young and dynamic group who, while geographically year the team released their second beta of a fully fledged disparate, are very much on the same wavelength when Linux distro, Elementary OS, that puts those years of hard it comes to what they want from a modern desktop work to ultimate use. It’s already making waves in the Linux operating system. world thanks to its Apple-esque design approach to the After following development in the form of both Linux desktop. betas and lengthy stints stalking the team on their At first glance it would be easy to dismiss Elementary well-populated and lively IRC channels, we managed to OS as a yet another respin with trendy desktop catch up with team Elementary to learn more about the backgrounds and whiz-bang icons, but this could hardly be first distro since to reinvigorate our love for further from the truth. desktop computing…

Daniel Foré Cassidy James Blaede Cody Garver Age: 24 Age: 21 Age: 23 Location: California, USA Location: Iowa, USA Location: Mississippi, USA Occupation: Self-taught interaction designer. Occupation: Full-time student and self-taught Occupation: Full-time student doing an Position on team: Founder of Elementary UX designer. Currently studying Interactive associate degree in computer networking. LLC. I work closely with software engineers Digital Studies. Position on team: I lead the Elementary and designers to create and enforce Position on team: I’m currently the community development team and am also OS engineer on code standards, human interface design manager, lead writer, a UX designer, and a the project. guidelines, and clear consistent copy. council member of Elementary.

18 www.linuxuser.co.uk WorldMags.net WorldMags.netAn introduction to Elementary OS A chat with the team behind this exciting new Linux distro INTERVIEW

Q The installer is typical Ubuntu – fast and very easy to work with

Q Slingshot, the application launcher, can Q The team are be pivoted and working on their own searched AppCenter, but it’s not available yet In your own words, what is Elementary? How of the apps, but wanted to help out. The cohesive CJ: By taking something that’s powerful would you explain it to a friend in a bar? sense of design drew me in and I stayed because and distilling the interaction down to what’s Cassidy James: Elementary is both an idea and of the heavy emphasis on user experience. necessary, we enable ordinary users to tap into a project. It’s the idea that computing should that power. be fast, easy, beautiful and free. It’s a project DF: For me, Elementary OS came about because that includes an icon set, a suite of apps and an Windows and OS X just weren’t perfect, and yet It must be hard to draw a line between power operating system (Elementary OS). there was nothing that could be done about and simplicity. How do you strike a balance? Elementary OS, specifi cally, is an open source it. I wanted a professional, consumer-ready DF: I think traditionally, power has been equated operating system that adheres to those ideas. desktop in which I could actually effect change. with complexity. But for me, a piece of software It’s the best-of-the-best from Elementary. It’s is truly powerful when it’s enabling users to do both powerful under the hood and beautifully Do you feel like you’ve been at all successful in things they were never able to do before. So for simple. We really don’t like to think of Elementary effecting that change? people like my grandparents, power means OS as ‘yet another distro in the Linux world’. DF: I think we’ve been 100 per cent successful. being able to send email. It’s an incredibly simple Elementary OS is an operating system that’s just We’re a super-open community and everybody task with a traditionally incredibly high barrier as good for your grandma as it is for an IT guy. has a voice here. While we do have an to entry. The more tasks that we can lower the barrier to entry on, the more powerful our What niche in the distro ecosystem does users become. it fi ll? What sets it apart from the crowd? “An OS that’s just as CJ: By having a disciplined user interface, Daniel Foré: When talking about the role we’re able to better expose that power to of Elementary in the Linux ecosystem, good for your grandma the user. For example, instead of offering I like to compare it to an album. There’s the kitchen sink of customisation options, a lot of ‘Top 10’ and ‘Greatest Hits’ we force ourselves to fi gure out how to distros out there. But Elementary is as it is for an IT guy” design it in a way that works best. one of the few that have produced the entire overarching vision and we have to stay focused experience from beginning to end. We build on our goals, I think it’s very easy for any How would you compare the way you’re a coherent experience with a whole new developer or designer (of any skill level) to get ‘designing it in a way that works best’ with, say, home-grown interface. into contact with the right people and effect or GNOME? Cody Garver: Elementary OS adheres to strict change on our desktop. CJ: I think we have a much tighter focus on the ideas and rules for how an operating system In addressing consumer-readiness, I’m user. I don’t want to bad-mouth anyone here, should interact with users. The ideas and rules always excited to hear stories from our but Canonical have their corporate interests, are defi ned in our Human Interface Guidelines or users about Elementary being installed for are focusing on servers, and are going out of otherwise decided on by the design team. stereotypically less experienced users (read: their way to do their own thing. They seem to be mom and dad). We had someone tweet at us thinking more, ‘what’s the most effective market What inspired you to be involved in the creation recently that they installed Elementary on their strategy?’ where we’re thinking, ‘what the best of both Elementary and the resulting OS? daughter’s computer and she promptly went off CJ: I got involved with Elementary a couple of to school and converted three of her classmates. years ago. I’d seen and used the icons and a few I think that’s pretty good for a public beta.

WorldMags.net 19 www.linuxuser.co.uk WorldMags.net Interview An introduction to Elementary OS

user experience?’. GNOME’s newer design kick actually overlaps with ours here and there, but I think their focus is really on providing a base for other distros. DF: To go further on what Cassidy just said, I think we’re sitting at a sweet spot between the two. We still care about desktop, but we’re also into innovative design.

What’s an average day for you on Elementary? Q Daniel Foré founded Elementary Q Cassidy testing Elementary OS What are your main focuses at the moment? CG: This is how things work for the most part at people can sit down and use it for everything and you both get really excited and then they Elementary: deluge of bug reports come in (from they want to do. We’re quickly approaching that ask about Netflix. users or team members or automated crash point and have some nice anecdotes from users CJ: Time, money and collaboration are all report). A team member (usually me) looks at each which back that up. challenges we face every day. We have a limited bug and if it’s design related, the design team A huge focus from there forward is on amount of contributors trying to fit working on sees it and makes a decision; otherwise the bug developers; we are building an infrastructure Elementary in between their everyday lives. We is marked Confirmed or Won’t Fix or Duplicate of for devs to build apps on Elementary, distribute don’t have a massive pool of money to throw at another report. If it’s confirmed, it gets assigned them and get paid. We already have a lot of them or to invest into the project, as much as we’d to a milestone that determines (very roughly and unique under-the-hood technologies in place, like to. And as Dan said, collaborating with third tentatively) when it should get addressed. like Granite and Contractor, that enable devs parties is difficult at this point; I think we’re not DF: My current focus at this point in the cycle to more easily make apps that both tie into as established in the OS world as we’d like to be. is smoothing out any visual design issues. I’m the system and follow our Human Interface Which makes sense, really, seeing as how we’ve looking for inconsistencies, oddities etc. Guidelines. We’re also working on AppCenter, only had one release, and that was years ago. CJ: Our focus at this exact second is getting an app store and distribution service, but I can’t Luna out the door. Our overall focus, however, is announce specifics at this point I’m afraid. What’s the way forward? How do you factor this on getting Elementary to a point where everyday DF: The team will tell you that we use in and work with it? , Google Docs and other online tools DF: I think the only real way forward on this is Elementary OS’s defaults extensively – they’re all integral tools to working as an entire Linux community. We owe a lot to Here’s a rundown of the core default programs together efficiently and effectively. Canonical and Ubuntu when it comes to courting that ship with elementary OS Luna. Most of big gaming and the like. But overall, I think the them are themselves part of the elementary Is Luna progressing how you’d like? We’ve more users get behind Linux-based operating project family: played with it extensively and found it to be very systems, the more support we’ll see from big Session manager: Pantheon Greeter (based polished and usable day-to-day. names. It’s all up to our early-adopter crowd and on LightDM) CJ: Absolutely. We’re really close, and I think how much noise they make. Top panel: WingPanel getting Luna out the door will allow us to show Application launcher: Slingshot people what we’re capable of doing. Luna What’s worse for a project like yours – a lack or was a huge undertaking: we started virtually time or a lack of money? Dock: Plank (based on Docky) from scratch. We switched over to the Vala CJ: I think time and money go hand-in-hand. If we Settings manager: Switchboard programming language, the GTK3 toolkit, and had more time, we could push things out faster. : really nailed our design. We also built an entire If we had more money, we could pay devs so they Email client: and suite of apps this [had a] lot more time to push things out faster. cycle. From there, we can really continue to Calendar: Calendar (formally known as Maya) impress by building on this solid foundation. Learn more about Elementary and Elementary Audio player: Music (formally known as Noise) OS by visiting their community page at : Scratch There are always pain points in any project – www.elementaryos.org/get-involved Terminal emulator: Pantheon Terminal what are yours? The team and its community are very active on CG: There’s never enough time. Developers don’t IRC (freenode – search for #elementary). : Pantheon Files have enough time to work on Elementary; tech You can also follow the project’s progress at moves too fast for things to get perfected before https://launchpad.net/elementary it’s either objectively or subjectively outdated. Author: Russell Barnes DF: I think our biggest problem is lack of support from major third-party developers. It’s always awful to talk up Elementary to someone

20 www.linuxuser.co.uk WorldMags.net WorldMags.net DOMAINS Create your perfect web address with over 500 new top-level domains from 1&1! Short, memorable domains like fashion.blog and kitchens.online are ideal for getting your website found easily. Pre-order your preferred domain PRE-ORDER for free, with no obligation! With regular updates from 1&1, you‘ll stay fully informed and be in the best position to register your domain with new domain extensions! Find out more at 1and1.co.uk

FREE* WITH NO OBLIGATION!

DOMAINS | E-MAIL | WEB HOSTING | eCOMMERCE | SERVERS 1and1.co.uk

* Pre-ordering a domain name is not a guarantee that the domain will beWorldMags.net registered. If your requested domain has already been pre-ordered, you will be added to a waiting list for that domain. WorldMags.net

SUBSCRIPTION VOUCHER HURRY Q YES I would like to subscribe to Linux User & Developer ORDER NOW YOUR DETAILS Title First name Surname Address

Postcode Country Telephone number Mobile number Email address Please complete your email address to receive news and special offers from us DIRECT DEBIT PAYMENT Q UK Direct Debit Payment I will receive my first three issues for just £1, I will then pay only £25.15 every six issues thereafter. If, however, I do not love what I see, I can cancel at any time.

Instruction to your Bank or Building Society to pay by Direct Debit Please fill in the form and send it to: Linux User and Developer Subscriptions Dept, 800 Guillat Avenue, Kent Science Park, Sittingbourne ME9 8GU

Name and full postal address of your Bank or Building Society Originator’s Identification Number To: The Manager Bank/Building Society 50 1884 Address

Reference Number

Postcode Instructions to your Bank or Building Society Please pay Imagine Publishing Limited Direct Debits from the account detailed in this FANTASTIC instruction subject to the safeguards assured by the Direct Debit guarantee. I understand Name(s) of account holder(s) that this instruction may remain with Imagine Publishing Limited and, if so, details will be passed on electronically to my Bank/Building Society

Signature(s) Branch sort code SUBSCRIBER Bank/Building Society account number

Date Banks and Building Societies may not accept Direct Debit instructions for some types of account A6 instruction form OFFER PAYMENT DETAILS YOUR EXCLUSIVE READER PRICE, ONE YEAR (13 ISSUES) Subscribe today and get Q UK: £62.40 (Save 20%) Q Europe: £70.00 your first three issues Q World: £80.00 for £1 (and save £17.00) Cheque Q I enclose a cheque for £ (made payable to Imagine Publishing Ltd) Q Pay only £4.19 for every Credit/Debit Card future issue – a 30% saving Expiry date on the store price

QVisa Q MasterCard Q Amex Q Maestro Q Free UK delivery to your door Card number Q Never miss an issue Q Money-back guarantee Security number QQQ (last three digits on the strip at the back of the card) Issue number QQ (if Maestro) Terms & Conditions Signed This offer entitles new UK direct debit subscribers to receive their fi rst three issues for £1. After these issues, subscribers Date will then pay £25.15 every six issues. Subscribers can cancel Code: PCG129 this subscription at any time. New subscriptions will start from Please tick if you do not wish to receive any promotional material from Imagine Publishing Ltd by post Q by the next available issue. Offer code PCG129 must be quoted to telephone Q via email Q receive this special subscription price. Details of the Direct Debit Please tick if you do not wish to receive any promotional material from other companies by post Q by telephone Q Please tick if you DO wish to receive such information via email Q guarantee are available on request. Offer expires 30 November 2013. Imagine Publishing reserves the right to limit this type of Terms & Conditions apply. We publish 13 issues a year, your subscription will start from the next available issue unless otherwise indicated. Direct Debit guarantee details available on request. This offer expires without notice. offer to one per household. I would like my subscription to start from issue: Source Code PCG129 Web address: www.imaginesubs.co.uk/lud. Tel: 0844 249 0282 Return this order form to:

Linux User & Developer Subscriptions Department, 800 Guillat Avenue, Kent Science Park, Sittingbourne, ME9 8GU or email it to [email protected] WorldMags.net You will be able to view your subscription details online at www.imaginesubs.co.uk WorldMags.net ISSUES OF LINUX USER 3FOR JUST 1

Readers in the US see page 84 for exclusive offer Get your first 3 issues for just £1, then save 30% on the shop price THREE EASY WAYS TO SUBSCRIBE 1. Online 3.Post or email www.imaginesubs.co.uk/lud Please complete and post the form to Linux User & Developer And enter PCG129 Subscriptions Department 800 Guillat Avenue Kent Science Park 2.Telephone Sittingbourne ME9 8GU 0844 249 0282 Or alternatively, you can scan and email the form to And quote PCG129 [email protected] WorldMags.net WorldMags.net 10 amazing Raspberry Pi projects

Everything you need to make technology come to life with our amazing ideas to try with your Pi!

Around six months ago we put together an together in a day – some in just an afternoon of monitor the temperature of your bedroom and article featuring ten of the most amazing light tinkering. In fact, most need little more than trigger an electric blanket to come on for an hour Raspberry Pi projects in the world. Those the technology you’ve already got in your home in those chilly winter evenings. Or maybe you projects featured lofty goals (like taking pictures – a TV, a camera, a mobile phone or videogame could sample the soil moisture of a houseplant from the edge of space) achieved by some controller. Even for the few projects that do need and have it tweet you when it’s thirsty. Many of devilishly clever people that we could only dream a bit more practical hacking, the bits and bobs the techniques featured in the following pages of emulating. As well as proving the power and you need are unlikely to cost much more than (and even entire chunks of code) would translate versatility of the Raspberry Pi, these projects £10 or £15 – a small price to pay for the gadgets perfectly to projects just like these – all you served as inspiration for the rest of us. you’ll get in return. need is an idea and a little bit of know-how. This time we’re getting practical. We want you Hopefully these projects will give you just In another six months we’re going to lay down to pick up the gauntlet and actually get building enough expertise and practical experience to the gauntlet all over again, but next time we and we’ve hand-picked another ten amazing allow you to take things even further and come want to show off your projects in these pages. projects, but each one of these can be put up with projects of your own. Perhaps you could Get hacking and show us what you can do!

24 www.linuxuser.co.uk WorldMags.net WorldMags.net10 Raspberry Pi projects made easy Practical Raspberry Pi projects to amaze and inspire

028 - 029 Portable internet radio

026 - 027 030 - 031 Complete media centre Always-on torrent box

032 - 033 034 - 035 036 - 037 038 - 039 Time-lapse camera trigger Retro games console File server Security camera

040 - 041 042 - 043 044 - 045 VoIP server Wireless access point Voice-control Your Pi

WorldMags.net 25 www.linuxuser.co.uk WorldMags.net The complete Pi media centre

MAKER PROFILE NAME: Create a complete ROB ZWETSLOOT OCCUPATION: media centre TECH WRITER Rob models complex systems and Turn your Raspberry Pi into the perfect media is a web developer profi cient in Python, Django and PHP. He loves centre with some simple software and tweaks to experiment with computing There are a few ways to use the Raspberry Pi as an HTPC, with some of the best being XBMC-powered distros. OpenELEC is a great, lightweight way to use the Pi for that sole WHAT YOU'LL NEED purpose, but we’re going to cover the more customisable Raspbmc, based on Debian. » Internet connection » External hard drive The Raspberry Pi makes Choose between » VESA mount the perfect media centre, different HTPC solutions » HDMI cable and there’s software to with different advantages take advantage of it and disadvantages

Watch local and network videos at full 1080p resolution, along with music and pictures

Get popular streaming apps for web-based video to run directly from your Raspberry Pi

26 www.linuxuser.co.uk WorldMags.net WorldMags.net10 Raspberry Pi projects made easy Practical Raspberry Pi projects to amaze and inspire

Raspbmc will download the latest image on its Install Raspbmc 01 Raspbmc has a downloadable installer initial boot that always gets the latest image for your Pi. Scrape your media Create a new directory and then download it with: 04 After selecting a source, you can choose $ wget http://svn.stmlabs.com/svn/ what service to scrape information from. This Android Remote raspbmc/release/installers/python/ gives you more info on the fi les you’re watching, 07 There’s an offi cial Android Remote app install.py such as episode summaries and proper names. on the Google Play Store that can control XBMC Make it executable with: Make sure your fi lms have the year appended to once the web server is enabled. Download it to $ chmod +x install.py them, and that your TV shows do too. And then run it with: your phone and launch it. Go to the Settings, add $ sudo python install.py new host, and enter the IP address and port (80 by default) like in the previous step. Follow the on-screen instructions and it will then install onto your Pi.

Get some apps 05 On any content tab, go to Add-Ons. It will display the apps you already have, which is none Setup 02 by default. By selecting Get More, the full list of By installing Raspbmc this way, the distro available apps will be shown and you can install will then download the latest image and updates them with one button click from there. to run on your Pi on fi rst boot. This will take a Using CEC while, and involve a couple of restarts, but will 08 If your TV supports it, CEC can be used only happen the fi rst time. Select your language over HDMI to control your XBMC-powered Pi. CEC in XBMC and you’re done. should be enabled by default, which means you can control your entire setup with only one remote control. Refer to the XBMC wiki to see if your TV supports CEC, and how you can take advantage of it: bit.ly/18kdVHf

Traditional 09 remotes XBMC supports a large number of universal remotes that include, Network sharing Web remote or support, USB IR 03 You can add fi le sources to XBMC by 06 In Settings, go to Services and then receivers. One of the fi rst of all going to Video, then Add Source. Go to Webserver. Enable it and you will now be able to best devices for this Browse and you can add local or networked fi les. control your Raspberry Pi using a web browser. is the FLIRC, a fully For network shares, choose either UPnP or SMB To access the web browser remote, enter the programmable USB shares to see what’s visible on the network, or IP address – found in System Info under the IR receiver that allows ‘Add network location’ if you know the direct path. home screen’s Settings tab – into your browser, you to use any remote This works the same for Music and Pictures. followed by ‘:80’. with the Pi.

WorldMags.net 27 www.linuxuser.co.uk WorldMags.net Portable internet radio

The completed Connect your speaker(s) project, with to the 3.5mm audio out momentary jack on the Pi switches to control stations

The circuit is very straightforward with just two buttons

We’ve used the Pi Cobbler, but it’s not a requirement

Build a portable MAKER PROFILE NAME: LES POUNDER internet radio OCCUPATION: FREELANCE SYSTEM Turn your Raspberry Pi into a portable ADMINISTRATOR Les has been a strong advocate Wi-Fi streaming radio of Linux and free software since There are thousands of free radio stations on the internet, and with this project you can 1999 and loves to tinker with hardware and software projects listen to all of them from one tiny little box. So let’s build our streaming radio using a Raspberry Pi, a speaker and a few odds and ends… WHAT YOU'LL NEED Let’s get set up Install some extra packages » A wireless internet connection 01 Firstly, we need to prepare our Pi. Using 02 We need to install the Python packages » 2 x momentary switches Raspbian, and a Pi connected to the internet, to access the GPIO. In a terminal, logged in as » 4 x female-to-male leads (to open a terminal and switch to the root user: root, enter the following. connect your Pi to a breadboard) sudo su -get install python-rpi.gpio » 2 x 220-ohm resistors And update your list of packages, then Now install MPlayer, which is what will be » 4 x male-to-male leads upgrade your Pi to the latest software: playing our audio. » Speakers connected to 3.5mm apt-get update && apt-get upgrade -y apt-get install headphone jack

28 www.linuxuser.co.uk WorldMags.net WorldMags.net10 Raspi projects made easy Practical Raspberry Pi projects to amaze and inspire

This code is the glue that links the GPIO to MPlayer, which handles audio playback

We import the RPi GPIO #!/usr/bin env python library and set it to use import time import sleep BCM numbering system import os import RPi.GPIO as GPIO Here we set up pins 23 # I found loads of BBC Radio streams from http://bbcstreams.com/ and 24, which control the GPIO.setmode(GPIO.BCM) radio station selection GPIO.setup(23 , GPIO.IN) GPIO.setup(24 , GPIO.IN) while True: Here we say that if the if GPIO.input(23)==1: button is pressed for 23, os.system(‘sudo killall mplayer’) run the command below os.system(‘mplayer -playlist http://bbc.co.uk/radio/listen/live/r1.asx &’) if GPIO.input(24)==1: Here we see the script os.system(‘sudo killall mplayer’) kill any open MPlayer os.system(‘mplayer -playlist http://bbc.co.uk/radio/listen/live/r6.asx &’) processes and then load sleep(0.1); the radio station GPIO.cleanup()

Make the files executable and Install Configure the radio to start at boot 03 To install the tools, we need to navigate 06 In a terminal, as root, navigate to to PiAUISuite-master/Install. /etc/.d/ and then create a fi le called radio We now need to make InstallAUISuite.sh using nano. There are executable for all users, so use: nano radio chmod 777 InstallAUISuite.sh In that fi le, type in the following: thousands of free #! /bin/bash Now that the fi le is executable, let’s install: modprobe snd_bcm2835 radio stations on sudo ./ InstallAUISuite.sh amixer cset numid=3 1 python /home/pi/radio.py the internet, and Set up the software 04 Copy radio.py from the cover disc to This loads the kernel module for the sound card you can listen to your home directory – we’ll use the code as is for Amixer sets the output to the 3.5mm headphone this guide, but feel free to edit the code to suit jack (that’s what 1 means, HDMI is 2). Lastly it them with this your needs later on. calls the Python script. Now open a terminal and switch to root, and project edit your network interface confi g: Make it executable nano /etc/network/interfaces 07 Save and exit radio in /etc/init.d by –a terminal is all we need, as the project will not require a screen for future use.. Wi-Fi configuration pressing Ctrl+X and then answering yes to 05 the prompt. Once complete, reboot the Pi and watch as the We want the Pi to automatically connect output from boot whizzes across the screen. to your router via Wi-Fi during boot. Now make radio executable by typing (as root): Edit your /etc/network/interfaces fi le to chmod 755 radio First test Then, as root, register radio to start on boot by resemble this: 09 Once the Pi has fi nished loading, press typing in a terminal: auto lo one of the buttons on your breadboard. In a iface lo inet loopback update-rc.d radio defaults few seconds you should hear the audio come iface eth0 inet dhcp through the speakers that you attached to the allow-hotplug wlan0 3.5mm headphone jack. auto wlan0 That’s it, you have a wireless internet radio. iface wlan0 inet dhcp Why not add a mute function using amixer wpa-ssid “ssid” (manpages.ubuntu.com/manpages/gutsy/ wpa-psk “password” Raspi-config man1/amixer.1.html) and another momentary 08 In a terminal as root, use switch. Or even add an LCD screen (www.rpiblog. Replace the “ssid” and “password” with your raspi-confi g to change the boot behaviour of com/2012/11/interfacing-16x2-lcd-with- own details, but keep the quotation marks. your Pi. We don’t want it to load the desktop, raspberry-pi.html) to show the station details.

WorldMags.net 29 www.linuxuser.co.uk WorldMags.net Always-on torrent box

Build an always-on torrent box Get the latest distros, packages and test builds MAKER PROFILE NAME: faster with a low-power, mini torrent box ROB ZWETSLOOT OCCUPATION: TECH WRITER Torrenting your open source software has a WHAT YOU'LL NEED number of advantages – it can be faster, alleviates » A portable hard drive bandwidth and allows you to share back with the community. Distros, packages and more are available via » Raspbian www.raspberrypi.org/ Rob models complex systems and downloads torrents, and the Raspberry Pi makes for a tiny, low-wattage, is a web developer profi cient in » PC with a desktop environment Python, Django and PHP. He loves always-on torrent box to better manage your fi les. and Deluge installed to experiment with computing

Faster, alleviates bandwidth and allows Store completed fi les you to share back with on an external hard drive, for more space the community or easy transport

You’ll be transferring An always-on torrent box large amounts you can hide in a (well- of data, so wired ventilated) small space networking is a must

30 www.linuxuser.co.uk WorldMags.net WorldMags.net10 Raspi projects made easy Practical Raspberry Pi projects to amaze and inspire

Install Raspbian Basic configuration 01 Raspbian works just fi ne for our torrent 05 Edit the fi le with: box. Install the image on an SD card and go $ nano ~/.config/deluge/auth through the basic setup process, making sure to enable SSH in the advanced options and to And add to the bottom: disable the desktop. [user]:[password]:10 …to restrict access. Now start it up with: $ deluged $ deluge-console

Remote access 02 Type ifconfig into your Pi’s command line to fi nd the IP address. At this point you can unplug the monitor and set it up remotely, but Download location Remote connection either way you can now access the Pi by typing: 08 Go again to Edit then Preferences, 06 Now you’re in the client, type the $ ssh [user]@[IP address] and change to the Downloads tab if it’s not on following three commands: …and entering your password to log in. there already. Set the download location to the config -s allow_remote True directory we mounted the hard drive to, and config allow_remote enable ‘Auto add .torrents’, setting it to any exit destination if you plan to dump torrent fi les to the Pi. Restart the Deluge daemon with: $ sudo pkill deluged && deluged Mount hard drive 03 Unless you plan to reformat your portable Now open the graphical client on your Linux PC. drive, you’ll need to install NTFS support onto your Pi. Type: $ sudo apt-get install ntfs-3g Add the hard drive to /etc/fstab (open it with sudo nano /etc/fstab) by adding the line: /dev/[hard drive address] [mount point] auto noatime 0 0 Use fdisk to fi nd the name of the storage, and create a mount point such as /home/pi/torrents with mkdir. Reboot for it to mount. Start on boot Install Deluge 09 An init script from Ubuntu can be used to 04 We’ll use Deluge for our torrents. Install have Deluge start on boot. Download it with: it with: $ sudo wget -O /etc/default/deluge- $ sudo apt-get install deluged daemon http://bit.ly/13nKOSj deluge-console Open /etc/default/deluge-daemon with nano Now start and then stop Deluge so it creates a and change the username to the one we set up confi g fi le we can edit with: earlier. Save it, then download the full init script $ deluged Remote interface and update with: $ sudo pkill deluged 07 Go to Edit>Preferences>Interface, then $ sudo wget -O /etc/init.d/deluge- disable Classic Mode and restart Deluge. Click daemon http://bit.ly/13nKKlz And fi nally, run the following to copy the confi g fi le Add on the Connection Manager, and enter the $ sudo chmod 755 /etc/init.d/deluge- in case we mess up: IP in Hostname and the user we set up earlier. daemon $ cp ~/.config/deluge/auth ~/.config/ Click Connect to see any torrents you have $ sudo update-rc.d deluge-daemon deluge/auth.old downloading or uploading. defaults

WorldMags.net 31 www.linuxuser.co.uk WorldMags.net Time-lapse camera trigger

We wont be controlling Using a basic 3.5mm audio jack, we can pulse the the autofocus with our shutter trigger simply by applying voltage to the Python app, so set the cable ‘head’ focus to manual and select your camera settings in advance of the shoot

We’re using a cheap Canon EOS DSLR, so to trigger the shutter with the Raspberry Pi, all we need is a simple 2.5mm to 3.5mm cable

We’re using the Pi Cobbler as a breakout for the Pi’s GPIO pins, making the build process easier (though it’s not required) Create a time-lapse camera trigger MAKER PROFILE NAME: Make shooting time-lapse video with your RUSSELL BARNES OCCUPATION: DSLR camera a cinch with our expert advice EDITOR, LINUX USER

You’d be forgiven for thinking that creating the Raspberry Pi and a sprinkling of Python code, that’s mesmerising time-lapse videos like those of no longer the case. In this guide we’re going to use our Russell has been an open source Vincent Laforet (www.laforetvisuals.com) Raspberry Pi to trigger our run-of-the-mill DSLR camera advocate and technology writer or John Eklund (www.theartoftimelapse.com) might (in this case a Canon EOS) to create pixel-perfect time- for 15 years. He is a keen RasPi be out of reach of the Average Joe, but with the help of lapse imagery for little more than £10. Here’s how… and Arduino project maker

Set up the Raspberry Pi Install the RPi.GPIO library WHAT YOU'LL NEED 01 For this tutorial we’re assuming you’re using 02 Next we want to make sure your development » Breadboard, connectors, a recent build of Raspbian, available both on the disc environment is set up. Users of Raspian should be set jumper wire and via www.raspberrypi.org/downloads. With the up already, but you should follow these steps anyway to » DSLR camera Raspberry Pi set up with a keyboard, mouse and make sure. In the terminal, type: » Compatible shutter cable monitor, open the terminal and type: suda atp-get install python-dev » Raspbian with Python 2.7 sudo apt-get update Then: sudo apt-get install python-rpi.gpio

32 www.linuxuser.co.uk WorldMags.net WorldMags.net10 Raspi projects made easy Practical Raspberry Pi projects to amaze and inspire

Set up the Pi Cobbler 03 With the development environment set Time-lapse trigger code listing It’s a simple script so the imports are up, we can turn our attention to the hardware. meagre. We need to import the GPIO For this tutorial we’ve used a cheap prototyping module to control the shutter pin import RPi.GPIO as GPIO breadboard and an Adafruit Pi Cobbler and the Time module helps us deal import time (learn.adafruit.com/adafruit-pi-cobbler-kit/ with the interval between shots overview) to give us easy access to the Raspberry print ‘\nWelcome to the Linux User Time-lapse Photography Tool.’ Pi’s GPIO pins. As you can see from the picture, print “Just tell us how many shots you’d like to take and the interval between them.\n” the Cobbler straddles the centre-point of the print “Try googling ‘time-lapse interval calc’ if you need help deciding.\n” breadboard and a ribbon cable connects the two. def main(): Configure the breadboard shots = raw_input(‘How many shots would you like to take?\n ->’) 04 For the Raspberry Pi’s GPIO to control interval = raw_input(‘How frequently do you want to take them (in seconds)?\n ->’) the camera, we need to create a circuit between a pin on the GPIO (in this case pin 23 on the if shots.isdigit() and interval.isdigit(): Cobbler – but it’s actually physical pin 16) and shots = int(shots) the pin that connects to the ‘head’ or ‘tip’ of the interval = int(interval) camera cable that activates the shutter when connected. We’ve also used a resistor, but it print “You’ll be shooting for %d minutes.\n” % (shots * interval / 60) isn’t required. The base of the connector cable answer = raw_input(‘Are you ready to proceed?(yes/no):’) is always ground, so make sure you ground the confirm = answer.lower() in [‘yes’, ‘y’] ‘GND’ pin on the Cobbler and the middle pin on Be mindful of (GPIO.BOARD) – this the audio jack. It’s very simple stuff. With the if confirm: tells you we’re using circuit complete, we can focus on the code. GPIO.setmode(GPIO.BOARD) physical pin number 16, as GPIO.setup(16, GPIO.OUT) opposed to the documented The Linux User Time-lapse taken = 1 number (which in this case is 23) 05 Photography Tool print We’ve created a small 55-line Python utility print ‘Starting a run of %d shots’ % (shots) called The Linux User Time-lapse Photography for i in range(0, shots): Tool, which asks the user to input how many print shots they’d like to take and the frequency they’d print ‘Shot %d of %d’ % (taken, shots) like them taken. It then takes that information This is the main taken +=1 and uses it in a For loop to activate the shutter loop of the script GPIO.output(16, GPIO.HIGH) using GPIO pin 16 . If you’d like to use the project that loops over your time.sleep(0.5) total shot count ‘in the fi eld’ we’d recommend using the Android GPIO.output(16, GPIO.LOW) app ConnectBot to SSH into your RasPi for input and factors in your time.sleep(interval) time interval and feedback. Don’t forget to start your script GPIO.cleanup() with sudo python time_lapse_camera.py else: print “Let’s try again (or press Ctrl + C to quit):\n” Creating a video from the images main() 06 With your camera packed with images, else: we need to now collect and output them as a print “Oops - You can only enter numbers. Let’s try again:\n” video fi le. While it’s technically possible to do on main() the Pi, we’d recommend copying them to an easily accessible folder on a separate Linux PC since print there will be quite a lot of heavy lifting involved. print ‘Done. Thanks for using the Linux User Time-lapse Photography Tool!\n’ We’re going to use FFmpeg. With the terminal again = raw_input(‘Would you like to do another time-lapse? (yes/no):\n -> ‘) open in the folder where your images are stored, proceed = again.lower() in [‘yes’, ‘y’] type: -f image2 -i image%04d.jpg if proceed: -vcodec libx264 -b 800k video.avi. This With the main If and main() obviously assumes you have libx264 installed on For loops complete, else: your machine and the ‘image%o4d.jpg’ assumes print ‘\nSee you next time!\n’ the script uses a the fi le format and the number of digits it’s quit() further If / Else to dealing with (in this case: ‘picture0001.jpg’). See ask if you’d like to ffmpeg.org/ffmpeg.html for full documentation if __name__ == ‘__main__’: shoot again, or quit of FFmpeg’s incredible capabilities, but the fl ags main() we’ve selected should make for good results.

WorldMags.net 33 www.linuxuser.co.uk WorldMags.net Retro games console

Confi gure RetroPie for more power control

Turn your Raspberry Pi into the ultimate portable retro games console

Properly confi gure USB and PS3 Install drivers controllers out of to use the Xbox the box 360 controller

MAKER PROFILE NAME: Make your own retro ROB ZWETSLOOT OCCUPATION: games console TECH WRITER Rob models complex systems and is a web developer profi cient in Get your retro gaming fi x with RetroPie, Python, Django and PHP. He loves a distro for getting the games of to experiment with computing yesteryear onto your Raspberry Pi WHAT YOU'LL NEED » RetroPie There’s a growing trend for people to create their own arcade cabinet or hack together blog.petrockblock.com/download/ their own retro console, and the Raspberry Pi’s size and power makes it perfect for this. retropie-project-image/ Follow our tutorial to turn your Pi into a fully functional emulating powerhouse.

34 www.linuxuser.co.uk WorldMags.net WorldMags.net10 Raspi projects made easy Practical Raspberry Pi projects to amaze and inspire

Install RetroPie 01 Download the latest RetroPie image from the website and unzip it. Like installing other Raspberry Pi distros, you simply need to Adding games to your Raspberry Pi write the image to the SD card with: $ sudo dd bs=4M if=[path to image] is fairly simple of=/dev/[path to sd card]

Initial setup 02 On the fi rst boot, you’ll be asked to confi gure a controller, which can be done with a keyboard, a standard USB controller or a PS3 controller. The initial setup on RetroPie is for very limited controls, and you’ll need to launch a separate tool for better confi g. Navigate RetroPie Calibrating controllers 07 RetroPie will automatically know if there 03 Press the menu button you set up, and are games for a specifi c emulator and allow go to exit. You’ll get to a command line. Connect a 05 Recognising the 360 controller you to access it. Pressing left or right will move USB controller and enter the following: Add the 360 pad to your confi guration fi le between the emulators, which then have options $ cd RetroPie/emulators/RetroArch/ by fi rst going to tools with: to load the games on the SD card. tools $ cd ~/RetroPie/emulators/RetroArch/ …and then: tools $ ./retroarch-joyconfig >> ~/ Then type in the following: RetroPie/configs/all/retroarch.cfg $ ./retroarch-joyconfig -o p1.cfg -p 1 -j 0 Follow on the on-screen instructions to properly And fi nally add the fi les to RetroArch with: confi gure your controller. $ sudo cat p*.cfg >> ~/RetroPie/ configs/all/retroarch.cfg Using an Xbox 360 pad Save and reboot. 04 To use a wired or PC-compatible Xbox 360 controller, you’ll fi rst need to install the correct drivers: $ sudo apt-get install xboxdrv Then edit /etc/rc.local by adding: xboxdrv --trigger-as-button --wid 0 06 Add some games --led 2 --deadzone 4000 --silent & Adding games to your Raspberry Pi is sleep 1 fairly simple. Grab the SD card from the Pi and put it in your PC. Move any ROMs or compatible PC 08 Two players …before exit 0. Change --wid to --id if it’s a wired fi les to the relevant folders in: For multiplayer gaming, it’s best to use controller. Reboot. [path to SD card]/home/pi/RetroPie/roms/ two controllers of the same type to avoid confi g issues. Go to the bottom of ~/RetroPie/confi gs/ all/retroarch.cfg and copy and paste the code from input_player1_joypad_index = “0” to the bottom. Change each instance of player1 to player 2, and a second controller will now work.

Safe restart 09 Some of the emulators can’t be quit out of, meaning you’ll need to physically reboot your Pi by unplugging it each time. We can add a hotkey to exit the emulators by again going to retroarch.cfg and adding to the end: input_enable_hotkey_btn = “X” input_exit_emulator_btn = “Y” …with X and Y being the corresponding numbers of buttons on your controller.

WorldMags.net 35 www.linuxuser.co.uk WorldMags.net File server

The Raspberry Pi will Each Samba user automatically advertise gets access to their its shares on the home folder, as well network – no need to as a folder shared remember IP addresses between all users

Access your shares from Windows, Linux or Mac!

MAKER PROFILE NAME: Liam Fraser OCCUPATION: Programmer and Sysadmin at Web Hosting company

Liam is the creator of the RaspberryPiTutorials YouTube series and volunteers as a Linux server administrator for the Raspberry Pi Foundation

Build a file server WHAT YOU'LL NEED » A router or switch on your Sick of using fl ash drives or email to share network to plug your Raspberry Pi into fi les between computers? Turn your RasPi » (Optional) External storage – an external hard drive or into a server and your problem’s solved! fl ash drive Having a central fi le server in your house will make life easier. You’ll no longer have to » Powered USB hub (if using external hard drive) struggle to share fi les between computers, as you can just save everything in your own mini-cloud on your home network. The Raspberry Pi is perfect for this! » Raspbian latest version

Installing the required software you will only be able to read the storage device Attached SCSI removable disk 01 Log into the Raspbian system with the on other Linux computers unless you reformat it. username Pi and the password ‘raspberry’. Get If you connect the device, you’ll be able to use the the latest package lists using the command dmesg command to fi nd out what the device is sudo apt-get update. Then install the called. (Piping that into tail -n 3 prints the last required packages with the command sudo three lines.) It’s probably /dev/sda. apt-get install samba. Samba will be used to serve fi les and also comes with software to pi@raspberrypi ~ $ dmesg | tail -n 3 advertise fi le shares on the network. [ 1707.371370] sd 1:0:0:0: [sda] No Caching mode page present Connect external storage [ 1707.371403] sd 1:0:0:0: [sda] 02 If you have any external storage, you’ll Assuming drive cache: write through need to prepare it for use with Linux. Note that [ 1707.371422] sd 1:0:0:0: [sda]

36 www.linuxuser.co.uk WorldMags.net WorldMags.net10 Raspi projects made easy Practical Raspberry Pi projects to amaze and inspire

Format external storage Create users for Samba root:sambashare /home/allusers/ 03 Use Parted to create a new partition 05 We now need to create some users to log pi@raspberrypi /home $ sudo chmod table on your external storage device and make a into Samba shares with. Do the above steps for 770 /home/allusers/ single partition the full size of the device. Then run as many users as you’d like to have on the server. pi@raspberrypi /home $ sudo chmod partprobe to reload the partition table, and make Only do the usermod step if you want the user to g+s /home/allusers/ an ext4 fi le system on the new partition. This will be able to use a shared directory for all users. destroy all existing data on the disk. pi@raspberrypi ~ $ sudo adduser liam pi@raspberrypi ~ $ sudo parted /dev/ Adding user `liam’ ... sda Adding new group `liam’ (1002) ... (parted) print Adding new user `liam’ (1001) with Disk /dev/sda: 16.1GB group `liam’ ... (parted) mktable msdos Creating home directory `/home/liam’ Warning: The existing disk label on ... /dev/sda will be destroyed and all Copying files from `/etc/skel’ ... data on this disk will be lost. Do sh: 0: getcwd() failed: No such file you want to continue? or directory Confi guring Samba Yes/No? Yes Enter new UNIX password: 07 Open /etc/samba/smb.conf in an editor (parted) mkpart Retype new UNIX password: using sudo. Scroll down to the Authentication Partition type? primary/extended? passwd: password updated section and uncomment the security = user primary successfully line. Then scroll down to the Share Defi nitions File system type? [ext2]? ext2 Changing the user information for section and change read only to no in the Start? 0GB liam [homes] section. End? 16GB Enter the new value, or press ENTER Finally, scroll down to the bottom of the fi le and (parted) quit for the default add a section for the shared folder. pi@raspberrypi ~ $ sudo partprobe Full Name []: Liam Fraser [allusers] pi@raspberrypi ~ $ sudo mkfs.ext4 / Room Number []: comment = Shared Folder dev/sda1 Work Phone []: path = /home/allusers Home Phone []: read only = no Mount external storage Other []: guest ok = no 04 We’re going to move /home onto our Is the information correct? [Y/n] Y browseable = yes external storage. We’ll do that by mounting it on create mask = 0770 /mnt/storage, moving the fi les from /home to pi@raspberrypi ~ $ sudo usermod -a directory mask = 0770 /mnt/storage, and then mounting the partition -G sambashare liam on the now empty /home. Restart Samba with pi@raspberrypi ~ $ sudo pdbedit -a sudo /etc/init.d/samba restart pi@raspberrypi ~ $ sudo su -u liam root@raspberrypi:/home/pi# cd / new password: root@raspberrypi:/# mkdir /mnt/home retype new password: Connecting to the shares root@raspberrypi:/# mount /dev/sda1 Unix username: liam 08 The Raspberry Pi will advertise its shares /mnt/home/ Full Name: Liam Fraser automatically. Each user will get access to their root@raspberrypi:/# mv /home/* /mnt/ Home Directory: \\raspberrypi\ home folder, as well as the allusers directory. home/ liam If the user isn’t in the sambashares group, they root@raspberrypi:/# umount /mnt/ won’t be able to get it. The syntax for accessing home/ Samba shares is as follows: root@raspberrypi:/# rmdir /mnt/home/ Create a shared directory root@raspberrypi:/# echo ‘/dev/sda1 06 We’re going to create a directory that Windows: \\raspberrypi\share_name /home ext4 defaults 0 1’ >> /etc/ any users in the sambashare group can access fstab and change. Setting the setgid permission on Mac: smb://raspberrypi/share_name root@raspberrypi:/# mount -a a directory (chmod g+s) causes new fi les and root@raspberrypi:/# mount | grep subdirectories created within it to inherit its group Linux: smb://raspberrypi/share_name sda1 ID. This means that each user in the sambashare /dev/sda1 on /home type ext4 group can access and change the fi les. The share name is optional – you should be (rw,relatime,data=ordered) able to browse for them. In fact, you shouldn’t root@raspberrypi:/# ls /home pi@raspberrypi /home $ sudo mkdir / even need to use these; you just need to go to lost+found pi home/allusers the Network section of your fi le manager and root@raspberrypi:/# exit pi@raspberrypi /home $ sudo chown select ‘raspberrypi’.

WorldMags.net 37 www.linuxuser.co.uk WorldMags.net Security camera

MAKER PROFILE NAME: Build a security camera Liam Fraser OCCUPATION: Programmer and Want to keep an eye on something from the Sysadmin at Web comfort of your web browser? All you need is Hosting company Liam is the creator of the RaspberryPiTutorials YouTube a Pi and a webcam! series and works as a Linux server administrator for the Raspberry This article will teach you how to use the MJPG-streamer software to stream video straight from a Pi Foundation webcam to your web browser. You could record the stream, and also display multiple streams from multiple Raspberry Pis on one page. The streams can also be viewed from mobile devices and tablets. WHAT YOU'LL NEED » A router or switch on your network to plug your Raspberry Network investigation and imagemagick, both of which are required by Pi into 01 We’ll want to investigate the network MJPG-streamer. You can install these with » A Linux-compatible webcam that the Pi is on, so we can assign it a static IP sudo apt-get install subversion (we used a Logitech C270) address. That way, we’ll always know where it is libjpeg8-dev imagemagick » Powered USB hub (the webcam on the network. might not have enough power pi@raspberrypi ~ $ ip addr show dev Compile MJPG-streamer without one) eth0 | grep inet 04 Download and compile MJPG-streamer » Latest Raspbian Image www.raspberrypi.org/downloads inet 172.17.173.94/24 brd as shown below: 172.17.173.255 scope global eth0 pi@raspberrypi ~ $ svn checkout svn:// pi@raspberrypi ~ $ ip route | grep svn.code.sf.net/p/mjpg-streamer/code/ default mjpg-streamer-code default via 172.17.173.1 dev eth0 pi@raspberrypi ~ $ cd mjpg-streamer- pi@raspberrypi ~ $ cat /etc/resolv. code/mjpg-streamer use sudo) to include the following lines, ensuring conf pi@raspberrypi ~/mjpg-streamer-code/ that it still ends with exit 0: nameserver 172.17.173.1 mjpg-streamer $ make clean all export STREAMER_PATH=/home/pi/mjpg- streamer-code/mjpg-streamer Assign a static IP address 05 Testing it out export LD_LIBRARY_PATH=$STREAMER_PATH 02 Now that we have the Start MJPG-streamer as follows: $STREAMER_PATH/mjpg_streamer -i network confi guration, we can export LD_LIBRARY_PATH=. “input_uvc.so” -o “output_http.so -w assign a static IP address. Open ./mjpg_streamer -i “input_uvc.so” -o $STREAMER_PATH/www” &s /etc/network/interfaces in an editor such as “output_http.so -w ./www” nano, and change the line: Reboot the Pi to check that it comes back up iface eth0 inet dhcp You have to export the library path variable happily and starts the stream. to a confi guration similar to our expert’s. Reboot to the current directory (.) so that the various Recording the stream to load the new confi guration. input and output plug-ins can be used. Type 07 iface eth0 inet static your Raspberry Pi’s IP address followed by You can easily download a motion JPEG address 172.17.173.94 :8080 into a web browser. Click the Stream tab stream and convert it to a more useful format netmask 255.255.255.0 to view the stream. If the Stream tab doesn’t using VLC: cvlc http://172.17.173.94:8080/?acti network 172.17.173.0 work, try the example that uses JavaScript, as on=stream --sout file/mp4:stream.mp4 broadcast 172.17.173.255 that should work on most browsers, including gateway 172.17.173.1 the Android browser. Alternatively, you can just download the stream URL with wget like so: Start MJPG-streamer at boot wget http://172.17.173.94:8080/?act Installing the required software 06 Edit the /etc/rc.local fi le (you’ll need to =stream 03 Log into the Raspbian system with the username ‘pi’ and the password ‘raspberry’. The MJPG-streamer software isn’t packaged for the Raspberry Pi, so we’ll need to compile it ourselves. Update the package index with the command sudo apt-get update. We Stream video straight from a need to install Subversion, which we’ll use to download source code. We’ll also need libjpeg, webcam to your web browser

38 www.linuxuser.co.uk WorldMags.net WorldMags.net10 Raspi projects made easy Practical Raspberry Pi projects to amaze and inspire

Most USB cameras should Depending on your work pretty much ‘out of the webcam, you may need box’, but it’s worth checking a powered USB hub to compatibility fi rst get it working

It even works from mobile devices and tablets!

MJPG-streamer also allows you to capture still images, which could be useful if put in a script

MJPG-streamer comes with many different methods of accessing the stream, with examples for each

Stream from a webcam straight to your web browser

…if you want the raw data. However, playing it Extensions and improvements back is tricky because you need to specify the

Stream 1

09 This example setup is very basic and number of frames per second to display.

Stream 2

has a few fl aws. There is no authentication or SSL encryption, which means the streams Multiple streams at once are insecure and shouldn’t be shared over the 08 Here is an example of how to put MJPG-streamer is quite simple, so you could streams could come from a number of different You’d be able to do SSL for each Pi you had with a single Pound instance and access the different

Streaming Example

Pis by having something like ‘stream1, stream2’ in the URL.

WorldMags.net 39 www.linuxuser.co.uk WorldMags.net VoIP server

MAKER PROFILE NAME: Build a VoIP server Liam Fraser OCCUPATION: Use your Raspberry Pi as a voice over Programmer and Sysadmin at Web IP server, perfect for phone calls in Hosting company Liam is the creator of the the home or a small business RaspberryPiTutorials YouTube series and volunteers as a Linux RasPBX is a project that brings Asterisk – industry-standard voice over IP server administrator for the software – to the Raspberry Pi. There are VoIP clients for many platforms, Raspberry Pi Foundation including hardware that converts VoIP to a conventional telephone line. Each client gets a phone number and can call other clients. You can also have conference calls, perfect for meetings over the phone. As an extension of this article, you could also share the WHAT YOU'LL NEED VoIP server over the internet, allowing remote clients to connect. » A router or switch on your network to plug your Raspberry Pi into Initial setup address 172.17.173.94 » Smartphones, computers, 01RasPBX is good to go as soon as the netmask 255.255.255.0 or VoIP phones on the same network to use as clients image is fl ashed to your SD card: there is a web network 172.17.173.0 » Powered USB hub (if using interface for confi guration, and SSH is included broadcast 172.17.173.255 external hard drive) for remote login. As this will be a server, we’ll log gateway 172.17.173.1 » The latest RasPBX image in with the user ‘root’ and password ‘raspberry’ www.raspberry-asterisk.org/ and change the IP address to a static one so we Now that we have the network confi guration, downloads always know where it is on the network. we can assign a static IP address. Open root@raspbx:~# ip addr show dev eth0 /etc/network/interfaces in an editor such as | grep inet nano, and change the line: inet 172.17.173.94/24 brd iface eth0 inet dhcp 172.17.173.255 scope global eth0 to a confi guration similar to our expert’s. We Add extensions inet6 don’t have to worry about DNS as Google’s 04 Each device that will be connected needs fe80::ba27:ebff:fef3:9016/64 scope nameservers are being used. You can load the its own extension. To add an extension, hover over link new network confi g using the Applications tab, then select Extensions. root@raspbx:~# ip route | grep sudo /etc/init.d/networking restart Select Generic SIP Device as the device type and default click Submit. The User Extension is the number default via 172.17.173.1 dev eth0 The web Interface to call to get to that device. The Display Name can root@raspbx:~# cat /etc/resolv.conf 03 Type the static IP address of your either be the name of a person or just the same as nameserver 127.0.0.1 Raspberry Pi into a web browser. You’ll be taken the User Extension. The only other thing that you nameserver 8.8.8.8 to the FreePBX web interface for confi guring need to fi ll in is the secret, which is a passphrase nameserver 8.8.8.4 Asterisk. Click the FreePBX Administration that allows the device to connect. One of these button and use the username ‘admin’, and will have been generated, but you can change it Assign a static IP address password ‘admin’. The User Control Panel allows if you like. Scroll to the bottom and click Submit. 02 iface eth0 inet static users to listen to their voicemails. Add as many extensions as you like.

40 www.linuxuser.co.uk WorldMags.net WorldMags.net10 Raspi projects made easy Practical Raspberry Pi projects to amaze and inspire

Call other VoIP We recommend using numbers and have wired networking, their phone ring just especially if you want like a normal call to ‘set and forget’ your VoIP server

The Raspberry Pi makes the perfect server for this kind of project

Add a conference extension 05 Go to the Applications section and select Conferences. Choose a number and name for the conference, and a PIN number if you’d like users Each client to require a PIN to join. Click Submit Changes once you’re done. gets a phone Apply config number and can 06 Changes such as adding extensions and conferences are not made until the Apply Confi g call other clients. button is pressed, so be sure to do that before closing the web interface. You can also have

Trying it out conference calls 07 If you’re using an Android phone, we recommend CSipSimple, which can be found on Google Play. We recommend Linphone for Trying a conference call Linux clients. We’ll use two Android phones as an 08 Call the conference number that you example. When adding an account in CSipSimple, set up from one of the devices. You’ll need to scroll down to the Generic wizards section and enter the PIN code you set followed by the # key. select Basic. Then fi ll in the information as shown You’ll be told that you are the only person in this in the image (right). Once you have two devices set conference, and will hear a notifi cation whenever up, try calling between the two. anyone else joins and leaves the conference.

WorldMags.net 41 www.linuxuser.co.uk WorldMags.net Portable wireless access point

MAKER PROFILE NAME: Create a portable ROB ZWETSLOOT OCCUPATION: wireless access point TECH WRITER Rob models complex systems and With the help of a Wi-Fi adaptor, you can is a web developer profi cient in Python, Django and PHP. He loves turn your Raspberry Pi into a wireless to experiment with computing access point for other devices WHAT YOU'LL NEED The Raspberry Pi’s portability makes it ideal for carrying around as an emergency » Model B Raspberry Pi wireless router and access point – great for some hotels and visiting less tech-adept » Compatible Wi-Fi adaptor friends and family. www.adafruit.com/products/814 » Raspbian Install Raspbian and make a note of it. Turn off the Pi, plug in www.raspberrypi.org/downloads 01 For this project, we can use Raspbian to your wireless adaptor, and turn it back on. In a power our access point. Install the image on an networked computer’s terminal, type: SD card and go through the basic setup process, $ ssh [user]@[IP address] Now we need to set it up. Edit the confi guration making sure to enable SSH. You can also turn off fi le with: the desktop during setup as well if you don’t plan Enter your password to then log in. $ sudo nano /etc/dhcp/dhcpd.conf to use it. Install DHCP Connect through SSH 03 Install a DHCP server to your Pi with: And start by putting a # in front of the two option 02 Find the IP address of your Raspberry $ sudo apt-get install hostapd isc- domain-name entries, then remove the # in Pi by typing ifconfig into the command line, dhcp-server front of ‘authoritative;’, seven lines down

Use a Wi-Fi adaptor to turn your Pi into a wireless access point No need for extra setup with a monitor once confi gured

Create wireless internet wherever there’s an available internet connection

42 www.linuxuser.co.uk WorldMags.net WorldMags.net10 Raspi projects made easy Practical Raspberry Pi projects to amaze and inspire

The Raspberry Pi’s portability makes it ideal for carrying around as an emergency wireless router

address 192.168.42.1 Save and exit. Now edit hostapd to point it to this netmask 255.255.255.0 new fi le with: $ sudo nano /etc/default/hostapd Save and exit, then set wlan0’s address with: $ sudo ifconfig wlan0 192.168.42.1 And then add: /etc/hostapd/hostapd.conf to DAEMON_ Now create a new fi le to use to start creating the CONF=”” wireless network: Server address $ sudo nano /etc/hostapd/hostapd.conf 04 At the end of the confi guration fi le, add Network Addressing these lines: 08 Run: subnet 192.168.42.0 netmask $ sudo nano /etc/sysctl.conf 255.255.255.0 { And add net.ipv4.ip_forward=1 to the range 192.168.42.10 192.168.42.50; bottom of the fi le. option broadcast-address Save this, and then fi nish by running: 192.168.42.255; $ sudo sh -c “echo 1 > /proc/sys/ option routers 192.168.42.1; net/ipv4/ip_forward” default-lease-time 600; -lease-time 7200; Run the following three commands to make sure option domain-name “local”; the internet is forwarded correctly: option domain-name-servers 8.8.8.8, sudo iptables -t nat -A POSTROUTING 8.8.4.4; -o eth0 -j MASQUERADE } sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state Save and exit. RELATED,ESTABLISHED -j ACCEPT sudo iptables -A FORWARD -i wlan0 -o Wireless networking Disable Wi-Fi eth0 -j ACCEPT 05 Edit the server more with: 07 Create your wireless network with the $ sudo nano /etc/default/isc-dhcp- following code: server interface=wlan0 Finish up driver=rtl871xdrv 09 So that this works after a reboot, type: Set INTERFACES to ‘wlan0’ and save. Now open: ssid=[access point name] $ sudo sh -c “iptables-save > /etc/ $ sudo nano /etc/network/interfaces hw_mode=g iptables.ipv4.nat” channel=1 Put a # in front of ‘iface wlan0’ and the following macaddr_acl=0 Then add up iptables-restore < /etc/ lines with ‘wpa roam’, ‘iface default’ and any auth_algs=1 iptables.ipv4.nat to the end of the others affecting wlan0. ignore_broadcast_ssid=0 /etc/network/interfaces fi le. wpa=2 Finally, set it up as a daemon with: Enable access wpa_passphrase=[password] sudo service hostapd start 06 After the line ‘allow-hotplug wlan0’, enter wpa_key_mgmt=WPA-PSK sudo service isc-dhcp-server start the following: wpa_pairwise=TKIP sudo update-rc.d hostapd enable iface wlan0 inet static rsn_pairwise=CCMP sudo update-rc.d isc-dhcp-server enable

WorldMags.net 43 www.linuxuser.co.uk WorldMags.net Voice-control your Pi

We recommend using a powered USB hub for your microphone and any storage you might use

Practically any USB We’ve used a VESA microphone should mount to fi x the RasPi work, but always to the back of the check compatibility monitor. See shop.pimoroni.com

Voice-control your Pi Control your Raspberry Pi using just your voice MAKER PROFILE Ever since Captain Jean-Luc Picard fi rst spoke to the Enterprise computer, there has been NAME: a fascination with verbally interacting with a computer by voice alone. Now you can do the LES POUNDER same with your Raspberry Pi. Special thanks to Steve Hickson and his PiAUISuite… OCCUPATION: FREELANCE Download the software sudo apt-get install libboost1.50- SYSTEM ADMINISTRATOR 01 We start by downloading the suite dev libboost-regex1.50-dev youtube- of software from the repository on GitHub: dl axel curl xterm libcurl4-gnutls- Les has been a strong advocate https://github.com/StevenHickson/PiAUISuite/ dev flac sox libboost1.46 of Linux and free software since archive/master.zip This will take a bit of time, so go grab a drink. 1999, and loves to tinker with hardware and software projects What you are downloading is a suite of software for the Pi; however, we will focus solely on voicecommand. Make the files executable and install WHAT YOU'LL NEED In a terminal, navigate to the download folder 03 To install the tools, we need to navigate » USB microphone and unzip the fi le using unzip master.zip. You to PiAUISuite-master/Install. (check compatibility – your expert used a Zoom H2) will now have a folder called PiAUISuite-master. We now need to make InstallAUISuite.sh executable for all users, so use » Powered USB hub (particularly if using an external hard drive) Download the dependencies chmod 777 InstallAUISuite.sh 02 You will need to install a few » Source code available from https://github.com/ dependencies to build your project, so open a Now that the fi le is executable, let’s install: StevenHickson/PiAUISuite terminal and run the following: sudo ./ InstallAUISuite.sh

44 www.linuxuser.co.uk WorldMags.net WorldMags.net10 Raspi projects made easy Practical Raspberry Pi projects to amaze and inspire

Voicecommand listens for a keyword to work

Plug in the microphone 07 Plug in your powered USB hub and then attach your USB microphone. Give the Pi a few seconds, then use the command lsusb to ensure that your mic is listed. Your expert used a Zoom H2, which has superb Linux compatibility. Your microphone should just work with the Raspberry Pi, but if you need to check, install (sudo apt-get install audacity) and do a test recording.

Little bit of housekeeping The install process the command: 08 04 There are a few fi les that need to be Once you run the script, you will be voicecommand -e made executable by everyone to work. asked to install dependencies, answer yes to In a terminal type in the following. this and it will install them. You may get an error Read the text shown, before pressing Enter. sudo chmod 777 /usr/bin/voicecommand about libboost – ignore it. sudo chmod 777 /usr/bin/speech- You will next be asked what tools you Setting up our commands recog.sh would like to install; answer No to all, except 06 You will now see an empty nano session. sudo chmod 777 /usr/bin/X11/speech- voicecommand, which is the last choice. Commands take the format of: recog.sh WORD==COMMAND This now completes the confi guration.

So, for example, to open a browser use Internet==midori &

Or a new terminal using Terminal==xterm & Our first words 09 Voicecommand listens for a keyword Configuring voicecommand Try those both out, then use Ctrl+O to save, and to work; by default, that keyword is Pi, so in a 05 The script will ask you if you wish to Ctrl+X to exit nano. terminal type in voicecommand -c. This will automatically confi gure the tool; answer No to launch voicecommand in continuous mode. this. The script will now end and leave you at the Note: Appending a command with ‘&’ will make it Now say “Pi” clearly; you will see the terminal terminal. Now we can edit the confi g fi le using run in the background. print Found Audio followed by Recording WAVE ‘stdin’… – this means that it has acknowledged your voice. Now clearly say “Internet”.

Taking it further 10 Your Raspberry Pi should now launch the Midori web browser. Congratulations, you just used your voice to control your Pi! Remember we said that this was a suite of voice-based tools? Well, head on over to stevenhickson.blogspot.co.uk/2013/05/voice- command-v20-for-raspberry-pi.html and learn more about what these tools can do to enhance your future projects. Good luck!

WorldMags.net 45 www.linuxuser.co.uk WorldMags.net Tutorial How safe is your network?

Kali starts up with a top-level The top ten applications Each application has an entry menu entry. Almost all of the that are used most often in the menu. If it is a console- tools available will be listed have their own menu entry. based application, it opens in here, making it easy to start This saves you having to a new terminal with a listing testing your security hunt in the submenus of the options for that tool

How safe is your network? One of the best ways to test your security is to try to tear it apart, and you can do just that with Kali Linux…

Advisor Security is something that everyone needs to or USB drive, allowing you to run forensics on a Joey Bernard As a true renaissance be aware of and something that everyone needs compromised machine. Alternatively, you could man, he splits his time between to deal with. While you can go out and collect install it on a box and set it up on your network for building furniture, helping a number of tools and utilities to help you out, a more permanent security solution. researchers with scientific computing problems and writing there is an easier path. There are several Linux In this tutorial, we’ll use Kali Linux to go Android apps. When the kids let distributions out there that provide an entire suite through one possible set of steps to analyse and him have some time, that is of tools to fit your security needs. One of the more test your local security. We will only be able to Resources popular ones is Kali Linux (originally BackTrack). cover a subset of all of the tools available in Kali There are other ones, like BackBox or Lightweight Linux, but you will learn some basic techniques Kali Linux: www.kali.org Portable Security, which may fit specific needs to monitor your systems and to test your Metasploit: www.metasploit.com better. You can run these off of a bootable DVD defences of them.

46 www.linuxuser.co.uk WorldMags.net WorldMags.netHow safe is your network? Use Kali Linux to test your system security TUTORIAL

Download and install 01 The fi rst step is to get a copy of Kali Linux to work with. The main download page provides downloads in several different formats and for several different architectures. The usual thing to do is to download an ISO and either burn it to a CD or create a bootable USB drive.

monitor the traffi c occurring on your network and construct conversations that you can analyse to see what your network is being used for.

Hardware detection 02 One cool extra that Kali Linux provides is the ability to take a look at your hardware before booting up. It is always a good idea to get a lay-of-the-land look at the hardware you want to investigate. This is a boot option when you start up Kali. Intrace 05 Once you know what kind of conversations are occurring on your network, you may be interested in fi nding out what routes those conversations are taking. Intrace gives you a traceroute-like listing of packet paths by looking at the TCP packets fl owing on your network. Sqlninja 07 Now we need to start poking at security. Microsoft is always a punching bag when it comes to security, and SQL Server is no exception. Most corporate networks use Microsoft software, so you need to test how they are confi gured. Sqlninja is the tool to beat on SQL Netdiscover Server, using techniques like SQL injection. 03 One of the fi rst things to do is to fi nd out who, or what, is on your network. Netdiscover Acccheck Another service that can prove to be a gives you a tool to do IP address mapping on 08 weak point in your systems is SMB, or Samba fi le your network. This is especially useful on Wi-Fi Zenmap sharing. The utility acccheck can be used to run a networks that aren’t using DHCP. 06 After identifying the hosts on your dictionary attack on account passwords, trying to Tcpfl ow network, you will probably need to see what break through Windows authorisation. 04 Once you have a list of hosts, then ports are open on them, and what OS is running you will probably want to look at what kind there. The go-to application for this is Nmap. The of communication is happening. Tcpfl ow will usual GUI front-end used for Nmap is Zenmap.

WorldMags.net 47 www.linuxuser.co.uk WorldMags.net Tutorial How safe is your network?

Forensics mode 09 If you do find a machine that you think may have been compromised, you want to be careful when you try to investigate it. Kali Linux provides a forensics mode on bootup that simply boots up and leaves all local drives unmounted and untouched. That way, you can run tests without changing the state of the system. Offline password cracking 10 One of the things you will want to investigate is if the machine has been compromised due to weak password selections. There are several tools that can be used to try to crack password hashes. Most of these, like Chkrootkit John the Ripper, use dictionary attacks to dig 12 One of the tings you will need to look for out passwords. during an investigation is whether a rootkit has been installed, providing a back entrance to the bad guys. One of the tools you can use to do this is chkrootkit. This utility looks for evidence of common rootkits used for taking over machines. Social engineering 13 One aspect of security that gets neglected is the social aspect. All of the security in the world won’t help if your users aren’t computing safely. Kali Linux provides a social engineering toolkit that you can use to do things like trying out spear-phishing attacks. Guymager 11 In some cases, the machine in question may be too important to leave offline. In these cases, the only option is to make an image of the drive to investigate later before rebuilding. Guymager is one of the tools available to make images for this purpose.

Once you have your network Exploit databases 14 Along with testing the social aspect, you secured, that is only the beginning also need to test the security of the machines

48 www.linuxuser.co.uk WorldMags.net WorldMags.netHow safe is your network? Use Kali Linux to test your system security TUTORIAL

to find any holes. You do this by trying known exploits. Luckily, there is a database full of Android exploits – apktool known exploits online. 20 Once you have your Android device tool passively monitors a network to see what attached, you can run various exploits to get Metasploit machines exist and what OS they run, without root access. These vary, based on what kind of 15 The usual tool used to test a system is letting them know that you are listening. hardware your Android is running on. One type Metasploit, which provides a full framework of exploit may need apktool, in order to open for putting together complete attack vectors. and edit the APK files on your Android device. These include intrusions, compromises and Bluetooth channels to allow for remote access of a 21 You also have another possible security compromised machine. Within Kali Linux, hole. The Bluetooth protocol is used for mice, there are menu items that allow you to start up keyboards and other bits of hardware. But the Metasploit server. There’s also an entry to security was never really thought of in any major grab a dump of diagnostic logs, in case you run sense. Kali Linux provides several tools to look at into issues. Metasploit runs in a client-server the Bluetooth signals travelling around. model, so once you start up the server, you will need to connect with a client in order to try some exploits against the machines that you are responsible for.

Hardware exploits 18 One set of tools that Kali provides that is unique is the ability to test other hardware. There are tools to poke into Android devices, Bluetooth protocols and Arduino systems.

Install on ARM 22 Support from the Kali developers has provided for an ARM architecture version. You can find it on the main download page. There are even instructions on how to install it on a Galaxy Note 10.1 device, including an Armitage installation image. 16 One of the graphical interfaces available to you is Armitage. If you have Conclusion already started Metasploit, then you can tell 23 Hopefully, if you follow these steps, you Armitage to connect to this already-running DDMS can start to get a handle on the security needs server. Otherwise, Armitage can start up a new 19 DDMS is a debugging monitor that gives for your system. This is only a start, though. Metasploit server for you to play with. you low-level access and control of Android There are lots more tools available in Kali Linux machines. You simply need to plug your device than we covered here, so don't be afraid to p0f into a USB port, start up DDMS and check check out what else is available. 17 Once you have your network secured, out what is happening on the device. You do that is only the beginning. You need to keep up need to install an SDK for a specific version with what is happening on your system. The p0f before starting.

WorldMags.net 49 www.linuxuser.co.uk WorldMags.net Tutorial Keep all your machines in line the easy way

Manually add nodes Puppet dashboard Stats on the left Using the tabs, you can and groups using showing daily status give a quick overall filter all the machines the buttons on the with our node health status and review all those in a left-hand side showing compliant particular state

Puppet – keep all your machines in line the easy way Set up your machines to be configured using Puppet so you can keep them in a consistent and workable state Advisor Stuart Burns is an experienced Linux and virtualisation Keeping track of two machines, keeping contents of their files and keep them in sync specialist for a Fortune them in sync is quite easy – for example, repo across your estate. In this how-to guide to 500 company and enjoys files and config files. However, once you start implementing a basic Puppet setup, we show writing about Linux scaling past a machine or two, keeping files how to keep all your files in sync. aligned over tens, hundreds and thousands This tutorial covers the basics of creating a Resources of machines, it becomes a nightmare. If there basic Puppet server and client setup, through to Two networked servers is one thing a network manager likes, it is setting up a few sample configurations that can configuration standards. be deployed, applying different configurations to Ubuntu 12.04: www.ubuntu.com This is where Puppet comes in. Puppet different machines and configuring to clients in Static IPs and full DNS entries allows users to use extend control over the a standard manner.

50 www.linuxuser.co.uk WorldMags.net WorldMags.netKeep all your machines in line the easy way Use the Puppet configuration management system TUTORIAL

Set up the Puppet master You will have to edit the server name to reflect later!). To help with this aim, Puppet thoughtfully 01 Puppet comes in two parts – master your setup. Leave the --test switch on as it’ll show created a site-wide basic config file called and agent nodes. The master node, as the name exactly what is happening in the foreground, site.pp. This is a basic file that is used to create implies, is in charge. This server holds all the making life easier if there’s a need to debug. the configurations. config file goodness (also known as manifests). If you run the command and you get an To create changes on systems, a manifest is For this tutorial we are running Ubuntu 12.04 error ‘warning: Could not retrieve fact fqdn’, it used. A manifest is a number of (or just one) text LTS. Installing Puppet is really straightforward. means you have not set up your DNS properly. files. Within these manifests are the details that Choose one of the hosts and install the Puppet It is strongly recommended that this is fixed configure each part of the system that can be master. Type the command: before proceeding. edited and customised. Looking at a very, very basic manifest – it is sudo apt-get install puppetmaster fairly clear as what it does… file {'myfile': The setup requires the file site.pp to be present path => '/tmp/myfile', (more on what it is later). Do this by using: ensure => present, sudo touch /etc/puppet/manifests/ mode => 0640, site.pp content => "This could be anything.", This installs all the prerequisites of the server. It's good to talk SSL } Set up the Puppet agent 04 The next step is to enable secure 02 The agents sit on the machines that communications between the master and agent. The first line is termed a resource. Resources we want to effectively manage. To install all the Type sudo puppetca --list. This will are groups of similar things that can be components, use the command: show all the client machines that are trying to configured to meet a desired standard. Examples connect to the server to service their requests. In of resources include directories, services and sudo apt-get install puppet order for them to be given access, we must allow files. In other words, basically groups of items them to do so, using the command: that share a commonality. Again, this installs all the requirements for sudo puppet cert --sign clientname The bit after the file resource is what is known the agent or client. It is suggested that you as the title. It can be thought of as the unique do not set Puppet to autostart on boot. If you Look at the agent console while doing this identifier. The bits that follow the identifier are do this, by default the agent will contact the and see the handshake that is going on as the properties and values. To explain it a bit better, Puppet master and update its configuration, if machines are joined together. the resource ‘file’ has a number of properties, needed, every 30 minutes. We are going to run To test if an agent system can see the server, such as the path and the file rights. ours manually, so that there is no waiting to see there is a command that can be used to test. the changes take effect. Introducing some Puppet basics Configure the Puppet 05 Before all the interesting code creation, 03 infrastructure you need to understand how Puppet works. All The next step is to set up the secure the configurations are held in manifest files. communication between the servers. To do Manifests are just source files are what we can this, log into the Puppet agent server and issue edit. All source files end in .pp the command: The whole point of having a Puppet setup is to sudo puppetd --server puppetmaster. ensure that the machines on the site are all the test.local --waitforcert 60 --test same (we can differentiate between server types

WorldMags.net 51 www.linuxuser.co.uk WorldMags.net Tutorial Keep all your machines in line the easy way

Create a new file under classes, call it webserver.pp and put in the following: class webserver { package { "apache2": ensure => "present"; } package { "php5": Testing the Puppet manifests ‘absent’ to make sure it is not! ensure => "present"; } 06 Manifests can be tested on the local package { "apache2": Puppet master machine if you want to (not ensure => "present" service { "apache2": best practice, but will suffice for the tutorial } enable => 'true' needs). Simply save the above into a file, for }} example test.pp. Once you have done that, use With a simple addition, that basic start can be the command: built up to autostart. The resource this time is sudo puppet apply /path/to/test.php ‘service’ . Following on from the above, add: service { "apache2": One item by itself is not very useful, so we enable => 'true' could group together several items in one file. } However, it makes more sense to split down the manifests into the jobs they do – or, to use the proper term, classes. That way you can modify the manifests to meet the requirements for multiple groups. Making the class useful! 09 Once the class is created, it can be referenced in the site.pp file. To make it work, the classes need to be included in the latter. Go back to site.pp and modify it to include the following text: # /etc/puppet/manifests/site.pp import "classes/*" Doing useful stuff with the node default { 07 manifest include webserver It was mentioned before that we could do useful } things with Puppet. For example, it can be made to install an application. This can be done by To import the classes, we just use the import defining the Resource; this time the resource command. The ‘default’ means it is applied to all is ‘package’ and using the ensure property nodes. Notice how we use ‘include webserver’ followed by ‘ensure’ to make sure it is installed or and the class is called webserver? Basically, the class can be called by using ‘include’ suffixed by the class created that is to be referenced. Doing it cleanly with classes The default node is applied to all the nodes. It Putting all these entries in one file is 08 is possible to create nodes with special uses and going to get messy, right? Also what if there are The whole point work only on specific nodes. These nodes are several different configurations? This is where the the same layout as the default, except they have system can be used to differentiate. Use classes of having a Puppet different names. Again, the include can be used to group together bits of code that need to run, to apply several configurations to all new nodes. setup is to ensure but reference it rather than putting all the code directly into site.pp. that the machines If there was a need for a separate a web server Assembling all the parts of Puppet config and a database configuration, they will 10 How do we group machines together and on the site are all have some commonalities and some differences. apply specifics? It’s quite straightforward. Use So create a folder called classes under the the ‘node’ prefix. Again it goes into site.pp. the same manifest folder. An example of adding specific machines is:

52 www.linuxuser.co.uk WorldMags.net WorldMags.netKeep all your machines in line the easy way Use the Puppet configuration management system TUTORIAL

node 'puppetclient2.test.local' inherits database …stating the node with its fully qualified name, and stating that it inherits, or takes on, the setup that is contained in the database class. In this example, puppetclient2 would get all the database configurations defined in the following way: node database { include mysql-server }

Then, when we have a database server, it will read all the classes defined in the node. So, for example, the database nodes get all the class setups contained within MySQL, Apache and phpMyAdmin with their potentially customised configuration. So we can essentially chain together several classes into one node. Note, though, that the default class must always come first! Followed by installing the repository: cd /usr/share/puppet-dashboard sudo -i puppetlabs-release- rake RAILS_ENV=production db:migrate precise. sudo -u www-data /usr/share/ sudo apt-get update puppet-dashboard/script/server -e production Now that we have the repository installed, the dashboard can be installed using the This will load the Puppet server in the command below. It will also install all the other foreground. Watch the console for any errors dependencies needed: that are thrown up. sudo apt-get install puppet- The file /etc/puppet/puppet.conf will need to dashboard be edited. On the client, edit it with these values: sudo apt-get install mysql-server [agent] report=true Now that the files are installed, you will need to set up the database. Run MySQL as root (just Edit /etc/puppet/puppet.conf on the master to while we create the database and users). Each add to the ‘[master]’ section: line needs to be entered one line at a time. reports = store, http CREATE DATABASE dashboard_production reporturl = http://puppetmaster. CHARACTER SET utf8; test.local:3000/reports/upload CREATE USER 'dashboard'@'localhost' IDENTIFIED BY 'password'; The web server can be accessed using the GRANT ALL PRIVILEGES ON following URL: http://puppet-server:3000 Installing the web report interface dashboard_production.* TO Log into the client and then rerun the Puppet 11 There is also a web management 'dashboard'@'localhost'; agent. Once this is done, if the foreground agent interface that can be installed to make is run and the server is active, you will see there reporting and management easier. It is not Once the database is set up, take the is a pending task. straightforward, but using it makes for a more password used above and edit the config file Log into the Puppet master and run the interesting and GUI experience. Installing the with the command: following command: Puppet dashboard on the Puppet master for sudo vi /etc/puppet-dashboard/ cd /usr/share/puppet-dashboard evaluation is okay. database.yml sudo -u www-data env RAILS_ Because of the dependencies you may ENV=production script/delayed_job -p encounter, your life will be much easier if you You will see an a series of text lines, one dashboard -n 4 -m start install it from the Puppet Labs repository. headed with the item ‘Production’. Fill in the Enabling it is quite straightforward, as is password field with my_password. This will run a background collection script shown below. that will populate the web server with collected data. And there you have it. On the Puppet master, use the following Configure the data collection command to get the repository details: 12 Once the database is created, it needs wget http://apt.puppetlabs.com/ to be populated. This is done using the following puppetlabs-release-precise.deb set of commands:

WorldMags.net 53 www.linuxuser.co.uk WorldMags.net Tutorial Speed up Linux with Openbox

Speed up a core part of your Use Openbox as a desktop system by using Openbox instead environment for super-speedy of the standard window manager and customisable workflow

Maintain the other aspects of your Personalise Openbox to make it favourite desktop environment while more usable in the way you wish with using the lighter, faster Openbox docks, and extra menus Speed up Linux with Openbox Learn how to install and properly configure the lightweight window manager Openbox and speed up your day-to-day computing without sacrificing usability

We’re always looking for ways to speed up our via the website. It can noticeably speed up your Advisor systems. Whether we’re trying out lighter distros desktop, especially if you’re using GNOME, KDE Rob Zwetsloot models complex or desktop environments, building from scratch and the like. systems and is a web or selecting the perfect array of apps, there are Openbox can also be used as your main, developer proficient in Python, Django and PHP. many ways to accomplish this. One of the ways supercharged and minimal desktop environment. He loves to experiment that can sometimes get overlooked, though, It uses a much simpler layout than some of the with computing is changing your window manager – the set of more popular desktop environments; however, packages that handles the actual windows of it’s perfectly usable with a few tweaks and may your desktop. just greatly increase your workflow. One of the most popular and lighter window The best part is, you can go back easily to your Resources managers is Openbox. It’s one of the main old desktop or windows manager whenever, Openbox: window managers in LXDE, and readily available thanks to the way Linux login managers handle openbox.org/wiki/Openbox:Download to a lot of distros either through their repos or desktop sessions.

54 www.linuxuser.co.uk WorldMags.net WorldMags.netSpeed up Linux with Openbox Configure the Openbox lightweight window manager TUTORIAL

Desktop compositing 07 For Docky to work properly, there needs to be some degree of desktop compositing. One of the best ways to do this while still keeping a quick system is to use xcompmgr. Install on Fedora with: $ sudo yum install xcompmgr Log into Openbox 04 Log back out and select the Openbox Install Openbox desktop from your session manager. After 01 Installing Openbox to your system is very logging back in, you’ll be presented with a easy. You can find it in your graphical package basic grey desktop and not much more. Right- manager or software centre, or install it with the clicking will open up some options; for now, following for Debian-based systems: open the terminal. $ sudo apt-get install openbox …and for Fedora it’s: Backgrounds $ sudo yum install openbox 08 To be able to set a background image and fully customise your Openbox desktop, the best package for the job is Nitrogen. It comes with a graphical interface to choose backgrounds and can be installed with: $ sudo apt-get install nitrogen

System tray 05 To get a panel with open windows and system trays, your best bet is to install tint2. To do this, you’ll need to simply install it using the terminal we just opened. The package is called Use Openbox tint2, so for Fedora it would be: 02 Log out of your distro. MDM, GDM, $ sudo yum install tint2 LightDM and KDM will all allow you to select a session at the login screen – open the selection Saving screens and you’ll see that you now have the option to use 09 You can install a screensaver to Openbox GNOME/Openbox or KDE/Openbox. by using the basic xscreensaver. Install it with something like: $ sudo yum install xscreensaver xscreensaver-gl To modify it, run xscreensaver-demo from the terminal. This also adds power management options.

Autostarting 10 These will not automatically start when logging into Openbox, so we need to create an autostart script to deal with it. Create a config Basic configure Docking directory with: $ mkdir ~/.config/openbox 03 Openbox is highly configurable, and the 06 You can create a shortcut dock for apps most basic configuration can be found in the to live on, similar (but better) than what you get …and then open a new autostart file with: graphical manager for this. Here you can change in OS X. It was used in Fuduntu, and is nice and $ nano ~/.config/openbox/autostart the windows , the way the windows react lightweight. To install Docky in something like during your workflow, and whether or not you Debian, use: want to use a dock. $ sudo apt-get install docky

WorldMags.net 55 www.linuxuser.co.uk WorldMags.net Tutorial Speed up Linux with Openbox

self.disable_buttons() self.status.set_ label("Shutting down, please standby...") os.system("dbus-send --system --print-reply --dest=\"org. freedesktop.ConsoleKit\" /org/ freedesktop/ConsoleKit/Manager org. freedesktop.ConsoleKit.Manager.Stop") def create_window(self): self.window = .Window() title = "Shut down " + getpass.getuser() + "? Choose an Start script Python imports option:" 11 Add the individual elements to the 14 Set up the script so we can use the self.window.set_title(title) autostart script like so: necessary Python elements with: self.window.set_border_ nitrogen --restore & #!/usr/bin/env python width(5) tint2 & self.window.set_size_ xcompmgr -c -t-5 -l-5 -r4.2 -o.55 & import pygtk request(500, 80) docky & pygtk.require('2.0') self.window.set_ xscreensaver -no-splash & import gtk resizable(False) import os self.window.set_keep_ Press Ctrl+X and save the script. import getpass above(True) Numlock on self.window.stick Shutdown confirmed 12 By default, the numlock will not be kept self.window.set_position(1) on when logging into Openbox. To get this to 15 For a simple shutdown button, you'll self.window.connect("delete_ happen at startup, install the numlock x package need to do the following in the script: event", gtk.main_quit) with yum or apt-get, and then add this line to the class cb_exit: windowicon = self.window. autostart script: def disable_buttons(self): render_icon(gtk.STOCK_QUIT, gtk. numlockx on & self.shutdown.set_ ICON_SIZE_MENU) sensitive(False) self.window.set_ def shutdown_action(self,btn): icon(windowicon)

Shut down 13 Openbox doesn’t have a specific menu that lets you shut down graphically. Crunchbang, a Linux distro that uses Openbox, has a great Python script for this that we can borrow from. First of all, create the shutdown menu script with: $ sudo /usr/bin/cb-exi

56 www.linuxuser.co.uk WorldMags.net WorldMags.netSpeed up Linux with Openbox Configure the Openbox lightweight window manager TUTORIAL

def cancel_action(self,btn): self.disable_buttons() gtk.main_quit()

And then adding the button with: self.cancel = gtk.Button(stock = gtk.STOCK_CANCEL) self.cancel.set_border_width(4) self.cancel.connect("clicked", self. cancel_action) self.button_box.pack_start(self.cancel) self.cancel.show() Menu button 20 To add this shutdown menu to the Openbox menu, you'll need to install obmenu. This graphical tool can help you add apps and scripts to the menu, and is easy to use and very customisable. Install it with something like: $ sudo yum install obmenu

Shutdown button self.vbox = gtk.VBox() 16 That’s the function of the button set up; self.vbox.pack_start(self. now for the window and button: button_box) self.button_box = gtk.HBox() self.vbox.pack_start(self. self.button_box.show() label_box) self.shutdown = gtk.Button("_ self.vbox.show() Shut down") self.window.add(self.vbox) self.shutdown.set_border_ self.window.show() width(4) def __init__(self): self.shutdown. self.create_window() connect("clicked", self.shutdown_ def main(): action) gtk.main() Add button self.button_box.pack_ if __name__ == "__main__": 21 Open obmenu, and expand the start(self.shutdown) go = cb_exit() Openbox 3 arrow. Choose a place to add the self.shutdown.show() main() button and press New Item. Give it any label you Restart button wish, such as Shutdown, make sure Action is set to Execute, and set the Execute command to To add a reboot button involves almost 18 /usr/bin/cb-exit. the same code as the shutdown button. While defining reboot_action, make it the same as shutdown_action, but make sure to use the .Restart function from the ConsoleKit. Create the reboot button by simply replacing ‘shutdown’ with ‘reboot’ in the same code.

Extra menus From here you can add extra buttons, Shutdown window 22 apps and functions to the right-click menu Finally, we finish off the script like so: 17 and customise your experience. There’s a lot of self.label_box = gtk.HBox() extra customisation you can do with Openbox in self.label_box.show() general as well, with theming options, behaviour self.status = gtk.Label() options and much more. self.status.show() Cancel button self.label_box.pack_ 19 You can add a cancel button by defining start(self.status) cancel_action like so:

WorldMags.net 57 www.linuxuser.co.uk WorldMags.net Tutorial Python for beginners: A graphical interface

Python for beginners: A graphical interface Bring everything together with a Python GUI and take the next step in programming your own software

AUTHOR Rob Zwetsloot Over the last few issues we’ve created three modules into our main graphical script. We’ll models complex systems basic games in Python; however, they all ran also modify the existing code to add some and is a web developer in the command line or via IDLE, a Python graphical elements. To do all this we’ll be using proficient in Python, Django and PHP. He loves to IDE. While this allowed us to show off different Tkinter, a default module available in Python experiment with computing ways to use Python code, we didn’t show you that allows you to create windows and frames how to present it. In this tutorial, we will take all with fairly simple code. three games and put them all into one unified All you need for this tutorial is an up-to-date Resources graphical interface. copy of Python, from your distro’s repository To this end, we’ll be making use of the small or the website, and the IDLE development Python 2: www.python.org/download line of code we added at the bottom of each environment. This will also work great on IDLE: www.python.org/idle previous tutorial so we can import them as Raspberry Pi distros, such as Raspbian.

The start Main Interface Code Listing Here we’re doing some minor setup, including getting a new #!/usr/bin/env python2 module that helps us create a simple graphical interface #Linux User & Developer presents: Mega Microgrames Collection The imports from Tkinter import * We’re importing the three games we created in past issues so we can call upon or use them import rockpaperscissors The window import hangman import pokerdice Create a graphical window and give it a name so we can add some functions to it root = Tk() The frame root.title (“Linux User & Developer’s Mega Microgames Collection”) Define the dimensions of the window and give a rough guide to mainframe = Frame(root, height = 200, width = 500) placement of the objects within mainframe.pack_propagate(0) mainframe.pack(padx = 5, pady = 5) The welcome Print a message in the window and place it in a specific intro = Label(mainframe, text = “””Welcome to Linux User & Developers Mega orientation. This works a little differently to print Microgames Collection. Please select one of the following games to play: The button “””) The focus of this month’s tutorial is making Rock-Paper- intro.pack(side = TOP) Scissors work in a graphical interface, so we’re calling a new function we’re creating rps_button = Button(mainframe, text = “Rock, Paper, Scissors”, command = rockpaperscissors.gui) The interface rps_button.pack() Creating and formatting buttons to start the other two tutorial games in the command line or hm_button = Button(mainframe, text = “Hangman”, command = hangman.start) hm_button.pack() The exit Here we create a button that quits the window and ends pd_button = Button(mainframe, text = “Poker Dice”, command = pokerdice.start) the script. We’ve also placed it specifically at the bottom of pd_button.pack() the window exit_button = Button(mainframe, text = “Quit”, command = root.destroy) The loop exit_button.pack(side = BOTTOM) The mainloop allows the main window to continue to work and be updated without exiting the program unless specified root.mainloop()

58 www.linuxuser.co.uk WorldMags.net WorldMags.netPython for beginners: A graphical interface Create a GUI for the three games we made in previous tutorials TUTORIAL

New imports Import new modules that allow us to create the GUI Modified RPS Code Listing #!/usr/bin/env python2 part of Rock, Paper, Scissors, as well as removing the modules we no longer need # Linux User & Developer presents: Rock, Paper, Scissors: The Video Game: The Module from Tkinter import * New interface from ttk import * Our new main function allows us to call the import random majority of the game script when the rps_button is pressed. This contains the game components and def gui(): the graphical components rock = 1 paper = 2 New start scissors = 3 We’ve changed the start function so that it no names = { rock: “Rock”, paper: “Paper”, scissors: “Scissors” } longer goes to the score function after it’s finished. rules = { rock: scissors, paper: rock, scissors: paper } We’ve also removed the score function, as we track that differently so it can be displayed properly def start(): while game(): pass New game We’ve changed the game function so that it now def game(): player = player_choice.get() takes the input from our graphical interface. We computer = random.randint(1, 3) Perfect use a new variable to do this that works with the computer_choice.set(names[computer]) GUI, otherwise it works roughly the same as before result(player, computer) for your def result(player, computer): Raspberry New results new_score = 0 The result function remains largely unchanged, if player == computer: Pi only now it sends the outcome message to a result_set.set(“Tie game.”) else: variable we use for the interface, and generally if rules[player] == computer: uses the new GUI’s variables result_set.set(“Your victory has been assured.”) new_score = player_score.get() New window new_score += 1 player_score.set(new_score) We create the game window with a slightly different else: method due to already having a ‘mainloop’ root result_set.set(“The computer laughs as you realise you have been defeated.”) window. We’re also giving it a name so you can new_score = computer_score.get() new_score += 1 identify it properly computer_score.set(new_score) New variables rps_window = Toplevel() Our new variables are set up so they can interact with rps_window.title (“Rock, Paper, Scissors”) both the game code and the interface code properly. player_choice = IntVar() We’ve also made sure to have a default selection for computer_choice = StringVar() the player so that the code runs properly result_set = StringVar() player_choice.set(1) player_score = IntVar() New frame computer_score = IntVar() Determine the size and layout of the window for the game using a slightly different method than rps_frame = Frame(rps_window, padding = ‘3 3 12 12’, width = 300) rps_frame.grid(column=0, row = 0, sticky=(N,W,E,S)) before. We’ve also allowed for elements to be rps_frame.columnconfigure(0, weight=1) anchored in certain positions around the window rps_frame.rowconfigure(0,weight=1) Label(rps_frame, text=’Player’).grid(column=1, row = 1, sticky = W) New choice Radiobutton(rps_frame, text =’Rock’, variable = player_choice, value = 1).grid(column=1, Here we place radio buttons in a specific row=2, sticky=W) configuration in the window, giving the user the Radiobutton(rps_frame, text =’Paper’, variable = player_choice, value = 2).grid(column=1, choice of three moves. This is then passed along to row=3, sticky=W) Radiobutton(rps_frame, text =’Scissors’, variable = player_choice, value = the variable and used by the game code 3).grid(column=1, row=4, sticky=W) New move Label(rps_frame, text=’Computer’).grid(column=3, row = 1, sticky = W) Label(rps_frame, textvariable = computer_choice).grid(column=3, row=3, sticky = W) Here we allow for the computer’s move to be displayed under the ‘Computer’ label Button(rps_frame, text=”Play”, command = start).grid(column = 2, row = 2) New button Label(rps_frame, text = “Score”).grid(column = 1, row = 5, sticky = W) Label(rps_frame, textvariable = player_score).grid(column = 1, row = 6, sticky = W) Pressing the Play button we’ve put here runs the game script, prints out the scores and finally a Label(rps_frame, text = “Score”).grid(column = 3, row = 5, sticky = W) message based on the outcome Label(rps_frame, textvariable = computer_score).grid(column = 3, row = 6, sticky = W) Label(rps_frame, textvariable = result_set).grid(column = 2, row = 7) New ending We’ve changed this so that the main script begins if __name__ == ‘__ main__’: with gui now rather than the start function gui()

WorldMags.net 59 www.linuxuser.co.uk WorldMags.net Tutorial Python for beginners: A graphical interface

#!/usr/bin/env python2 01 MAIN WINDOW #Linux User & Developer presents: Mega Microgrames Collection The main interface window that this code creates is fairly basic, 02 from Tkinter import * but contains the functions we require. The window exit button will do the same job as the Quit import rockpaperscissors button, and the Hangman and 03 import hangman Poker Dice buttons run the old import pokerdice scripts in the Python shell.

root = Tk() 04 root.title (“Linux User & Developer’s Mega Microgames Collection”)

mainframe = Frame(root, height = 200, width = 500) 05 mainframe.pack_propagate(0) mainframe.pack(padx = 5, pady = 5)

intro = Label(mainframe, text = “””Welcome to Linux User & Developers Mega Microgames Collection. Please select one of the following games to play: 06 “””) intro.pack(side = TOP)

07 rps_button = Button(mainframe, text = “Rock, Paper, Scissors”, command = rockpaperscissors.gui) rps_button.pack()

hm_button = Button(mainframe, text = “Hangman”, command = hangman.start) 08 hm_button.pack()

pd_button = Button(mainframe, text = “Poker Dice”, command = pokerdice.start) pd_button.pack()

exit_button = Button(mainframe, text = “Quit”, command = root.destroy) exit_button.pack(side = BOTTOM) 09 root.mainloop()

First line three games. We added the line at the bottom it a minimum height and width in pixels. We 01 As we’ve done before, we use this line of each script so we can do this. To make sure use pack_propogate to create the window, and to enter the path to the Python interpreter. This to differentiate the functions in each game, we then make sure it’s the size that we’ve defined. allows us to run the program inside a terminal or will have to specify [module].[function] so there We’ve then used pack to pad the borders, otherwise outside of a Python-specific IDE like are no errors in the code. allowing the contents of the window to not IDLE. Note that we’re also using Python 2 for this touch the sides of it. particular script. Root window Introductions We create the intro variable as a label Import graphics 04 Using the Tk() function creates the 06 that lives in the main frame. We give it text to Tkinter is the graphical interface we’re window we’re going to be placing everything in. 02 introduce the interface, using the triple quote using and while it’s a standard Python function, We’ve called it root for now; however, you can marks to have it go across multiple lines and you’ll need to import the module so you can use it. call it anything, as long as you’re consistent. format better. We then use pack to display it, and We’ve used the ‘from [module] import *’ method We’ve also named it using the title command tell Tkinter to put it at the top of the interface. so that we can use the functions from it without from Tkinter and a string of text. having to add Tkinter at the beginning. Main frame Rock, Paper, Scissors 05 The first line has us set the variable 07 We create a button for the Rock, Paper, Import games mainframe as a Frame in the interface. We’ve Scissors game using the Button function. We 03 We’re importing the modules for the attached it to root, the main window, and given attach to it the main frame, give it a label using

60 www.linuxuser.co.uk WorldMags.net WorldMags.netPython for beginners: A graphical interface Create a GUI for the three games we made in previous tutorials TUTORIAL

#!/usr/bin/env python2

# Linux User & Developer presents: Rock, Paper, Scissors: The Video Game: The Module 10 from Tkinter import * from ttk import * import random

11 def gui():

rock = 1 PYTHON SHELL paper = 2 scissors = 3 Our other code will run in the shell 12 or via a command line in the same way as before when the buttons names = { rock: “Rock”, paper: “Paper”, scissors: “Scissors” } are pressed. rules = { rock: scissors, paper: rock, scissors: paper }

def start(): 13 while game(): pass

def game(): player = player_choice.get() 14 computer = random.randint(1, 3) computer_choice.set(names[computer]) result(player, computer) text that appears on the button, and then have there, and with a few modifications the code will Start function it run a command. In this case, we use the run independently of the main interface. We’ve 13 We’ve removed the part that calls modified rockpapershotgun.py code that has a removed the time module, as we no longer need the score function from the start function, gui function, hence rockpapershotgun.py. We it, and imported not only the Tkinter module, as we have the interface handle the scoring then use pack to place it in the window but the ttk module. The ttk module allows us to now. It still calls upon the game function, arrange the GUI in a grid, which will be slightly though, putting it into a loop so it can be Other games easier to use and understand. used continuously. This function is called by 08 For the other two games, the code is the interface to begin the game by setting a mostly the same; however, we call upon the start Game interface computer move and then comparing it to the function in both of them. In the final interface, 11 One of the biggest changes we’re making player’s choice. this will cause the games to run in the shell or to this script is having it all contained in one command line as they’ve been running before. function, ‘def gui’. The interface code needs to Game function be put into a function, otherwise it will be run 14 The game function has had a few Break the loop during import. While we’ve chosen to put the modifications to make sure it works with 09 The exit button works similarly to the entirety of the code in a function, you can also the interface. First of all, the player variable other buttons we’ve created, but instead it uses try just having the graphical interface code in is retried using get() on the special variable the command root.destroy. This ends the loop one. All our variables are kept in here so that we’ve created to contain the player choice. that we’ve created with root.mainloop(), which they still work properly. We do a similar thing for the computer, using allows the interface code to continue looping, ‘set’ to change the variable in our interface- allowing us to continually use it. We place the Game variables friendly computer_choice value. We still use exit button at the bottom of the window with 12 The variables are staying the same the name variable to set the text that goes into ‘side = BOTTOM’. so that we can do the same comparisons we computer_choice. This then passes the player made in the original code. We’ve put them into and computer variables along in the same way Game code the function itself so that they don’t affect the we did before. 10 Nothing much has changed in the start of other imported code into the main interface – this code, other than a few import changes. The and so that when calling just this function, we code for running it in the command line is still don’t need to use global to bring them in.

WorldMags.net 61 www.linuxuser.co.uk WorldMags.net Tutorial Python for beginners: A graphical interface

15 def result(player, computer): new_score = 0 if player == computer: 16 result_set.set(“Tie game.”) else: if rules[player] == computer: result_set.set(“Your victory has been assured.”) 17 new_score = player_score.get() new_score += 1 player_score.set(new_score) else: result_set.set(“The computer laughs as you realise you have been defeated.”) 18 new_score = computer_score.get() new_score += 1 computer_score.set(new_score) GAME WINDOW rps_window = Toplevel() In its default state, the game 19 rps_window.title (“Rock, Paper, Scissors”) window will have rock selected and no message will be displayed. player_choice = IntVar() Once the player makes a move, the message will be displayed at the computer_choice = StringVar() bottom and the computer’s move result_set = StringVar() 20 will be printed. There’s no quit player_choice.set(1) button on this menu, but clicking player_score = IntVar() the window exit will bring you back computer_score = IntVar() to the main interface.

make. We set the result_set like we did in the it a name, which will not change the main tie game, with a different message to the user. window’s name in the process. Finally, we set the new_score variable to be the Result function current player score, using the get function to Interface variables 15 The result function still takes the same obtain it, plus one to the score, and then use 20 Here is the reason we had to call and two variables as before, which we set in the set again to put it back into the player_score change the variables in a different manner. game function. While technically we can use variable. We can’t use += with the player_score For Tkinter, we need to let the interface know the variables set up for the interface, these variable, as it is not a standard variable. whether or not a variable is an integer or a text are not pure integers and can cause an error if value. IntVar and StringVar allow for these not handled correctly. With that in mind, we’ve Lose respectively. We’ve also set the player_choice created an empty new_score variable that we 18 This part of the overall if statement variable to be one, which we have already set as can use to effectively clean the interface value works in the same way as before, by assuming the choice for rock. This means there will at least before adding it back into it. that if it isn’t a tie or a win, it’s a loss. Like the be a default choice when the game is started, new version of the win code, it then uses set and it won’t cause an error. Tie to change the message that will be displayed 16 The logic for determining the result is to the player, and calls upon and changes Game frame the same as before. We first do the easy check – the computer score by putting it through the 21 We’ve created the frame for our whether or not the numeric value for the player new_score variable. interface items slightly differently. Instead and computer variable is the same. What changes of using the pack command in the main this time is that, instead of printing the text, New window interface, we’re using grid to make sure they’re we send the “Tie game” message to our result 19 As the original window is part of the orientated in such a way that makes sense variable using the set function from Tkinter. mainloop, we cannot have the window be for the user. Padding does just that, setting created using Tk() like in the main interface up values to make sure the items in the frame Win code. As this window is coming off it, though, don’t touch the edge of the window. Using the 17 The if statement continues by seeing if we instead create it using Toplevel(). This .grid command, we then create this frame. the player has won. Like before, we use the rules allows the window to run separately and on The row and column variables allow for rows we set to make the comparison for the code to top of the main window. We’ve also given and columns to be included in the structure of

62 www.linuxuser.co.uk WorldMags.net WorldMags.netPython for beginners: A graphical interface Create a GUI for the three games we made in previous tutorials TUTORIAL

rps_frame = Frame(rps_window, padding = ‘3 3 12 12’, width = 300) rps_frame.grid(column=0, row = 0, sticky=(N,W,E,S)) 21 rps_frame.columnconfigure(0, weight=1) rps_frame.rowconfigure(0,weight=1)

Label(rps_frame, text=’Player’).grid(column=1, row = 1, sticky = W) Radiobutton(rps_frame, text =’Rock’, variable = player_choice, value = 1).grid(column=1, row=2, sticky=W) 22 Radiobutton(rps_frame, text =’Paper’, variable = player_choice, value = 2).grid(column=1, row=3, sticky=W) Radiobutton(rps_frame, text =’Scissors’, variable = player_choice, value = 3).grid(column=1, row=4, sticky=W)

Label(rps_frame, text=’Computer’).grid(column=3, row = 1, sticky = W) 23 Label(rps_frame, textvariable = computer_choice).grid(column=3, row=3, sticky = W)

24 Button(rps_frame, text=”Play”, command = start).grid(column = 2, row = 2)

Label(rps_frame, text = “Score”).grid(column = 1, row = 5, sticky = W) Label(rps_frame, textvariable = player_score).grid(column = 1, row = 6, sticky = W)

25 Label(rps_frame, text = “Score”).grid(column = 3, row = 5, sticky = W) Label(rps_frame, textvariable = computer_score).grid(column = 3, row = 6, sticky = W)

Label(rps_frame, textvariable = result_set).grid(column = 2, row = 7)

if __name__ == ‘__ main__’: 23 gui()

the window, and the sticky allows us to justify a second label to display the actual move. We computer. We label these the same way we’ve items with specific directions – in this case top, do this by adding the textvariable option to done with labelling the Player and Computer left, right and bottom justification. Finally, we Label, and using the computer_choice variable move, having them on a lower row but still in then make sure each column and row is treated we updated earlier in the game function. This the relevant columns. Below that, we use the equally by giving them the same weighting, and merely prints the text from the names list and textvariable option again to get the numerical starting from zero. justifies this to the left. score we assigned to the separate score variable. Finally, we create another label to Player’s choice Press Play display the message for the game’s outcome 22 We create a label for the player’s move 24 The running of the code all hinges on and assign it to a grid location, on the first row, the Play button. It’s very simple: we put it in the End game on the first column. We also justify it to the left row between the Player and Computer move as 26 The final part of the code allows for using ‘sticky = W’. We then add the radio buttons part of our three-column system; and it runs the the script to be used by the main window, and for the player’s move, each on the same column start function using the command option. Due to also allows for it to run on its own when used but the following row down. We give each choice the loop of the interface, we can keep pressing in the command line or shell. You’ll need to a name, then assign it to the player_choice this without needing to be asked to play again. perform some modifications to make it run on variable. We then make each choice have a Simply exiting the window will go back to the its own, such as making it the mainloop and not numerical value that corresponds to the moves main interface window as well, meaning we do a Toplevel window. However, it will run just fine we’ve determined in the first set of rules. not need a specific quit button. from both without the need to be launched from the main interface. Computer’s move Running score 23 We display the computer move here. 25 We have two sets of scores to display First of all, we label what this is and then create – one for the player and the other for the

WorldMags.net 63 www.linuxuser.co.uk WorldMags.net Tutorial Create and save data with a MongoDB database

The replica set consists of nodes 192.168.2.4 (port 27019), 192.168.1.10 (port 27019) and 192.168.2.3 (port 27018)

The replica set is Which is the recovering primary node Synchronising data to node 192.168.2.3 Create and save data with a MongoDB database Forget about joins and SQL and try NoSQL databases – specifi cally MongoDB, the leading example Advisor Mihalis Tsoukalos has MongoDB is an open source document- and Scala – support MongoDB. It is suitable for over 15 years of UNIX sysadmin and oriented database system written in C++ by many things, including archiving, event logging, programming experience and has Dwight Merriman and Eliot Horowitz. It runs storing documents, agile development, real-time been using Linux since 1993. He loves learning new things on UNIX machines as well as Windows and statistics and analysis, gaming, and mobile and supports replication and sharding (aka horizontal location services. Resources partitioning) – the process of separating a single This article will show you how to store Apache database across a cluster of machines. log fi les in a MongoDB database with the help MongoDB: www.mongodb.org Many programming languages – including C, of a small Python script. We’ll also demonstrate Pymongo: api.mongodb.org/python/current/ C++, Erlang, Haskell, Perl, PHP, Python, Ruby how to implement replication in MongoDB.

64 www.linuxuser.co.uk WorldMags.net CreateWorldMags.net and save data with a MongoDB database Store Apache log fi les and implement replication in MongoDB TUTORIAL

Connecting to MongoDB for the 01 fi rst time Your Linux distribution probably includes a MongoDB package, so go ahead and install it. Alternatively, you can download a precompiled binary or get the source code from www.mongodb.org and compile it yourself. After installation, type mongo --version to fi nd out the MongoDB version you are using and mongo to run the MongoDB shell and check if the MongoDB server process is running. Inserting an Apache log fi le into 04 MongoDB Now that you know some things about MongoDB, it is time to do something interesting and useful. A log fi le from Apache will be MongoDB inserted inside a MongoDB database using a Python script. is supported The Python script is executed as follows: $ zcat www6.ex000704.log.gz | by many python2.7 storeDB.py programming MongoDB terminology …where www6.ex000704.log.gz is the name of the compressed (for saving disk space) log fi le. 02 NoSQL databases are designed for languages the web and do not support joins, complex transactions and other features of the MongoDB server is running on localhost and SQL language. You can update a MongoDB listens to port 27017. For every inserted BSON database schema without downtime, but you document, its _id fi eld is printed on screen. should design your MongoDB database without Finally, the script prints the total number of joins in mind. documents inserted in the MongoDB database. Their terminology is a little different from the The host and its port number are hard-coded terminology of relational databases and you inside the script, so change them to match yours. should familiarise yourself with it. Connecting to MongoDB using 06 PyMongo You fi rst need to connect to MongoDB using: connMongo = The _id fi eld pymongo.Connection('mongodb:// 03 Every time you insert a BSON localhost:27017') document in MongoDB, MongoDB You then select the database name you want automatically generates a new fi eld (LUD) using the following line of code: called _id. The _id fi eld acts as the primary db = connMongo.LUD key and is always 12 bytes long. To fi nd And fi nally you select the name of the collection the creation time of the object with _id (apacheLogs) to store the data: ‘51cb590584919759671e4687’, execute the logs = db.apacheLogs following command from the MongoDB shell: After fi nishing your interaction with MongDB > ObjectId("51cb59058491975967 you should close the connection as follows: 1e4687").getTimestamp() connMongo.close() ISODate("2013-06-26T21:11:33Z") The storeDB.py Python script Note: You should remember that queries are 05 The storeDB.py script uses the PyMongo case-sensitive. Python module to connect to MongoDB. The

WorldMags.net 65 www.linuxuser.co.uk WorldMags.net Tutorial Create and save data with a MongoDB database

$ mongod --port 27018 --bind_ip 192.168.2.5 --dbpath ./mongo5 --rest --replSet LUDev Note: You are going to see lots of output on your screen. More information about the three 10 MongoDB servers You should specify the name of the replica set (LUDev) when you start the MongoDB server and have the data directory, specifi ed by the --dbpath parameter, already created. You do not necessarily need three discrete Linux machines. You can use the same machine (IP address) as long as you are using different port numbers and directories.

The rs.initiate() command 11 Once you have your MongoDB server processes up and running, you should run the rs.initiate() command to actually create and enable the replica set. If everything is okay, you will see similar output on your screen. If the MongoDB server processes are successfully running, most errors come from misspelled IPs or port numbers. The rs.initiate() command is simple but has a huge impact!

Displaying BSON documents from power outage. Can you access your data? Is your Information about replication 07 the apacheLogs collection data safe? 12 • Any node can be primary, but only one Type the following in order to connect to the To avoid such diffi cult questions, you can node can be primary at a given time. MongoDB shell: use replication to keep your data both safe • All write operations are executed at the $ mongo and available. Replication also allows you to do primary node. Select the desired database as follows: maintenance tasks without downtime and have • Read operations go to primary and optionally to > use LUD MongoDB servers in different geographical areas. a secondary node. See the available collections for the LUD • MongoDB performs automatic failover. database as follows: Running the three MongoDB • MongoDB performs automatic recovery. > show collections 09 servers from the command line • Replication is not a substitute for backup, so apacheLogs For this example, you need three MongoDB you should not forget to take backups. system.indexes server processes running. Lastly, execute the following command to see all We ran the three MongoDB servers, on their the contents of the apacheLogs collection: respective machines, as follows: > db.apacheLogs.find() $ mongod --port 27018 --bind_ip If the output is long, type ‘it’ to go to the next screen. 192.168.1.10 --dbpath ./mongo10 Replication is --rest --replSet LUDev A replication example $ mongod --port 27019 --bind_ip not a substitute 08 Imagine that you have your precious 192.168.2.6 --dbpath ./mongo6 --rest data on your MongoDB server and there is a --replSet LUDev for backup

66 www.linuxuser.co.uk WorldMags.net CreateWorldMags.net and save data with a MongoDB database Store Apache log fi les and implement replication in MongoDB TUTORIAL

Apart from primary and secondary nodes, Trying to write data to a non- a third type of node exists. It is called arbiter. 16 master node An arbiter node does not have a copy of the If you try to write to a non-master node, data and cannot become primary. Arbiter MongoDB will not allow you and will generate an nodes are only used for voting in elections for a error message. primary node.

More information about replication 13 • The former primary will rejoin the set as a secondary if it recovers. • Every node contacts the other nodes every few seconds to make sure that everything is okay. • It is advised to read from the primary node as it is the only one that contains the latest information for sure. • All the machines of a replica set must be equally powerful in order to handle the full load of the MongoDB database.

Useful MongoDB commands 17 • Delete the full apacheLogs collection: db.apacheLogs.drop() • Show available databases: show dbs • Find documents within the apacheLogs collection that have a StatusCode of 404: db.apacheLogs.find({"StatusCode" : "404"}) • Connect to the 192.168.1.10 server using port number 27017: mongo 192.168.1.10:27017 Selecting a new primary node 15 If you shut down the primary MongoDB Hints and tips server (by pressing Ctrl+C), the logs of the 18 • It is highly recommended that you fi rst remaining two MongoDB servers will show the run find() to verify your criteria before actually failure of the 192.168.1.10:27018 MongoDB server: deleting the data with remove(). Mon Jul 1 11:21:29.371 [rsHealthPoll] couldn't • Should you need to change the database connect to 192.168.1.10:27018: couldn't connect schema and add another fi eld, MongoDB will to server 192.168.1.10:27018 not complain and will do it for you without any Mon Jul 1 11:21:29.371 [rsHealthPoll] couldn't problems or downtime. connect to 192.168.1.10:27018: couldn't connect • The way to handle very large datasets is to server 192.168.1.10:27018 through sharding. It takes about 30 seconds for the new primary • Mongo has its own distributed fi le system server to come up and the new status can be called GridFS. The rs.status() command output seen by running the rs.status() command. • The name Mongo comes from ‘humongous’. 14 The rs.status() command shows you Important note: Once a primary node is down, the current status of your replica set. It is the fi rst you need more than 50 per cent of the remaining command to execute to fi nd out what is going on. nodes in order to select a new primary server.

WorldMags.net 67 www.linuxuser.co.uk BUILDWorldMags.net A BETTER WEB www.webdesignermag.co.uk

Available from all good newsagents and supermarkets

ON SALE NOW UX: Psychology of great design | Expert guide to HTML5 video | eCommerce with Stripe

DESIGN INSPIRATION PRACTICAL TIPS BEHIND THE SCENES STEP-BY-STEP ADVICE INDUSTRY OPINION

BUY YOUR ISSUE TODAY Print edition available at www.imagineshop.co.uk Digital edition available at www.greatdigitalmags.com

Available on the following platforms

WorldMags.netfacebook.com/webdesignermag twitter.com/webdesignermag WorldMags.netReview index Essential kit, software and resources for the open source scene REVIEWS

“Its support for selected Arduino shields is handy, but most users will likely ignore the on-board STM32 processor” Embedded Pi

How we review Our experts thoroughly test the kit and grade it using the following criteria

Avoid at all costs

A designer/developer’s bad day

Good but could do better

Get this. It won’t disappoint

Software or hardware nirvana

Group TestHardware Books 70 76 Raspberry Pi 85 The latest Linux Software Photo managers Camera Module reads dissected Which of our open source choices Snap happy? gets you the best results? 78 Embedded Pi The ultimate companion?

digiKam F-Spot 81 LG Optimus L3 II One of the smallest Androids available 82 AV Linux The best in media editing? gThumb Shotwell

WorldMags.net 69 www.linuxuser.co.uk WorldMags.net Review Photo manager super-test

SUPER TEST Photo managers Sort and edit your photos, from holiday snaps to hardware shots, as we fi nd out the very best photo-managing tool on Linux In the digital age we live in, with camera-phones, and searching for specifi c events or items in your functions that allow you to perform simple, prosumer photographers with their DSLRs and photo stream. batch processing tasks like colour correction on everything tagged on Facebook, there are a There are a lot of powerful yet easy-to-use a selection of images rather than one at a time. lot more photographs fl ying around than there tools around to help touch up and enhance We’ve chosen the best and most popular were in the days of Kodak fi lm being developed. your photos, but going through GIMP with each applications for comparison here. Others that Organising your photos can be a huge task, with individual photo for some basic edits can get didn’t make the cut include Fotoxx, Darktable a wealth of metadata and tagging that you can tedious. A few of the photo management apps and showFoto, the last two being more about edit on your images to aid with album creation we’re looking at today also include editing image manipulation than photo management.

70 www.linuxuser.co.uk WorldMags.net WorldMags.netPhoto manager super-test Four of the best photo managers battle it out REVIEW

Shotwell www.yorba.org Shotwell is the one application on our test that is used by default in the likes of Ubuntu or Fedora. It’s popular in GNOME- based distributions and other GTK desktop environments, although of course it works fi ne in KDE and the like. It’s a straightforward photo manager that requires little confi guration and is fairly lightweight to begin with, much like the other Yorba applications. When we say the interface is straightforward, what we mean is that there’s only a simple thumbnail view of your pictures. While you can increase the size of the thumbnails in this view, this of course reduces the amount of Q There’s only a thumbnail view for photos images you can see at once, and is not a true preview like you would get with something The interface does have its perks, though, and rotating, along with red-eye removal and like a fi lmstrip view – that kind of view is great allowing you do a few batch operations such as a manual colour balancing tool. That’s about it, for quickly scanning through pictures for tagging, placing in events, and using the ‘enhance’ though, and if you want to do some other effects either yourself or showing off to others, so its button to do some autocorrection on lighting and or manipulations you’ll need to fi re up the GIMP. absence is a bit odd. colouring – it won’t instantly make things look Shotwell is a very serviceable photo amazing, but it’s subtle enough that it doesn’t manager, doing the semi-basics well enough overdo anything. Events are treated like albums so that while it might be easier to use other “There’s only a in the interface and you can only assign one to a apps in this test, you’ll be able to get the job simple thumbnail photo, while multiple tags can be assigned. This is done. It does come with a great function that enough to differentiate their usage, as you might allows you to publish photos online, though view of your pics” have hundreds of tags but only a few events. – this includes posting to Facebook or Flickr Image editing in Shotwell is also very basic, accounts, and is a good way to sort out all your allowing you normal things such as cropping photos before uploading them.

SCORES

A lot of dependencies required; however, it’s a default application on 8 Installation some distros

A fi lmstrip view would be nice, but otherwise it’s Ease of use very straightforward 9

The most basic tools to crop and rotate images, along with a magic 4 Editing enhance button

Quite basic; however, the online publishing feature stands out among all the 6 Features other photo managers

A decent photo manager that can do all the basic tasks you’d want from such an application, but 7 Overall not much more Q Publishing online is a great feature

WorldMags.net 71 www.linuxuser.co.uk WorldMags.net Review Photo manager super-test gThumb live..org/gthumb We were actually a little surprised by gThumb, especially as it’s a GNOME-made application. With the recent move to simplifying all parts of GNOME, we were wondering whether its popularity was misplaced; however, it looks like all the changes to the GNOME Shell haven’t affected the way gThumb works. It’s not to say it’s a super-advanced, though – it features a fairly straightforward interface that we’d want from a photo manager. By default, it’s a thumbnail view, displaying the Picture folder in the home directory. Instead of importing photos from specific albums, you merely navigate Q gThumb lets you navigate the directory structure through the directory structure. This means that instead of having specific albums to create, them individually, although you can’t move edit information in batches as well; however, you’ll need to organise those photos yourself in a between them with arrow keys. The editor is you’ll likely want to do that individually. Images file manager or terminal. a little more advanced than what you get with that have been edited in this way get a date Clicking on the Edit file button in the top right Shotwell, allowing for more manual colour and added to them, letting you know when they were opens up the image editor, and a sort of limited balance corrections, as well as anti-blurring, last modified by gThumb. filmstrip view as well. You can click between desaturation and negative filters. There isn’t any Like Shotwell, gThumb also has online photos in the stream on the bottom to edit red-eye removal, though, and no paintbrushes publishing tools, with similar services such as or anything to do that, meaning you’ll need to Facebook, Twitter, Flickr etc. It’s nice that these open GIMP for those kind of operations. tools exist, as these services don’t have touch- “The editor is a little You also can’t do batch autocorrection for the up options, allowing for mass uploading of more advanced images, but you can do batch tagging. You can holiday photos and the like. drag a box over the images to select them, or gThumb is a great little application and while than Shotwell’s” press Ctrl/Shift with click, and you’ll be able to it doesn’t quite have everything we want, it’s add, remove or assign tags in batches. You can definitely a step up from Shotwell.

SCORES

Easy to obtain, but also requires a few Installation GNOME packages 8

Generally very easy to use; however, the edit/filmstrip Ease of use view is confusing 8

Decent amount of editing tools, although no Editing red-eye removal 7

While not particularly feature-heavy, it’s got enough to properly 7 Features manage your images

A very strong showing from gThumb, a photo manager with plenty of features, although it could do with some batch image 8 Overall touch-up options Q Plenty of photo information can be changed in gThumb

72 www.linuxuser.co.uk WorldMags.net WorldMags.netPhoto manager super-test Four of the best photo managers battle it out REVIEW

F-Spot f-spot.org F-Spot was replaced by Shotwell in Ubuntu a few years ago. However, the application has stuck around, albeit without an update in over two years. This simple image editor actually comes with an interesting variety of features, although they’re not all that useful in the long run. The first time you start it up, you’ll need to import photos from a directory. This is a pretty straightforward process, although it initially looks like you’ll need to change settings on each individual image in selected folders. It quickly imports into the library, displaying a thumbnail view, some basic metadata, a histogram and a Q The timeline can help filter some images sort of timeline for basic filtering of your photos. The timeline breaks are used to show a graph of which you can also select from the top bar, and supposed to get back to the standard view if photos taken per month along the top, allowing this includes a filmstrip view that you can key you want to, and you need to completely reset you to select each month from there. You can between with arrow keys on the keyboard. The the filters to remove any. Tagging is a little also filter by tags and such in the main view, as editor is a little simplistic, with some basic weird as well, since you need to create the tags well as adding extra tags and dates to the filters autocorrection tools, although they seem to do before you can even apply them to anything, to find exactly what you need. very little to the photos we tried them on. even if you have the images you need to tag The thumbnail view is quite basic, and you can The main browsing interface can be a little already selected. increase the size of the thumbnails in the view. confusing as well, especially once you start While there are some good parts to F-Spot, Double-clicking a picture enters the edit mode, filtering images. It’s not always clear how you’re in general it’s not as complete or as easy to use as we would have liked. The interface has a few “The main browsing interface can ease-of-use issues that are not encountered be a little confusing” with the other photo managers, too. SCORES

Generally easy to get, although it’s a little older now and requires older 7 Installation dependencies

Basic navigation is great, but can get a little counter-productive with 5 Ease of use more advanced searches

Has a small selection of autocorrection buttons, Editing but they do very little 6

A decent variety of features, but not all of them work quite as well as 6 Features they should

F-Spot is showing its age and is just not as good as the others in this test. A newer update could fix the problems, but that may 6 Overall never come Q The editor and file strip view are quite nice, but could do more

WorldMags.net 73 www.linuxuser.co.uk WorldMags.net Review Photo manager super-test digiKam www.digikam.org The KDE-developed image organiser is now in version 3.x, receiving a few upgrades over the past two years since it hit version 2.0 and became one of open source’s premier photo managers. It comes with a full range of functions, including the standard preview and filmstrip view we’re looking for, batch tag and data editing, editing software, and even a light- table function. Although built for KDE, digiKam works just fine with GTK-based desktop environments and has a more neutral design aesthetic than KDE, allowing it to not stick out on other desktops. Q digiKam has a selection of different views It can also be found in all major package managers thanks to its popularity and ties to have any. It’s here you can edit tags, geotags It’s a really comprehensive piece of software, KDE, although options to compile from source etc, as well as looking up metadata and colour offering just about everything we’d want from a via a tarball or GitHub are just as available. maps for the images. The interface aids in this, photo manager and more, especially for those Initial startup involves a quick but thorough allowing you to select multiple images with that need it in a professional capacity. setup wizard, going through basics such as the plus symbol that appears as you hover photo library locations, the manner of importing over thumbnails, although Ctrl and click also RAW files and a few more options. While a lot still works. “Everything we’d of people can mostly ignore these and have a Selecting an image then allows you to enter decent default selection, they are useful for the image-editor window or the light-table want from a photo people with more specific needs. Any changes view. In the image editor, there are a lot of you make during this wizard can of course be functions for adding effects and general image manager and more” altered in the main program’s settings and such, manipulation, although it’s mostly hidden away and there’s a lot of extra customisation you can in drop-down menus, making it a bit tricky to do to digiKam as well. use. The light table is a great feature, allowing The main window allows you to view your you to compare and contrast a couple of photos photo library in a stream, with thumbnails and in case you need to select from multiple images SCORES previews, as well as by their geotags if they of the same angle and subject. Requires some extra packages from KDE, but Installation easy to install otherwise 8

The main window is easy enough to use, although the image editor is a 7 Ease of use little confusing

Not quite at the level of GIMP, but more than good enough for a 9 Editing photo manager

digiKam is overflowing with a variety of features to make it easier and 9 Features better to use

A fantastic overall package that offers specialised tools to organise, analyse and edit 9 Overall your photo library Q Light table allows you to compare photos to find which is best

74 www.linuxuser.co.uk WorldMags.net WorldMags.netPhoto manager super-test Four of the best photo managers battle it out REVIEW

In brief: Compare and contrast our verdicts Shotwell gThumb F-Spot digiKam

Easy to fi nd and install GNOME-using distros Using a few older Requires a few on most major distros will easily be able to packages, F-Spot KDE packages, 8 install it 8 is generally easy 7 but available in all 8 Installation to install major repos

Very easy to use, Nice and easy to use, Basic browsing is fi ne, A little bit complex although it may be a although a proper but add searches and in some ways, but little simplistic 9 fi lmstrip view would 8 fi lters and it becomes 5 generally fi ne to use 7 Ease of use be welcome a mess

Only a couple of A good variety A selection of editing Fairly advanced autocorrection editing of manual and tools that do very little editing options, functions autocorrection to the photo although GIMP can 4 functions – no 7 6 do more 9 Editing red-eye though

Low on features, but A decent selection of While it has some Brimming with it has the necessities features to manage great features, they features to perfectly plus online publishing 6 your photos 7 generally don’t work 6 manage your photos 9 Features so well on your system

Shotwell is decent gThumb is a great F-Spot is showing A fantastic piece of enough for some of piece of software its age now and software that does the basics of photo that does just about could do with a bit of everything you’d 9 Overall management 7 everything you’d want 8 an overhaul 6 want and more

www.linuxuser.co.uk AND THE GROUP TEST WINNER IS… WINNER digiKam We very much like digiKam. It’s a fantastic suite with a huge variety of functions that we fi nd really help when sorting through a lot of photos. The different views are great, the light- table function is good for more professional photographers and the image-editing part is fully featured. It can be a little dense for its own good, though, taking a little time to work your way around the interface. However, it’s worth the effort and not only will your images be organised in a much more logical way, they may just look better as well. We were also very pleased with gThumb, a fairly lightweight equivalent that is a little easier to use. With GNOME’s recent push to simplify all its applications, gThumb doesn’t really seem to have been negatively affected like other parts of GNOME. Shotwell is still good, but lacking some features when compared to the rest, and F-Spot is just nothing in comparison to digiKam. Rob Zwetsloot Q digiKam is highly customisable, with plenty of advanced options

WorldMags.net 75 www.linuxuser.co.uk WorldMags.net Review Raspberry Pi Camera Module

The camera comes with a protective piece of plastic over the lens, which needs to be removed before use

Some cases now come with camera-mounting sections, but existing cases will need the camera module to be retrofitted by hand

The ribbon cable is thin and quite easy to damage, so care should be taken not to fold it

MODULE Raspberry Pi Camera Module £19.87 Does the Raspberry Pi’s first official accessory live up to its high-resolution hype, or is its outlook blurred? the USB part of the Pi altogether by connecting to the Pros Cons The Camera Module is the first piece of add- previously unused Camera Serial Interface (CSI) located near Compact and The software is in on hardware to come out of the Raspberry Pi the USB socket. Second, it taps into the graphics processing lightweight, this the very early stages Foundation itself – and it addresses a real need unit (GPU) of the Broadcom BCM2835 chip that powers the Pi Pi accessory is of development, a must-have for and there’s no in the Pi community. Many users are looking to – giving it vastly more computational power than devices that remote monitoring Video4Linux use the Pi for computer vision projects ranging use the Pi’s relatively weedy CPU. applications and support for existing offers surprising applications to use from near-space balloon launches – in which The result is a camera that draws surprisingly little power, flexibility the module the Pi provides a live stream of its journey while weighs just 3g, has the footprint of a postage stamp and yet is storing higher-resolution snapshots for when it returns to the capable of capturing 5-megapixel still images and 1080p high- ground – to burglar alarms and home automation systems. definition video at 30 frames per second. Better still, it does The official Camera Module dodges issues encountered all this for less than £20. Granted, that’s around the same as using webcams on a Pi – thanks to its esoteric USB you’d pay for a Raspberry Pi Model A to which the camera can implementation – in a couple of clever ways. First, it bypasses be connected – but given its capabilities, it’s still a bargain.

76 www.linuxuser.co.uk WorldMags.net WorldMags.netRaspberry Pi Camera Module First official Pi hardware add-on REVIEW

Mounting holes are included for bolts or screws, but the light weight of the camera means sticky tape or even Blu-Tack is an option A Camera Serial Interface (CSI) connector attaches the module to the Pi, via a bundled 15cm ribbon cable

The Omnivision 5-megapixel sensor is found behind a fixed-focus 3.6mm lens, but you can adjust the focus with a little hacking

Also consider

Logitech HD Webcam C270 £17.49 One of the most Pi-friendly webcams on the market, the for the official Camera Module. As a result, the only way to Logitech C270 is a cheaper Technical specs drive it is to use two command-line packages – raspistill and alternative to buying the Sensor Omnivision 5647, 5-megapixel official Pi Camera Module. raspivid – the source code for which is available. Unfortunately, it doesn’t Lens 3.6mm F/2.0 fixed-focus The software is easily the worst part of the camera, but use the GPU acceleration Dimensions 21.6 x 25 x 8.65mm (excluding cable) it’s also the part that will change most rapidly. Even between features on offer so video Weight 3g (excluding cable) capture is limited to low the writing of this review and its publication, the Foundation resolutions at around five Cable Length 150mm (15-core 1mm pitch ribbon cable) frames per second. Connection Camera Serial Interconnect (CSI) has likely fixed several of the bugs mentioned here – and will www.logitech.co.uk Max Still Resolution 2592x1944 (currently limited to 1920x1080) continue to improve the software. Max Video Resolution 1920x1080 (1080p) @ 30fps When used within the constraints of the software, the camera certainly delivers: still images are crisp, providing The Camera Module arrives, in traditional Foundation they don’t hit the Full HD crop limit, and video is impressive fashion, as a bare circuit board with a small, 15cm ribbon – although prone to banding if your power supply isn’t up to cable as the only accessory. Gently inserted into the CSI port scratch. The fixed-focus lens is a slight drawback, with objects on the top of the Pi, the camera is ready to go – once you’ve any closer than two to three metres appearing blurred – but updated your Raspbian installation. Those who have chosen if you’re willing to hack the camera apart, you can remove the alternative operating systems for their Pi are, at this point, left glue from the lens and adjust the focus manually with a twist. Toshiba TCM8240MD CMOS Camera out in the cold: currently, it’s Raspbian or nothing. Gareth Halfacree £7.93 Even fully updated, the software to drive the camera is Capable of capturing 1.3-megapixel still images in a very early stage. Many functions – such as the ability to Summary at 15 frames per second, the record EXIF tags into image files – simply don’t work. Other There’s no denying that the Raspberry Pi Camera Module is a Toshiba CMOS sensor does on-board JPEG compression features work incorrectly: attempting to capture any image bargain, despite costing nearly as much as the Model A itself. – taking the strain off the above 1920x1080, for example, makes the camera take a Full The software needs serious work and the lack of Video4Linux Pi’s CPU. It can’t do video, though, and users will need HD cropped image and then resize it rather than capturing support is disappointing, but its small size and high- to write their own I2C drivers the full frame of the sensor – a problem the Foundation’s resolution sensor will likely find it a home in many imaging- to use it. www.proto-pic.co.uk development team is working to resolve. related projects. Another issue, less likely to be fixed any time soon, comes in how the camera is driven. While webcams are supported More on the Pi through Video4Linux, allowing them to interact with information various third-party software packages, there’s no such driver www.raspberrypi.org

WorldMags.net 77 www.linuxuser.co.uk WorldMags.net Review Embedded Pi

I/O BOARD Embedded Pi £25.50 Designed to bridge the Arduino and Raspberry Pi worlds, will the Embedded Pi drive the low-cost microcomputer to new heights?

Pros Cons The brainchild of CooCox, a specialist in The second mode available is ST-Adapter Mode, in which A flexible piece of The official equipment, and its development tools development tools for ARM Cortex-class the STM32 drives various ports on the board but cedes control powerful STM32 are Windows-only microcontroller units (MCUs), the Embedded to the Pi’s own GPIO port – providing a handy command-and- processor makes and entirely useless for a capable for the Pi, making it Pi is described as the first triple-play accessory control channel without tying up a USB port. standalone difficult to unlock for the Raspberry Pi. Like rival devices, it extends Finally, the Ras-Pi Mode acts as a dumb expansion board, development the board’s true board potential the capabilities of the Pi’s general-purpose disabling the on-board STM32 processor in favour of merely input/output (GPIO) port, but it also runs extending the Pi’s own GPIO capabilities. independently of the Pi thanks to an on-board In all these modes, the Embedded Pi can communicate STMicroelectronics Cortex-M3 STM32 microcontroller. with a number of add-on boards originally developed for the This on-board microcontroller can be loaded with a Arduino microcontroller platform. Dubbed ‘shields,’ these program, which will run in real-time when connected to power boards – which offer everything from motor control to GPRS – even if the board is detached from the Pi itself, in what mobile data connections – can be connected directly to the CooCox describes as Standalone Mode. Embedded Pi without modification. That’s a feature list that covers almost every eventuality, but one that isn’t without its problems. By far the biggest On-board voltage is in software support: despite designing the Embedded Pi regulators accept 7V to specifically for use with the Raspberry Pi, the official manual 12V input without harming – provided as a downloadable PDF – requires the user to any connected hardware run CooCox’s own CoIDE software on a Microsoft Windows machine in order to do anything with the STM32 processor. If

The pins on the Embedded Pi are laid out for compatibility with Arduino ‘shield’ add-on boards

Jumpers allow the three modes – Standalone, Adapter and Ras-Pi – to be selected

The STM32 microcontroller provides the Embedded Pi with flexibility, but the included software is Windows-only

78 www.linuxuser.co.uk WorldMags.net WorldMags.netEmbedded Pi Arduino-compatible I/O board for Raspberry Pi REVIEW

A handy quick-reference table of pin-outs is included on the bottom of the Embedded Pi

Connection to the Raspberry Pi is via a ribbon cable that links to its GPIO header

A JTAG header is included, which will be handy for debugging or fl ashing the STM32 from Linux Also consider Technical specs Processor STMicroelectronics STM32F103 (72MHz The USB port is Cortex-M3 MCU) used to program the Memory 20KB RAM, 128KB fl ash ROM Dimensions 53.4 x 110 x 19.2mm STM32, and can also Weight 35g power the board GPIO 2x SPI, 2x I2C, 3x UART, CAN, 2x 12-bit Arduino Leonardo 16-channel ADC, 4x PWM, Arduino- £19.00 compatible headers and is remarkably capable even when used in its simplest Although it can’t easily make Power Mini-USB, 7-12V DC, or Raspberry Pi Ras-Pi Mode. Those willing to take the time to learn how to use of the Pi’s existing GPIO GPIO-provided port, an Arduino offers easy develop and fl ash STM32 applications from within Linux USB-connected expansion Extras 1x 26-way ribbon cable, 1x 10-way ribbon will unlock its true powers – and, should a community build for hardware projects. cable, 4x plastic raisers Like the Embedded Pi, its up around the device, packages to do exactly that will likely on-board processor – an you’re a Linux user, or want to do development directly on the become readily available. Atmel microcontroller – also allows for standalone use. Raspberry Pi itself, you’ll be stuck with using the Embedded For now, however, the Embedded Pi is diffi cult to www.arduino.cc Pi in Ras-Pi Mode – missing out on the chance to use the recommend unless you’re a Windows user. For Linux fans who powerful STM32 processor for real-time tasks. are looking for a way to use Arduino shields with a Raspberry It’s a major oversight on the company’s part. While Pi, a better option may be to simply use an Arduino connected it’s possible to program the STM32 from Linux – several either over USB or to the Pi’s UART for serial control – and in toolchains exist, thanks to STMicroelectronics releasing a doing so save around £5.50 to spend on parts for their project… range of low-cost STM32-based development boards some Gareth Halfacree Gertboard years ago – this will require additional hardware and a degree £36.00 of technical knowledge that will put most beginners off before Designed by engineer Gert Summary van Loo, the Gertboard they’ve even started their project. offers a vast array of GPIO Creating a Pi accessory that requires a Windows machine to expansion for the Raspberry Even assuming that the user is willing – or able – to use a unlock its full potential isn’t a great business idea – which is Pi. Originally supplied as a Windows box to write, debug and upload their program to the a shame, as the Embedded Pi shows signs of brilliance. Its self-assembly kit, the new Gertboard arrives ready to STM32, the list of supported shields is short. Specifi c drivers support for selected Arduino shields is handy, but most users use – but isn’t particularly need to be written for the Embedded Pi to communicate with will likely ignore the on-board STM32 processor. user-friendly. cpc.farnell.com Arduino shields, and so far only nine shields – including the offi cial Motor Shield and Wi-Fi Shield – are supported, from a list of many hundreds from numerous manufacturers. More This isn’t to say the Embedded Pi isn’t without its charms: information the compact board takes up a lot less room than a Gertboard cpc.farnell.com

WorldMags.net 79 www.linuxuser.co.uk UNLOCKWorldMags.net THE POWER OF ANDROID www.littlegreenrobot.co.uk

Available from all good newsagents and supermarkets

ON SALE NOW > Galaxy supertest > 25 quick upgrades > Sony Tablet Z > Amazing hacks

HARDWARE REVIEWS ANDROID HACKING TIPS & TRICKS APP REVIEWS HELP & ADVICE

BUY YOUR ISSUE TODAY Print edition available at www.imagineshop.co.uk Digital edition available at www.greatdigitalmags.com

Available on the following platforms

WorldMags.netfacebook.com/littlegreenrobot twitter.com/lgrobot WorldMags.net Review LG Optimus L3 II

The LG Optimus L3 II is quite a thick handset, but overall it is small and it does fi t in the MOBILE hand quite nicely, especially LG Optimusfor one-handed use The small, low-res screen is not great for viewing video or reading text. This restricts L3 II £69.99 some of the things you can do One of the smallest Android with the device phones ever, it also comes with a few attractive features… You don’t have to look too far with the LG Optimus L3 II to fi nd one of the things that’s been sacrifi ced for the low price tag. The screen stares out at you as low-cost A light around the Home technology and, sadly, it really lets the phone down. button can alert you to SMS, The screen is very small at 3.2 inches. That enables the alarms and more. It’s a neat LG Optimus L3 II to be a little phone – it measures just touch that helps you identify 102.6mm tall, which is among the smallest we’ve seen. But when things are happening it is surprisingly wide at 61.1mm. Even the Samsung Galaxy S4 with its gigantic fi ve-inch screen is not much wider at 69.8mm. And the LG Optimus L3 II is a chunky phone too, at 11.9mm thick. It feels very substantial in the hands – though LED surrounding the long, thin physical Home button. You can that is matched by a solid build that makes it diffi cult to bend set this to pulse in different colours for alerts, alarms and as a and bow in the hands. battery charge indicator. However, let’s get back to the screen. Its small size means More useful on an everyday basis is the lock screen which it is always going to be diffi cult to view complex things like lets you open up into one of four apps, access anything on the webpages, and it is not going to be showing off its best side notifi cations bar or sweep inwards from either bottom corner for video viewing. But its low resolution of 240x320 pixels to open into the last screen you were using. Given the way does it no favours at all. LG lets you select from a small choice the phone’s compact size aids one-handed use, this makes it of fonts and one of two font sizes, but neither helps much really easy to navigate your way around the Optimus L3 II. with readability. SMS fans will like that incoming messages show on screen Pros The internal specifi cations aren’t a disaster for such a low- until they are dismissed, and a quick tap is all you need to Surprisingly powerful considering it’s one of the cost handset, though. Android 4.1 is a pleasant surprise, and get into the messaging app and craft a reply. There’s also smallest Android handsets the 1GHz processor with 512MB of RAM is no less than we’d a little Quick Memo app you can call up to take handwritten to be released expect to see here. There is 1.6GB of free storage (from the notes. These can use the app you are in or a blank page as a 4GB that’s installed) and you can slot a microSD card in under background, and are saved as image fi les so they are easily Cons the backplate to augment this. shared. The screen size doesn’t let you make the most of this The screen resolution really lets it down – if you So far, so dull, but there are some good things to be found app as there’s not space to write much, but it is a nice addition. want to watch video, you’d on this device as well. If you like alert lights you will love the Sandra Vogel better look elsewhere

Summary Technical specs While the screen might let the LG Optimus L3 II down rather, Operating System Android 4.1 there are some features that help it to stand out from the Processor 1.0GHz single-core low-cost crowd – such as its diminutive size, lock-screen Storage 4GB gestures and alert lights. Dimensions 102.6 x 61.1 x 11.9mm Weight 106.4g More Display Size 3.2-inch information Display Resolution 240 x 320 Expansion Slot microSD www.lg.com

WorldMags.net 81 www.linuxuser.co.uk WorldMags.net Review AV Linux 6.0.1

New features: Kernel 3.6.11.2 • Utility menus • Skype • EasyTag • Scribus Q The AV Linux Control Panel Q Utilities have been split up in allows for a lot of customisation the menu now, allowing for easier of the distro, including creating access to the hardware tools a special Hybrid ISO for USB

Q AV Linux uses LXDE with Openbox so that you can get the most amount of power out of your system DISTRO www.linuxuser.co.uk EDITORS’ CHOICE AV Linux 6.0.1 Best for: Media editing Minimum Specs: CPU Pentium II RAM 256MB STORAGE 4GB (USB Stick) A highly customised Debian designed for video and audio professionals, how exactly does it differ from other distros? And does it deliver?

Pros AV Linux 6.0 came out towards the end of last year after pretty or user-friendly as some of the major distros, it does A real-time kernel an apparently difficult development period. AV Linux does the job and explains what you need to be doing at each of the for reduced audio take a while to iterate, though, and there were some big steps. This includes giving instructions on how it wants the latency, and every major media changes from version 5 to 6 – such as switching from Linux hard drive partitioned before letting you launch into GParted editing application kernel 2.x to 3.x for better hardware support, and some to do it. The biggest hassle during installation in general is available as default major updates to all the packages. A point update has been changing locale and keyboard if you’re not American. released for 6.0 now, which includes some minor upgrades Cons and bug fixes throughout the distro and its apps. The installer is a Live performance bit basic, and the AV Linux comes as a fully functional, live-booting OS, One of the things that make it great as a live distro is its many real-time kernel perfect for writing onto a USB stick or live CD and using it extra drivers for a lot of proprietary audio and video hardware, can be a resource hog if you don’t where you can. It does also include a fairly basic installation such as sound cards, graphics cards, MIDI controllers and specifically need it function, which gives you just enough control to partition more. These are all carried over through to the installed your system and then install the distro to it. While it isn’t as version and you can then start customising which versions

82 www.linuxuser.co.uk WorldMags.net WorldMags.netAV Linux 6.0.1 Highly specialised media-editing distro REVIEW

Q The selection of sound mixers and audio drivers don’t work in harmony, but Q Installation is more manual than some distros, including using GParted to set they offer a lot of control over a sound card when you need it the most up your hard drive. The process has clear and concise instructions, though

The real-time kernel allows for a much lower Screenshot latency while recording audio Gallery of the drivers you want to use, and keep them. This allows are joined by 3D modellers like , and other video you to get the most out of your system for AV work without editors for different skill levels such as OpenShot and having to set it up every time. There are also a lot of sound- . The full LibreOffice suite is also available in case card utilities that allow you to edit the levels through a variety you need to write or present something, and of course a full of different applications with different effects to the sound complement of internet browsers, messaging clients and input, although it seems to prefer you use one at a time rather media players are included to round out the experience. All than a combination of drivers and tools. this is especially helpful for the live version of the distro, as bit.ly/LUDAVL6 Speaking of sound input, AV Linux’s real-time kernel is one it’s all there without preconfiguring, and there’s a lot of extra of the distro’s best features for professional audio engineers. utilities and tools that would take a long time to set up and The real-time tag on boot allows for a much lower latency customise to this extent. However, you can make a hybrid Summary while recording audio, keeping things a lot more accurate bootable USB key using current system settings to create a Possibly the perfect than the standard Linux kernel. You can remove this if more personalised version of the live distro, with software audio editing suite needed, though, as the real-time kernel does take up a few installed or removed using the standard Debian packages based on Linux, more resources than usual, noticeably slowing down our test it’s based on. especially for one machine while it was activated. that’s ready out All inclusive of the box so to speak. The real-time Modifying defaults It’s generally a fantastic editing suite. The use of LXDE and its kernel option is a There are several boot-time cheat codes that you can apply policies on screensavers means it can eke every bit of power great feature for on boot, one of which is the -rt option that enables the real- from your system to make sure latency and rendering are the sound engineers, time kernel. By default, there are options to enable threaded best possible. And on top of that, it gives you a huge amount reducing audio IRQs, which aids in the audio latency, as well turning off of control over the way the hardware interacts with the latency, and there’s the hugepages memory management feature. Disabling distro to optimise the system even further. It does use a lot a lot of driver and hugepages is apparently another step in keeping the latency of non-free software to achieve this, though – unfortunately hardware control for low, but it causes memory-heavy applications such as video this is more of a problem with the entertainment industry everyone else. editors to not work as smoothly. There’s also an option known than anything else, but allows people to do the kind of work as noautogroup that allows for the desktop to work a little they want to use AV Linux for. better, even when CPU-intensive operations are under way. Rob Zwetsloot One of the upsides of AV Linux is the sheer amount of Dowload now audio, image and video editing software pre-installed onto the distro. Mainstays such as GIMP, Audacity and www.bandshed.net

WorldMags.net 83 www.linuxuser.co.uk WorldMags.net Subscribe Subscribe today & start saving Non-USA readers see page 22 USA special offer Subscribe today and get 5 free issues* Exclusive subscriber benefits • Subscribe today and pay just $122 for 13 issues* • Pay as little as $9.39 an issue – usually $15.99 in stores Your exclusive For more information and to order visit offer code: USA www.imaginesubs.co.uk/lud Or call +44 (0) 1795 418661

Imagine Publishing publishes more than 20 monthly magazines, some of which have been running for over 10 years, reaching over 4 million readers every year

*Terms and conditions: This is a US subscription offer, please don’t forget to quote USA when ordering. You will actually be charged £80 sterling for an annual subscription. This is equivalent 84 www.linuxuser.co.uk to $122 at the time of writing, although the exchange rate may vary. Five free issues refers to the newsstand price of $15.99 for 13 issues being $207.87, compared with $122 for a subscription. Your subscription will start from the next availableWorldMags.net issue. This offer expires 30 November 2013. WorldMags.netBook Reviews Latest Linux books revealed REVIEWS

Brain-Computer Interfacing An Introduction Absolute OpenBSD: Author Rajesh P N Rao UNIX for the Practical Paranoid 2nd Edition Publisher Cambridge Try a more secure UNIX ISBN 978-0521769419 Price £50.00 OpenBSD is successful at being a highly secure, UNIX- Score like operating system. If it is not successful at building an Essential background evangelising, open community – in the manner of GNU/Linux in neuroscience, – that’s because that’s not what the OpenBSD developer brain recording community wants to concentrate on. Their single-minded and stimulation technologies, signal devotion to security makes it the best OS for some jobs. processing, and machine learning. Detailed Michael Lucas, with trademark dry humour, acknowledges description of the major types of BCIs in this position, but seeks to guide new users through the animals and humans, including invasive, operating system and the community until they are in a position semi-invasive, non-invasive, stimulating, to ask the right questions. and bidirectional BCIs. In-depth discussion Security is a process, not a simple set of recipes, and your of BCI applications and BCI ethics. reasons for trialling OpenBSD may be diverse, but in all cases Author Michael W Lucas there’s much fundamental knowledge to absorb. If you’re used Publisher No Starch to the GNU/Linux way, the journey may not be easy, but Lucas Practical Programming, ISBN 978-1593274764 is an able guide with a comprehensive knowledge, and along 2nd Edition: An Introduction to Price £40.99 the way you’ll pick up nuggets of wisdom you’ll use in adminning Computer Science Using Python 3 Score non-BSD machines, too. Authors Paul Gries, Jennifer Campbell, Rapid Android Linux System Jason Montojo Development: Programming: Publisher Pragmatic Bookshelf Build Rich, Sensor-Based Talking Directly to the Kernel ISBN 978-1937785451 Applications with Processing and C Library Price £28.99 Score Powerful Android Classic intro to development without coding Linux This book is for anyone the pain of Java system software who wants to understand computer Author Daniel Sauter Authors Robert Love programming. You’ll code along with the Publisher Pragmatic Bookshelf Publisher O’Reilly book, writing programs to solve real-world ISBN 978-1937785062 ISBN 978-1449339531 problems as you learn the fundamentals Price £26.99 Price £38.50 of programming using Python 3. You’ll Score Score learn about design, algorithms, testing and debugging, and come away with all the Processing – a language popular with artists Updated for the 3.x kernels, Love’s classic work tools you need to produce quality code. and educators – has been available for on POSIX and Linux coding features a new chapter producing Android apps since 2.0 in 2010. If you’re on multithreading, and numerous updates, but not already familiar with Processing – it’s popular still shows you how to write code that, in the Practical Data Analysis: RAW in hackspace projects on Arduino for example – words of Greg Kroah-Hartman’s introduction, you’re in for a treat. Designed to have “a low fl oor “doesn’t suck.” Author Hector Cuesta and a very high ceiling”, you’ll be working with the Providing you’re happy with C, and the basics of Publisher Packt Android hardware in a few short steps. the GNU compiling and debugging tools, this work ISBN 978-1783280995 Price £48.99 A quick tour of setting up the IDE (far speedier gives you all you need to get started writing at a Score than starting up Eclipse for Java on Android) and low level for our favourite OS. This is about systems it’s on to the accelerometer to make a motion- programming, not higher-level applications From learning data based colour mixer. The rest of the book divides programming where APIs abstract away many visualisation with D3.js, into four parts. First, working with the camera(s) challenges for you. to building simulations and location devices. Next, networking, using Love is experienced at working directly with for econometrics, harnessing the power Wi-Fi and Bluetooth to make collaborative apps the kernel and the C library, covering both general of open source data analysis technologies like surveys, and working with NFC tags. After UNIX and specifi cally Linux calls, and then diving can lead to better customer service, the data and storage, using SQLite, the last part into where behaviour varies between theory and visualisation of customer needs, or even brings in 3D graphics, and covers writing cross- practice. By the end of the book, you’ll fi nd yourself the ability to obtain fresh insights about the platform desktop apps and web apps through with an understanding of Linux which will help in performance of previous products. processing.js. Practical, enjoyable, useful. higher-level coding – and in adminning, too.

WorldMags.net 85 www.linuxuser.co.uk WorldMags.netClassifi ed Advertising Rock solid protection Read anything for Raspberry Pi. good lately? Shop for quality magazines, books and DVDs from Imagine Publishing

Machined Aircraft Alumini um Integrated Camera Option Anodized Colour Options Security Features Passive Cooling Follow @imagineshopuk on Twitter Proto for exclusive discount Armour codes TM www.protoarmour.com

Raspberry Pi is a trademark of the Raspberry Pi Foundation

MAGAZINES BOOKS DVDS DOWNLOADS GIFTS

To Advertise In

Contact Rhian on 01202 586421

[email protected] WorldMags.net01202 586421

Introducing the Pibow ModelA for the low-profile Model A A hacker’s delight!

The neat little layer case for your Raspberry Pi®

Crystal Toxic Ninja Adafruit Rainbow

Available From: http://pibow.com/ http://shop.pimoroni.com WorldMags.net WorldMags.netContact us... Web: www.linuxuser.co.uk Email: [email protected]

Contact us @linuxusermag Questions Become a fan on & answers Linux User & Developer answeredYour questions ASK THE EXPERTS Send us your questions and we’ll do our best to answer them! This month your questions were answered by…

Russell Barnes has been a computer and technology journalist for nearly 15 years

Q Here’s the end of the code as it should look Kunal Deo is a veteran on a Linux operating system? I am aware Mac developer of many open source projectes Python problems OS X and Linux are both derived from UNIX. I Thank you for your piece in the current issue of noticed I can run the included version of Ubuntu your magazine about programming a game of on my MacBook when I ran it directly from the hangman. I have enjoyed following and learning included DVD. Do you believe I would get better from it as I am new to programming and this is the results on this project were I to install that first thing I have done. This is also the first copy of version of Ubuntu on a separate partition? Linux User I have purchased too, so unfortunately Any advice you could give me would be much I haven’t seen your previous pieces to learn from. appreciated as I have never done anything like I’m sorry to say I am having an issue in running this before, but I am keen to learn how to program. Rob Zwetsloot studied the finished project. When I do run the program, Thanks in advance. aerospace engineering, using the Python shell just shows three lines. These Python to model simulations lines are: Matthew Steele ======RESTARTING======>>> There seems to have been a small >>> problem with the code printed in I have followed your coding exactly and the the magazine that will cause this only change I needed to make was to the last to happen, unfortunately. The last line, which was putting an indentation before two lines are printed like this: ‘start()’. This was due to an error message telling me it expected an indent. if __name__ == ‘__main__’: Richard Smedley spends 90% of his screen time shelled I am running Python on Mac OS X 10.5.8. start() into servers in the UK and USA Would this make a difference to running Python The if statement was indented by mistake in

88 www.linuxuser.co.uk WorldMags.net WorldMags.netQuestions & answers All your technical problems solved Q/A

the printing process, and should instead look Secondly, make sure any packages in IgnorePkg like this: or IgnoreGroup do not have fi les in /bin, /sbin or if __name__ == ‘__main__’: /usr/sbin. Fix them if necessary. Batch files start() Next, if you have fi les in /bin, /sbin or /usr/sbin I’m running an enterprise batch scheduler that are unowned by any package, you need to on RHEL 6.3. I have a batch utility called a The code on the disc and on the website has move them. Find a list using: ‘File Watcher’ that simply monitors for the this part coded correctly, and it’s usually a $ find /bin /sbin /usr/sbin -exec presence of a fi le. I run it as a batch job and good idea to check between the two for any pacman -Qo -- {} + >/dev/null if the fi le is not found, it is supposed to fail errors like this. with a return code of 7. File found = return Python is platform agnostic, so even if you Finally, ensure all partitions are mounted if using code zero success. used this on Windows, which doesn’t have any autofs. They may not automount when needed I’ve been testing it with a fi le that doesn’t ties to UNIX, it should also work. Although of later in this update. Then update safely using: exist, and weirdly, the fi le is not found by my course, we recommend using Linux as much as $ sudo pacman -Syu --ignore utility, but it’s returning a success return you can. filesystem,bash code. I have never had this occur on any $ sudo pacman -S bash platform but RHEL, and it is happening on $ sudo pacman -Su all of our Linux servers. Merger issue The vendor says the PAM (pluggable I hope you guys can help me. I encountered a This should fi x the problem now that the merge authentication module) is being invoked but curious exit status with pacman when I was trying has happened. failing on the session close. They had me run to upgrade my packages. I am running Arch, and an strace on the batch utility. what I used was the ‘pacman -Syu’ command. Basically, I’m getting a success from This is what I got: You’ve got mail batch jobs when they should be returning (251/251) checking for file conflicts Do you know of any software that notifi es when back a non-zero return code (failure). Any [######################] 100% a new email arrives to a given email account? help would be much appreciated. error: failed to commit transaction I’m currently using aMSN on KDE with a plug- Geoff Burtt (conflicting files) in for Gmail and another for Yahoo, so I can filesystem: /bin exists in filesystem know when I get new email. The problem is that This is a documented bug in filesystem: /sbin exists in now the Windows Messenger protocol has and there are a couple filesystem discontinued, aMSN does not work so well any of workarounds for it at the filesystem: /usr/sbin exists in more, especially for these notifi cations. moment. The best one to use is filesystem Basically what I need is a program (or some the following, although it Errors occurred, no packages were desktop widget) that notifi es me when I get new involves modifying the system-auth-ac fi le. upgraded. email on webmail services and that shows a You can fi nd this fi le in /etc/pam.d – open counter with the number of unread emails on it with your favourite text editor. Look for This is weird, considering the fact that bin and each one. Does an app like this exist? this line: sbin dirs are always there. What could be the session optional pam_sss.so problem with this? George Burton …and add a line above it as follows: session sufficient pam_localuser.so Kim Hu For KDE, there’s a nice plasmoid Save the fi le and recycle sssd with this to be called kde-plasma-mail-checker. on the safe side: Due to changes in the Arch This allows for multiple accounts, $ service sssd restart packages thanks to a merge, you and notifi cations for them, and it That’s it. Hopefully, the bug should be fi xed need to do some updating to your supports both POP and IMAP. soon, though. Arch distro and pacman to get it to This means it will work with Yahoo mail as well work properly. These are the steps as the others. to follow to fi x it: Firstly, to fix any non-official packages with files in /bin, /sbin or /usr/sbin by putting those files in /usr/bin. The list of packages that are not in a repo that need to be fixed can be generated using: $ pacman -Qqo /bin /sbin /usr/sbin | pacman -Qm - Also check packages installed from non- offi cial repos using: $ paclist | awk ' { print Q The Red Hat team are usually very good $1 } ' | pacman -Ql - | grep ' at fixing bugs such as this /s\?bin/\| /usr/sbin/' Q The KDE mail checker is highly customisable

WorldMags.net 89 www.linuxuser.co.uk WorldMags.net

Contact us @linuxusermag Questions Become a fan on & answers Linux User & Developer

GIS query Hi there, I’m looking for recommendations of specialised GIS software. In my IT department, ArcGIS is commonly used and it’s important that this new software be able to process the data that ArcGIS creates, which is in .mxd files. These also need to support some other requirements set out by my company. Are there any feature-rich GIS solutions that will be able to do this for me? Thanks.

Den Sanchez

Well there are a few things you should try out that might solve your problem, although without knowing your special Q GNOME’s Startup Applications helps you with graphical programs requirements we can’t give a better recommendation. Start with the beta versions of description run devil’s pie on ‘FWTools-x86_64-3.1.0’. FWTools contains GDAL Pie solution startup as Python wrappers, which helps with ArcGIS. I have a problem with Adobe Flash player that start on startup You could also try out GRASS, which supports apparently can be fixed using Devil’s Pie as a stop on [016] ArcGIS through GDAL as well, and is in the repos workaround, making it autostart in respawn of most distros. 13.04 with GNOME Shell. exec su - ben -c “devilspie” If none of that works, IDL is another option Here’s what I tried to achieve after following that should do everything you need and may be the instructions I was pointed towards. I first I wanted to test it first by seeing if I could worth checking out anyway. Hope one of these made a file /etc/init/devilspie.conf with the run it manually, but I couldn’t understand the works for you. following content: output. Either way, it seems that Devil’s Pie is not running - it’s not listed in the running processes of System Monitor.

Ben Darrington

As Devil’s Pie is a graphical program, you probably don’t need to be putting it in . As you’re using GNOME, there’s the startup application manager called autostart that allows you to add graphical programs that will launch after GNOME loads up. Add the path to devilspie in the new entry form, reboot, and it should work fine. Audio split Hi there. For some strange reason all the music files in one of my directories repeat themselves twice, as in the files are twice as long and contain each track twice in them. Perhaps I unwittingly merged them when restoring a backup or something. In any case I have a question: is there a way to run FFmpeg or some other tool to cut my double Q GIS allows for geographical data to be analysed MP3 files in half? The solution needs to be

90 www.linuxuser.co.uk WorldMags.net WorldMags.netQuestions & answers All your technical problems solved Q/A

Q The mp3splt tool does not decode audio files, allowing In FFmpeg we the process to can do a batch be a bit faster process for any MP3 in a directory dynamic; that is, the program needs to measure the individual length of each MP3 fi le and fi nd out by itself where the 50% mark is. I could always do this manually in Audacity, but there are hundreds of sound fi les affected, so this would take forever. Any help on this would be greatly appreciated.

Dan Simons

That’s an odd problem you seem to have there, but you’re right: there’s a way to do it in FFmpeg that will do a batch process for any MP3 in a directory – although we need to create a script ourselves to handle it: going to be installed backported version with: #!/bin/bash Depends: libsqlite3-0 (>= 3.7.12-1~) $ sudo apt-get install -t squeeze- mkdir unchopped but 3.7.3-1 is to be installed backports iceweasel for file in *.mp3 How can I fi x this? Is there a way to fi x this? do Conner Truman You need to make sure that the backports mv -v $file unchopped repo is added like you have done, of course. The ffmpeg -i unchopped/”$file” -t Well the easy solution to this is to problem is the different information Apt is now $(echo $(mp3info -p %S “$file”)/2 | use the actual backport repository getting; however, installing it that way will get bc -l | cut -f1 -d.) $file for Debian. You can install the it done. done

This won’t do any analysis on the fi le, though, so if the halfway mark isn’t what you want to split Q Iceweasel, from, you might be in trouble. A slightly faster now IceCat, method of loading MP3 fi les so you can do it is for graphically is using mp3splt. Debian Getting backported I am using Debian (Squeeze) and I am trying to install Iceweasel from backports. I have added: deb http://mozilla.debian.net/ squeeze-backports iceweasel-release …to my /etc/apt/sources.list and issued an ‘apt-get update’ command. Then, I tried to install Iceweasel and received an error about missing dependencies like this: iceweasel: Depends: xulrunner-14.0 (>= 14.0.1-1~bpo60+1) but it is not

WorldMags.net WorldMags.netSponsorship opportunity Bring attention to your brand by sponsoring this Hosting listings section. Contact Rhian Carter on +44(0)1202586421

Dedicated server listings Got a deal you think we should list? Whether you’re a hosting firm or a happy customer who wants a favourite provider listed, drop us a line with the details! [email protected]

NAME AND URL PACKAGE PHONE NUMBER PER COST MONTH MINIMUM TERM CONTRACT CPU CORES / SPEED DISK SPACE 1GBPS INTERNET CONNECTION RAID HARDWARE POWER REBOOT REMOTE KVM PERMANENT UPTIME GUARANTEE NETWORK BACKUP STORAGE SUBNET PRIVATE 24/7 PHONE SUPPORT

Dual Core 2200DC 0800 061 2801 £50 1 month 160GB N/A Raid 1     2.2GHz

Dual Core 3000DC 0800 061 2801 £80 1 month 2 x 250GB N/A Raid 1     3GHz

Intel Quad Core 2660QC 0800 061 2801 £130 1 month 2 x 500GB N/A Raid 1     2.66GHz

Developer 0800 061 2801 £32.89 1 month N/A 1GB N/A 

One 0800 061 2801 £109.99 1 month N/A 5GB N/A  Netcetera www.netcetera.co.uk/linux Reseller 0800 061 2801 £274.89 1 month N/A Unlimited N/A 

Bravo14 (http://bravo14.co.uk) Starter Linux N/A £20 N/A N/A 2,000MB N/A 

Bravo14 (http://bravo14.co.uk) Starter Windows N/A £20 N/A N/A 2,000MB N/A 

Bravo14 (http://bravo14.co.uk) Business Linux N/A £45 N/A N/A 4,000MB N/A 

Bravo14 (http://bravo14.co.uk) Business Windows N/A £45 N/A N/A 4,000MB N/A 

Bravo14 (http://bravo14.co.uk) Ultimate Linux N/A £60 N/A N/A Unlimited N/A 

Bravo14 (http://bravo14.co.uk) Ultimate Windows N/A £60 N/A N/A Unlimited N/A 

12 Dual/Quad 160GB FlexServer2 01628 777730 From £29 10Mbps 99.90% 10 GB  months Core to 2TB

100 BudgetBox III 01628 777730 £36 1 month Intel Xeon 3065 1 x 250GB 99.90% 10 GB  Mbps

Quad Core Intel 120GB Intel 100 SSD 4 01628 777730 £60 1 month 99.90% 10 GB  Xeon X3430 520 SSD Mbps

2 x Intel Xeon 2 x 500GB 100 Merlin 01628 777730 £199 1 month 99.90% 10 GB  Quad Core SATA II Mbps

2 x Intel Xeon 4 x 1TB 100 DS6.5 01628 777730 £295 1 month 99.90% 10 GB  Hex Core SATA III Mbps

Gbit Cloud Server 01628 777730 £52 1 month 2 vCPU (4GB) 40GB shared / n/a 99.90% O  node

Gbit PoundHost Cloud Server 01628 777730 £98 1 month 4 vCPU (8GB) 40GB shared / n/a 99.90% O  www.poundhost.com node

Heart Internet (www.heartinternet. Dual Core Xeon 24/7 Ticket Linux Dual Core 0845 644 7750 £79.99 12 months 160GB  99.99%  co.uk/dedicated-servers) 2.33GHz support

Heart Internet (www.heartinternet. Dual Core Xeon 24/7 Ticket Windows Dual Core 0845 644 7750 £89.99 12 months 160GB  99.99%  co.uk/dedicated-servers) 2.33GHz support

Heart Internet (www.heartinternet. Quad Core Xeon 24/7 Ticket Linux Quad Core 0845 644 7750 £129.99 12 months 250GB  99.99%  co.uk/dedicated-servers) 2.5GHz support

12 Quad Core Unlimited 0208 123 2730 £1.79 Unlimited  N/A  N/A 99.9% N/A N/A  months Xeon

Zyma Octo Core Unlimited 0208 123 2730 £7.95 3 months Unlimited 99.9%   www.zyma.com Xeon

O = Option

92 www.linuxuser.co.uk WorldMags.net GET YOUR LISTING HIGHLIGHTED! CONTACT RHIAN [email protected] +44(0)1202586421 Hosting listings LISTINGS

Dedicated and Shared server listings SHOPPING CART VIRUS FILTER FIREWALL PHONE SUPPORT SUPPORT EMAIL WEB CONTROL PANEL LEVEL SERVICE AGREEMENT PACKAGE PHONE NUMBER COST WEB SPACE MONTHLY BANDWIDTH POP3 ACCOUNTS DATABASE SUPPORT NAME AND URL Minimus +44 (0)845 5280242 €49.95 10GB 200GB Unlimited     Linux / Windows

Medius +44 (0)845 5280242 €89.95 20GB 400GB Unlimited     Linux / Windows

Blacknight Maximus +44 (0)845 5280242 €149.95 30GB 600GB Unlimited     www.blacknight.com Linux / Windows

eHosting (www.ehosting.com) Starter 0844 999 4100 £23.88 1GB 25GB 10   eHosting (www.ehosting.com) Personal 0844 999 4100 £59.88 2.5GB Unlimited 50   

eHosting (www.ehosting.com) Expert 0844 999 4100 £95.88 5GB Unlimited 250   

eHosting (www.ehosting.com) Virtual 0844 999 4100 £227.88 50GB Unlimited Unlimited   

Equiphase (www.equiphase.net) Bronze 0121 314 4865 £30 200MB 2GB 10   

Equiphase (www.equiphase.net) Silver 0121 314 4865 £42 400MB 5GB 20   

Equiphase (www.equiphase.net) Gold 0121 314 4865 £72 800MB 10GB 100   

Equiphase (www.equiphase.net) Platinum 0121 314 4865 £114 1,200MB 40GB 200      

Eurofasthost.com (www.eurofasthost.com) Email Only 02380 249 823 £40 1GB 2GB 10      

Eurofasthost.com (www.eurofasthost.com) Essential 02380 249 823 £75 2GB 5GB 10      

Eurofasthost.com (www.eurofasthost.com) Superior 02380 249 823 £140 5GB 10GB 25      

Eurofasthost.com (www.eurofasthost.com) Premium 02380 249 823 £250 10GB 25GB 100      

Evohosting (www.evohosting.co.uk) Starter N/A £29.99 500MB 1GB 3   

Evohosting (www.evohosting.co.uk) Home N/A £54.99 2.5GB 30GB 50   

Evohosting (www.evohosting.co.uk) Business N/A £79.99 6.5GB Unlimited Unlimited   

Evohosting (www.evohosting.co.uk) eCommerce N/A £159.99 30GB Unlimited Unlimited   

Personal 0808 168 6777 £32.87 5GB Unlimited 50  

Business Bronze 0808 168 6777 £58.38 50GB Unlimited 500  O   

Business Silver 0808 168 6777 £76.39 Unlimited Unlimited Unlimited  O   

Business Gold 0808 168 6777 £101.89 Unlimited Unlimited Unlimited  

WD Starter 0808 168 6777 £149.99 20GB Unlimited Unlimited  OO   Fasthosts www.fasthosts.co.uk WD Advanced 0808 168 6777 £199.99 Unlimited Unlimited Unlimited  OO  

Giacom (www.giacom.com) Business Pro 0800 542 7500 £199 100MB 2GB 100       Heart Internet (www.heartinternet.co.uk) Starter Professional 0845 644 7750 £29.80 2.5GB 10GB 1,000  

Heart Internet (www.heartinternet.co.uk) Home Professional 0845 644 7750 £89.99 10GB 50GB 10,000   

Heart Internet (www.heartinternet.co.uk) Business Professional 0845 644 7750 £129.99 Unlimited Unlimited Unlimited   

Heart Internet (www.heartinternet.co.uk) Reseller Professional 0845 644 7750 £299.99 Unlimited Unlimited Unlimited   

Hostway (www.hostway.co.uk) Silver 0808 180 1880 £79.50 150MB 3GB 5  O   

WebFusion (www.webfusion.co.uk) Fusion Professional 0845 130 1602 £107.40 5GB 50GB 1,000       WebFusion (www.webfusion.co.uk) Fusion Business 0845 130 1602 £179.40 10GB 150GB 1,500      

WebFusion (www.webfusion.co.uk) Fusion Developer 0845 130 1602 £227.40 20GB 300GB 5,000      

WebFusion (www.webfusion.co.uk) Fusion Reseller 0845 130 1602 £329.99 Unlimited Unlimited Unlimited      

Eco Web Hosting (www.ecowebhosting.co.uk) Starter N/A £29.99 200MB 2GB Unlimited      

Eco Web Hosting (www.ecowebhosting.co.uk) Standard N/A £54.99 1GB 10GB Unlimited      

Eco Web Hosting (www.ecowebhosting.co.uk) Advanced N/A £119.99 20GB 24GB Unlimited      

Eco Web Hosting (www.ecowebhosting.co.uk) Reseller Unlimited N/A £199.99 Unlimited Unlimited Unlimited      

NameHog (www.namehog.net) Email Only 0845 612 0330 £11.75 25MB 1GB 5      

NameHog (www.namehog.net) Standard Package 0845 612 0330 £35.25 100MB 4.5GB 10      

NameHog (www.namehog.net) Professional Package 0845 612 0330 £58.75 250MB 8GB 25      

O = Option

WorldMags.net 93 www.linuxuser.co.uk WorldMags.net Your view Your source of Linux news and views Contact us… Register and post your comments… Email us directly… www.linuxuser.co.uk/forum/ [email protected]

YOUR VIEW Linux User Letters Your opinions about the magazine, Linux and open source Reader replacement Q Google Reader will be sorely missed by us at Linux User I read your review of the RSS readers, and I just the bigger overhead of setting up a database Tiny Tiny does get around some of the syncing wanted to suggest another alternative. I use and configuring a web server, you have the great problems. However, Digg has just released its the Tiny Tiny RSS reader which runs as a local benefit of accessing the feed from multiple own RSS reader service that is in a lot of ways feed aggregator daemon, storing everything in systems. For example, I’m syncing my feeds also similar to Google Reader. This, of course, might a database, giving you access via a web server. to my Android tablet to have them ready for offline mean it will get shut down along the line, and From the look and feel, it is literally like hosting reading when I’m out of the house. Tiny Tiny will last as long as your system will. It’s your own Google Reader server at home. Beside Felix Simpson great to have options. THREAD BARE GNOME no more Our exclusive interview with Clement Lefebvre and the rest of the Linux Mint team revealed a very important new fact – Cinnamon 2.0 will be in the next Mint, and GNOME will be removed. A lot of people were excited when we broke the news on our website. Join in on the conversation at: bit.ly/ZIEaE3

Nick said: I’ve poked tentacles into Mint since 12 & 13, and not been able to settle with it. But with a dedicated Cinnamon and what that may promise. Lighter and hopefully more stable. That might just be the QCinnamon won’t look different, but the core will have changed turning point. Looking forward to this release. underlying technologies. Clem will need to gather a much bigger team, I guess, which seems problematic. JIM said: We’ll see. I HATE to see this duplication of work (DEs, distros etc) but I I left Mint because Mint wouldn’t leave Ubuntu and their Debian feel GNOME is moving in a really bad direction, as well as Ubuntu (even if, rolling release barely rolls, with updates every six months. Now, I am again, the underlying work benefits everyone). on with Cinnamon loaded. 1.8 Cinnamon, which is newer than As a KDE user, pretty happy because it’s SO advanced and features- Clem’s own LMDE version. And it actually rolls with 3.9 kernel and complete, but still a bit annoyed by the fact it lacks manpower to polish it everything else always staying spanking brand new while still being stable. properly, I don’t know what to think. Will we have yet another half-baked Arch is sweet! environment ? (Promising, with many qualities, but lacking the amount of support really needed to make it perfect)… Chezbutt said: It’s silly when you consider that if you could combine the qualities of all Ohhh… That sounds again like a huge heap of duplicate work. those environments you would get something amazing. I wonder how this will turn out, as GNOME is so much more than Well, I’m lost but somehow I think the Linux Mint team has very sane and the desktop/file manager/window manager; there is a lot of work done in pragmatic reasoning :-)

94 www.linuxuser.co.uk WorldMags.net WorldMags.netYour view Tiny Tiny RSS reader, Mint & Cinnamon 2.0, Chrome privacy concerns LETTERS

related to Google (in the aspect of storing Chrome concerns bookmarks, online integration), it’s just easier Web Designer I’ve heard the news that again Canonical are for me to stick with Firefox and not worry about Development for the considering replacing Firefox with Chrome the scandal altogether. Just my two cents. But web is a huge part of or Chromium as the default browser in the the good thing is we all have the freedom to modern computing, next version of Ubuntu. After all the remarks choose whatever browser we want regardless with the majority of about the NSA and specifi c mention of Google of what is installed by default. services available in the reports, I’d be inclined to use Firefox Dave Crane online and in the cloud. While we pride regardless. Not to mention Mozilla is putting ourselves on having up quite a front in regards to this whole It’s not just the Google services we’d worry some fantastic open ordeal. Maybe Google is completely innocent about – remember, by default Ubuntu has the source web design in the matter, but is it really worth the risk? Amazon and online search function activated, tutorials, our sister magazine Web Designer Since Chromium and Chrome are so closely which also has privacy implications. is dedicated to bringing you many more of While Amazon is not allegedly part of the these features at the same level of quality. Regularly covering the newest technologies PRISM program, the data sent to it is not such as HTML5, CSS3, jQuery, WordPress, anonymous. If you want to truly make sure and mobile apps, Web Designer is the best you’re secure, you should check out the choice for hobbyists and professionals that Electronic Frontier Foundation’s PRISM want a more dedicated web development Break website (prism-break.org) to make magazine. You can fi nd out more about it at sure you’re using non-invasive software. www.webdesignermag.co.uk

Contact us @linuxusermag Become a fan on Q PRISM Break is a great resource for secure, Linux User & Developer free/libre and open source software

The website for the GNU Generation

The ultimate resource for open source enthusiasts and professionals • Latest news • Reviews • Tutorials • Opinion Never miss an update Subscribe to our RSS feed today!

WorldMags.net WorldMags.net

iPad iPhone Android phone Android tablet Apple Mac Windows PC WorldMags.net /P%JTD/P1SPCMFNWorldMags.net Many of the fi les you’re looking for can be found on the magazine’s website To get the most out of your digital *NBHJOFEJHJUBMFEJUJPOT editions, be sure to enjoy all of our BSFBOFXBOEFYDJUJOH fantastic features, including: XBZUPFYQFSJFODFPVS r;PPNBCMFUFYUBOEQJDUVSFT r*OBQQCSPXTJOH XPSMEMFBEJOHNBHB[JOFT r4FBSDIBCMFUFYU BOECPPLB[JOFT r5BLFZPVSDPMMFDUJPOXJUIZPV r3FBEPGáJOF

5PCVZNPSF*NBHJOFEJHJUBMFEJUJPOTBOEGPSUIF MBUFTUJTTVFTBOECFTUPGGFST QMFBTFHPUP XXX(SFBU%JHJUBM.BHTDPN WorldMags.net WorldMags.net Next issue What’s coming up… Look out for issue 130 THE MAGAZINE FOR on sale 29 Aug THE GNU GENERATION Want it sooner? Imagine Publishing Ltd Richmond House, 33 Richmond Hill Subscribe Bournemouth, Dorset, BH2 6EZ today!  +44 (0) 1202 586200 Web: www.imagine-publishing.co.uk www.linuxuser.co.uk www.greatdigitalmags.com Magazine team COMING IN THE NEXT ISSUE Editor Russell Barnes [email protected]  01202 586272 Staff Writer Rob Zwetsloot Designer Stephen Mathews Photographer James Sheppard Senior Art Editor Andy Downes Editor in Chief Nick Jones Head of Publishing Aaron Asadi Head of Design Ross Andrews Contributors Stuart Burns, Phil King, Simon Brew, Jon Masters, Liam Fraser, Richard Hillesley, Joey Bernard, Michael Reed, Richard Smedley, Gareth Halfacree & Mihalis Tsoukalos THE HOTTEST Advertising Digital or printed media packs are available on request. Head of Sales Hang Deretz  01202 586442 [email protected] Advertising Manager Jennifer Farrell  01202 586430 [email protected] Account Manager Rhian Carter DISTROS  01202 586421 [email protected] Cover disc Multimedia Editor Steve Dacombe [email protected] International EVER MADE Linux User & Developer is available for licensing. Contact the International department to learn more. Counting down the best in open source Head of International Licensing Cathy Blackman  +44 (0) 1202 586401 [email protected] Subscriptions Head of Subscriptions Gill Lambert For all subscriptions enquiries  0844 249 0282 (UK)  +44 (0) 1795 418661 (Overseas) Email: [email protected] 6 issue subscription (UK) – £25.15 13 issue subscription (Europe) – £70 (ROW) - £80 Circulation Head of Circulation Darren Pearce  01202 586200 Production Production Director Jane Hawkins  01202 586200 Founders Group Managing Director Damian Butt Group Finance & Commercial Director Steven Boyd Group Creative Director Mark Kendrick Printing & Distribution Printed by William Gibbons, 26 Planetary Road, Willenhall, West Midlands, WV13 3XT Distributed in the UK & Eire by Seymour Distribution, 2 East Poultry Avenue, London, EC1A 9PT.  0207 429 4000 Distributed in Australia by Gordon & Gotch, Gordon & Gotch Corporate Centre, 26 Rodborough Road, Frenchs Forest, NSW 2086.  + 61 2 9972 8800 Distributed in the Rest of the World by Marketforce, Blue Fin Building, 110 Southwark Street, London, SE1 0SU.  0203 148 8105 Disclaimer The publisher cannot accept responsibility for any unsolicited material lost or damaged in the post. All text and layout is the copyright of Imagine Publishing Ltd. Nothing in this magazine may be reproduced in whole or part without the written permission of the publisher. Command line Python code All copyrights are recognised and used specifi cally for the purpose of criticism and review. Although the magazine has endeavoured to ensure all information is correct at time of print, prices and bluffer’s guide listings availability may change. This magazine is fully independent and not affi liated in any way with the companies mentioned herein. Become an overnight More Python projects to If you submit material to Imagine Publishing via post, email, social network or any other means, you automatically grant Imagine Publishing CLI sensation test and modify an irrevocable, perpetual, royalty-free license to use the images across its entire portfolio, in print, online and digital, and to deliver the images to existing and future clients, including but not limited to international ALSO INSIDE: licensees for reproduction in international, licensed editions of Imagine products. Any material you submit is sent at your risk and, although How to build a >> System admin with Webmin every care is taken, neither Imagine Publishing nor its employees, >> A brief history of MySQL agents or subcontractors shall be liable for the loss or damage. pro-grade firewall >> Your questions answered © Imagine Publishing Ltd 2013 Can pfSense save your bacon? +14 pages of reviews ISSN 2041-3270

98 www.linuxuser.co.uk WorldMags.net WorldMags.net Turn your TV into a Smart TV...

STREAM YOUR FAVOURITE MOVIES, TV SHOWS, VIDEOS, MUSIC AND MORE TO YOUR TV USING RASPBERRY PI

Raspberry Pi

Raspberry Pi XBMC Starter Kit The Raspberry Pi XBMC home entertainment system is the ideal solution for playing your media. Supplied with the Raspbmc OS preloaded SD Card, offering a whole host of entertainment features including playing a wide range of HD formats with DTS, photo slideshows and music. The ultimate XBMC starter kit solution includes: • Raspberry Pi Model B 512MB RAM • 4GB SD Card with RASPBMC Preloaded £50Inc VAT • WiPi USB Dongle • Ethernet Cable order code SC1301244 • HDMI and Power Cables

Get everything for your Raspberry Pi project...

• Raspberry Pi and full range of accessories • Kits and Cases • Expansion, Breakout and Prototyping Boards • Vast Range of Components • WiFi Dongles & HDMI to VGA Adaptors • Video and Audio Leads • Keyboards, Mice and Monitors • GPIO Ribbon Cables cpc.co.uk • Programming and User Guides FREE cpc.co.uk WorldMags.net DELIVERYConditions apply, visit WorldMags.net

WorldMags.net