Hacker's_Manual_-_17th_Edition,_2024

You might also like

Download as pdf
Download as pdf
You are on page 1of 148
HACKER'S TN 2024. THE KERNEL » NETWORKS SERVERS » HARDWARE * SECURITY ENHANCE YOUR KNOWLEDGE WITH IN-DEPTH PROJECTS AND GUIDES rrrrrrrrerrrrrrrrrrrrrrrrre 4 Ad dd dd ddd de dd ad de ee A 644444444 Ae eee eee 4 4d dd dd Ad dd de dd ed ee al dl a di di dl dl dl al dil ald dif dlsdldl dif ddl didi didlsdi 4 Ad dd dd Ad dd de A ed de ee al dl dl di di al dl lal dil ll dl dl dl ld dl ddl ddl dials 4 Ad dd Ad A dd dd de A ad ee 6h eee eA ene eee e eee LAMM anand Ad ee ee A dd Ad Ad dd did dd ddd dd dd 4d A ddd 4d A ddd ddid dd 4d 4444 44 44444444 dd dd did dd 444444444 Ad dd 4 dd A ddd ddd dd 4d 444444 44444444 AAAAAAAAMAMAEAEAAADA OO “444 sd adaaaaaaaaaasadad adda dd dd Ad ddd dd dd dd dd ddd dd dd Ababa daadaaaaaaaaassadaaéadadéa, rTwrrwrrwrewrwweweweewwe eww wre wee es Welcome tothe 2028 edition ofthe Hackers Manual! You holdin your hands 148 pages of Linux hacking tutorials, guides and features from the experts at Linux Format magazin - the home of open source software. Inthis edition we've gone in hard for security Youll find guides to securing servers, geting 2 grounding in hacking, using security tools such as Kall and Fedora Securty Lab alongside solid features explaining how to protec your pracy online sing established tok ike Tail. Gut we should ive in fea! Hacking is ‘monumental fun. Nevermind setting up and plying with Linux, we take a look at hacking tablets, media servers, virtual machines, cloud servers, ‘mult-booting with Grub and much more. yout alte tim when it comes to the Terminal we even have a meaty reference section at the back So dvein and enjoy! 4 L FUTURE 4 r HACKER'S MANUAL 2024 {sa | Contents HACKER'S MANUAL 2024 Security Distros 10 Ubuntu 24.04 Get the lowdown of n the latest Ubuntu and discover its secrets, 18 30 years of Linux How a 21-year-old! took 32 Build the kernel Its the ultimate nerd credential, tune up your al kere ner 40 Rescatux repair Explore one of the repair systems p 6 | TheHackers Manual 's bedroom coding project he world. most famous rescue and wered by Linux. 46 54 62 68 Protect your privacy Discover what threats are out there and what you can do to protect your dev ith Kali Master hacking fet toolkit and explain how to u ‘Secure chat Chat online without anyone snooping in on. what you have to say Secure your desktop Linux can thwart a majority of attacks on its own but we can help put a level 10 forcetield ‘around your computer Data recovery from damaged disks and items are gone for good, Contents Hacking Take yo t! ir Linux skils to ext level and beyond, 96 Hacker's toolkit Getto gps withthe mecasystem er Diecover the tks usedby hackers desktops and embedded sjtems tohepteep your systemesate 82 Virtual Box 108 Linux on Linx tablet Ensure yougetthebest out of your vital Get Linux upand runing on alow cost systems wthouressontal gui. Windows abet ntout thehasle 86 Nextcloud 108 Multi-boot Linux Trebresk aay. anew clo storage and Dscovertheinner workings of Grub and boat ocurnt system she foal jtsot OSes romone PC 90 Nagios (‘112 Build your own custom Ubuntu distro Inst level system montringso you Why sete forubet fe esting dstrubutons Contachstiyour un 2s hove tote? 116 LTTng monitoring Get to know what all your programs are up to by trchg Linucapp set, 120 -USB multi-boot We exlan how youcan carry mts distros onsangle USB rie The terminal like a 1337 hacker and get to grips the powerful termina 126. Get started 154. Drive partitions The best way to use the terminal is to dive in Control, edit and create hard drive partitions wth bth eet nd star unt and permissions 128 File and folders 136 Remote access \Weemlan now you can navigate the fle Setup ane acess emote GUI applications System and star meripuatng things vain 130. Edit config files. 138 Display control cover net you can edit configuration tes Stetung ith he wed oF XI We ake some from wt th text erie rand for reseluton corte 152. System information 140 Core commands Interrogate the local system to discover all of its dirty ttle secrets, 20 essential terminal commands that all Linux ‘web server admins should know. The Hackers Manual | 7 exec rals dbsmigrae$ bundle exec rake db:migrate § bundle exec ral rors ae eel =randl2 oy eee tt eo) eer iit renee eaten Dee eee eres eeu eee eeu eerste migrate $ b Crores ao) erg perme Tet eet ene erg ee Neate eer eau ope ad reeeanany Seer yee Paes ken ee Sas tes eek Gi= Soe ere een rooney er ot betes hei pee Ieee eee eee ore Seer See Cea Tee Bcontent ) else format him! {rend een game event get eve eee refresh; usleep 50000; lin Wl Seer bs ssable_enity }$ bundle Pee Se el ee ee cee ree ee ececerme res ort Cioran re ernnen Barre eer oe ere eae aiayeaering coe reer Se eae ee eee ee =e erearen Sere eee oto 0, 479), randrange, 5) peogetens omen eee Distros Because if there was only one form of Linux, we'd be bored Ubuntu 24.04 Get the lowdown on the latest Ubuntu release and discover its secrets. 30 years of Linux How a 21-year-old's bedroom coding, project took over the world, Build the kernel Its the ultimate nerd credential, tune up your own personal kernel, here's how, Rescatux repair Explore one of the most famous rescue and repair systems powered by Linux. Te Hacker's Manual | 9 ‘buntu LTS (Long Term Support) [ J scent eon res we get exited about nowadays. So colour us excited. We're champing at the bt to tell you all about Ubu 2404's great new features And to explain the creature behind its code rare (Noble Numbat) As ever, Ubunts Continues to excel at usability, compatiblity and uty. Gone are the days when gripes about Office documents and Windows games reigned 4 Whether you'r a beginner or aficionado, 2 we've got all you need to got started Wel show you how to get itinstaled silly and safely. We'l show you how to 10 |The Hacker’ Manual Ubuntu 24.04 LTS The latest Ubuntu is here. Jonni Bidwell has come out of hibernation_ just to celebrate and (in between beverages) tell you all about it. make sure it's playing nice with your hardware. We'll show you all the fresh features, such as the brand-new Gnome 46 desktop and accessibility ‘options. We'll show you how to install Powerful open source software. We'll ‘even show you how to install proprietary ‘games. Yes, we have a lot to show you. ‘And if there are things you don't lke, we might also be able to show you how to remedy them. We've got the low-down on Snaps, the universal packaging format from Canonical (the company that makes Ubuntu), They've been getting a bit of flack lately, so we're going to counter that and show that they're actually pretty good, We'll show you how you can use them to get powerful software installed effortlessly. And how they use confinement to keep you safe. There's a whole lot to get through, so grab yourself a brew (or something stronger) and let's see what the Numbat i all about Ubuntu Make way for nobility Prepare yourself, mentally and digitally, for Ubuntu's latest and greatest outing, Noble Numbat. {that most special time ofthe year when Canonical releases anew Ubunt LTS. Thstime. he creature thas loosed unt te words Noble Numba. nd what a fine specimen ti, OK al disclosure before we got stuck in we're basing our evaluation on the latest day images So, we're tnocing Some rough edges as we're sure they lbe smoothed by the time you reas ths. This does mean we may miss ny final ourshes the tear isholing bac ut the finalrelease, but we're sure youl orgie us Before younish to https:/Aabun.com/desktop to downoad the instalation material. we'd ket offer a fen pointers rts your rst foray nto the world of Ubuntu or Lnaxin general good news we're making this feature as beglne-renaly as posible. The ipside ot this is thatinsaling Ubuntuis sometimes abit trickier than actualy using aly, youl want to instal Linux ont oun machine. This way, you sidestep ‘ny issues that arise from dal booting with Windows, Nake sure there's nothing important on that machine: theres back upright aay. The easiest way to instal Ubuntu ist lett erase an entre ve, and once that's happened, yur not geting anythin back Not everyone has a spare machin athoush prety cruch ay 68 syster th 43 of RAM can happy run Ubuntu, 20 you might want to cobble something together). The nxt best thing sto get afresh new SSD (256GB is more than enough). chuck tin your system Sn dal Boot without touching the Windows ive Windows 10 was fussy about having is partitions ana filesystems resized, and Win Ls even more so.So, we 7 Ubuntutets auton aganst tyngto gel thetwo Osestoplaynce musa the nthe same dive. eventhough is theoretiealy scoop posse todo the fom the Ubu ntl wie he ove eques Scie Soto eturadn tuk Yarnton (unlike the LXFDVDs of old) Ubuntu has no problem with this. There's no accounting for other oddities in manufacturers’ UEFI (the firmware that runs as soon ‘as you turn on your machine) implementations, so all kinds of things could happen (or not happen) on that crtical post installation reboot. While these are usually not indicative of massive data loss, it's vital that you back up ertical les from your Windows drive in case Create and boot installation media You can download the Ubuntu 24,04 ISO image from the link ‘above I's over 5GB, so won't fiton a regular DVD, Unless you've gota thing for dual layer optical media, you'll want to write that image toa USB drive. This is more ‘complex than ust copying the fie on toit, and you need specialist tools fo doi. If you're already running Uountu,t includes its own tool for ths, called Startup Disk Creator. Otherwise, we recommend Etcher, which you can get from https:// etcherio runs on Windows, Mac 08 and Linux. Fre up its writing order from the UEFI Etcher, select the ISO you just downloaded and hit Flash, Now make a cup of tea while Exactly how to boot your freshly minted media depends on your system, ‘Some give you ahelpful boot ‘menu when youpush a key (often F12 oF F10) while booting. Others require you to explicitly change the boot Configuration (which you ‘might get toby pushing Del ‘or Alt+F2), In some cases, it's tricky (not impossible) tocatch the UEFI before Windows boot. In this case, and select Restart. Then from the recovery menu, select ‘Advanced Options > UEFI Firmware Settings. Dig ‘around in here and youl find ‘some boot options, you can force the issue from the Windows login screen (or Start menu), Hold down Shift {2s you cick the power icon in the bottom-right (or Power Options inthe Start menu) J The Hackers Manual | 11 Distros Install Ubuntu 24.04 Get Ubuntu loaded on to your machine, without messing with any incumbent operating system. x ~ > Accessibilty ke row at the heart ofthe Ubunt Setup, making (en accessible forall 12 | The Hacker’ Manual H opel, by now you've ‘managed to create and boot ‘an Ubuntu installation ‘medium. If nt, turn back and follow the instructions i the box forthwith The first thing you see isa brutalst ‘menu from which you should select the frst option (Try Or Install Ubuntu). If things go wrong, try again with tone ofthe other options (use Safe Graphics mode i you see graphical corruption ora blank screen), Once i's loaded, you hear a welcoming chime and are asked to select localisation settings, connect to your WiFi (or LAN), and set up ary ‘accessibility options (such asthe 200m tool, screen reader and sticky keys). You might then be offered an Update to the installer, which you should accept Next you'te asked whether to Try Ubuntu o Install it Rather than dive straight into the instalation, we first recommend trying out the live envionment. doesn't touch your system drive(s) unless you ask itto = 0 it's totally risk-free, unless you take risks. The live environment runs from a compressed flesyster and without much inthe way of graphical acceleration (Gepending on your hardware),so it won't quite be as snappy [is this foreshadowing? ~ ed] as the real thing If you're coming from a Windows background (in which case, congratulations on taking this fist step), the most obvious difference isthe lack of a Start menu equivalent. The flagship ection of Ubuntu uses the Gnome desktop, which, as far as GUIs go, sas far from \Windows as you could get. There are other Ubuntu flavours that use other desktop environments (some of which have a traditional applications menu) ~ more on those later. In Ubuntu, frequenty accessed programs are accessed from the Dock to the left. fyouhave a > You might need to aust alplay scaling it you havea high-resolution display high-resolution display and everything looks too smal, Fieht-click the desktop, select Display Settings and then adjust the sealing. Your fst Linux experience should not involve eyestrain aftr all, Dock worker The lve environment includes (in order of Dock appearance) Firefox, a file manager (Files). the word processor from LibreOtfice (Write), App Center for instaling and updating software (see bor) and the Helo tool. Below this are any connected drives and the Trash (ouhere deleted fies first end up). That's not the whole story, though. Get alist of al installed applications by clicking the Ubuntu logo atthe bottom of said Dock. if ‘you dig around in here you'l find the rest of LbreOtfice, the Gparted ask partitioning to! (in case you want to prepare your disks for a more advanced install) and a myriad other utities that it would be sil to list here, Basically, everything youneed to get started ‘You're probably already familar with Firefox (it ooks ‘and works exacty lke it does on Windows and Mac OS) and, for mast purposes, Files acts much like Windows Explorer or the Mac 0S Finder. I you're instaling alongside Windows (and your Windows drive doesn't Use any kind of encryption). you can see those fes, too. The indicator icons inthe top-right show network, volume and battery status. You can adjust decibels by hovering the mouse over the indicator icons and using, the scroll wheel, I'you click on ther, you bring up the Quick Settings menu, which can toggle Bluetooth, ‘etwork and light/dark themes. You ean also configure [Nght Light here to automaticaly reduce blue hues after sunset, again reducing eye strain, From the top-left ofthe Quick Settings menu, you can bring up the sereenshat tol (invaluable for tech Journalists). The small cog immediately to the right of ‘this brings up the Settings panel. rom whence you can Configure all aspects of the system. We'llleave you to rummage around in there isa tweaker's paracise, ‘The Status menu also provides the buttons to shut down or restart your machine. But let's not do that we've nearly completed our cursory introduction and are but afew sentences away from instaling, Ifyou cick in the top-left. you gt tothe Activities ‘overview. This shows you any running apps. and also lets you switch between workspaces. These are virtual desktops that enable you to better organise yourself ‘when running multiple apps. I you make heavy use ‘ofthese, youl want to know that the Windows key (technicaly the Super key) brings up the Activities view. ‘and that Super and Page Up/Down switch between workspaces. you type in the ist few letters of a ‘rogram from the Activities view. it (or any other app ‘matching those letters) magically pops up. and you can ‘open iby clicking or hiting Enter, Get it installed ‘When you're ready. close any open applications and Click the instal Ubuntu ican an the bottom-right You're asked the same questions as earlier, so zip through ‘those until you're asked whether to do an interactive ‘or Automated installation. The correct answer is Interactive, so click it. Next youte askedif you want the Defauit or Extended package selection. The Default installation is somewhat frugal (basicaly the apps we ‘mentioned above, minus LibreOffice). The Extended selection includes LibreOffice and a few other utites. ‘Size-wise the Extended install eccupies 94GB, Next you're asked about proprietary software. This isnt the place to enter into a philosophical discussion (on software licences. sof you'e not familar withthe lore (and particularly if you have an Nvidia graphics Card), tik the first box It ight also be the difference ‘between your WiFi working or otherwise. The second ‘box s ess important, but if you stl use the MP3 format for your music collection (or Apple QuickTime), tick it Now you're asked whether you want to erase a disk and install Ubuntu (fit detects a suitable drive). stall alongside another OS or go with a manual instal Choose whatever suits, butf you're dual booting. make sure the correct drive marked for installation. If Ubuntu detects files or an OS on that drive it tries its best to repartition it sensibly and it wil probably be fine. But well reiterate our advice from earlier ~ it's much safer to devote a whole drive to Ubuntu ‘Once you've chosen your installation method, you are asked to set up an account with a username and password, You're asked for this password when you log in, unless you uncheck the box below. There's also the ‘option to log in via an Active Directory domain, but we doubt ary of our readers use this at home. Althat' eft todois wait forthe install to complete, Enjoy the slideshow showcasing what avait, or make a cup of tea. When done, choose Reboot and, when prompted, remove the installation medium and hit Enter. Ubuntu >ubuntw happily installs alongside Windows. but Windows might not be happy about it being there. phteM Styne Besides the lack of Start ‘menus, one ofthe most stark differences between Ubuntu ‘and Windows i the way Software (be it applications, drivers or games) installed ‘While this 's changing on Windows, many users are stilused to downloading installed there. “The App Center is your gateway to these Fepositores 0 let's explore how the process works by way. you canbe sure that ‘what you'te gettingis what i's supposed tobe, anit wil ‘work with everything else hitinstal. Within moments, software from (sometimes __insaling something. One questionable) websites in change Canonical has the formofanexecutable introduced for this outing, (orcompressed executable) is that Minesweeper and bundle. While things on Ubuntu (and other flavours of Linux) can be installed this way, the de rigueur way to install software is direct from Ubuntu’s repositories. This Soltaire-type games are no longer installed by default, Lets change this by installing ‘Gnome Mines. Open the App Center, search for gnome mines from the top bar and that button changes to read Open and you can waste some time finding explosive ordnance Again this is all happening in the ephemeral lve environment, andisn't ‘making any changes to your > Bring back Mines (and ‘other classe Gnome games) ina couple of clicks. system (or the USB you're instaling from), So, fel fre to install anything ese, ust bear inn mind there isn’t much space in the lve instal (i's a 2B flesystem that ives in memory), So, you cant install anything heavy lke Steam. The Hackers Manual | 13 Distros Explore Ubuntu Get to grips with your new favourite operating system and diagnose any hardware or software issues. ‘ou should reboot toa boot menu (whichis quite Y hard to ead on a HIDPIcispay). Choose Ubuntu (it’s the default option, with Windows. Boot Manager below itif you installed alongside Windows) and ina few seconds, you are greeted with a login screen Enter your password and you're presented with a prompt about sending information to Canonical Unike certain other OSes, Ubuntu cares about your privacy. Any telemetry information snot linked in any ‘way to your machine or identity. I's easy to opt out of sending anything, but ifyou want Canonical get some insight into how Ubuntu is used or how i's breaking, say Yes. You can even view the first report before it’s sent to get a handle on what kind of metrics are divulged Next you're asked if you want to enable Location Services, which allows apps to guess where you are ‘based on your IP address, GPS signal and nearby Wi-FV/ Bluetoath devices. This was done using the privacy’ friendly Mzila Location Service, but in March t was ‘announced that this service is shutting its daors to non Mozila entities, and atthe time of writing, it's unclear how Ubuntu plans to mitigate thi. The mos likely scenario is that ths will reduce to a simple IP-based lookup, but we won't speculate. If you object to being located, say No. then say hello to your fresh new Ubuntu desktop. A desktop that, but for an installation icon is indiscernible from the live environment Ifyou are anything tke us, youl want to check out the selection of wallpapers, Ubuntu has always shipped with ) The best part of any new Ubuntu release isthe fantastic selection of desktop backgrounds, fabulous desktop background offerings, and 24,04 is no aifferent. As usual, some ofthe graphics are based on the animal (a numbat i atermite-eating marsupial found in Western Australia i you didn't know) and some are just nice to look at. Right-click the desktop and choose Change Background to see for yourself. You might also have your own images you want to use here, in which case just select Add Picture from the top. It's a controversial option, but you might also want to set Bing's image ofthe day as your background, in wich case you can instal the BingWall application from the Ubuntu is used by all sorts of people, from beginners topros, business suits to scruffy gamers, and everyone in between, Whatever your level or purpose, if you want to deepen your understanding Of Linux (or possibly just fh lonsteroids. There's space fora deep dive (see https// bitly/xf_terminai into shell ‘commands here, but if you type journaletl-b youll see the system log for the Current boot. Use the cursors to scroll up and down, and you might find some annoying problem), some clues to help diagnose then sooner orlater you're any problems. Or you might ‘going tohavetoface the find some problems you commandline. Thisisatext never knew youhad. Press Q interface to your system —_toreturn to the command faccessedby the Terminal prompt. sett com Other useful commands are: top (seealistof running, application), which in the Fight hands, an manipulate every aspectof it ifyoute processes d-h show free ™agzzinet a Windows pro, then think ‘space) and Ispci or Isucb to ‘cantation: Powershell. Orif you're old- show a list of connected $sudo apt School thenthink DOS -PCIUSBdevies By forthe $sudoapt 14 |The Hackers Manual > The new installer certain looks the part. but is probably notin ‘most quoted inthis pling reason fr you to upgrade. This invokes administrative though.is the privileges (the sudo part of the commands) to update update package lists and then apply ‘upgrade ‘any avaliable upgrades. ‘App Center (sory fellow Brits ~ this is how its spelled). Hf you'r using a laptop, its worth noting that you can switch between three ben power profiles from the Status menu: Performance, Balanced and Power Sav which wee pretty sure you don't need us ‘o.expain further. nthe latest release, ‘support has been reworked to make newer hardware (where P-state divers are avaiable) even more efficient when working on battery power All sorts of hhardware (besides the CPU itself can be ppower-managed these days, including sraphics, storage andi network devices If things go wrong Ubuntu pretty good a getting al your hardware working out ofthe bo. The days ‘when you had to configure each bit of hardware trough arcane tet fs re erally (forthe most pat fer behind. That notwithstanding, fyou fel something hast been set Up correctly might be worth mvestigating the ‘Ackitional Drivers uit (ht the Ubuntu logo in the bottom ight to bring up the applications men and search for there), This tel you f any proprietary dhiversare active or canvshouldbeactNated. AS we touched on you shouldn't ever have to manualy dovnload and instal any divers on Liu. And ‘some manufacturers do offer Linux downloads, these ae often more trouble than they e woth, Ifyou runintoa showstopping graphics issue you right find yourself staring ata textual login prompt instead ofthe usual pretty graphical one Push Ctr+Alt+ F3 to see what we mean you don thave a graphics problem (Ctrlrlt+F2 brings your desktop back). Your {sual login details work atthe console, an after entering them, you meet an expectant-ookng ashing cursor Welcome, rend, tothe console, We've conned all we wart to say about ths to the box (opposite), butifyourun into graphics or ether problems, we encourage yout take your eror messages and og files tonitps/ubuntuforums.og or htps//askubuntucom. Just be sure to read the guidelines before posting Its kely (ifyu're connected to the internet) that a couple of minutes after logging in, youre notifed that Updated softwares avalabe Like any madern OS Install the Ubuntu Advantage tools and you ean keep your 16.4 installation truckin Ubuntu Tes mw mem dea. enoee eo (monet fae s|@Ttce KAA doe BEa Uburtu1s0 sizes : = ° oo | | e a0 re ‘2000 lo ohh nek te? a FALE IL ELE CLS LLP LAIIE you should update Ubuntu regia Unlike Windows,» Welovea Unni doesnot suddeny free updates upon you nor good er and does make your machine unusable or hours wie they Ure Otce makes install Update alerts and indeed any notfeations) can means. We bemutedbytopgingthe Do Not Disturb swtchinthe fame te notiieaton are, They canalsabeconfgiredona per fitedona Sppcation bai rom the Settings panel SomRoM, tough Ifyou get an upgrade alert, you might notice some Updates are marked as Ubuntu Pro updates and greyed fot. Ubuntu Pro's aitle controversial (among fe software users) because i's (potential) a paid-for service that seems to gatekeep certain updates from non- Pro (amateur?) users. In truth, there's no real need for this fuss. Ubuntu Pro's free (on upto five machines) for home users. and ifyou don't want, you're not going to miss any vital new features ana you'e certainly not going tobe deprived of any ertcal security updates. I you want toactvate it. you need to sign up for an Ubuntu One account at htips://login.ubuntu.com. No credit card Getais are taken (only a valid email address is required). (Once you're enrolled, you can activate the Pro updates by ‘pening the Software Updater tool (again, search fori in the applications menu) and entering your credentials in the Ubuntu Pro ta. ‘There are some additional benefits to Ubuntu Pro, mast notably 10 years of support instead ofthe usual five, Note that support here means security updates and bugfixes, as opposed toa 24/7 helpdesk. This Extended Security and Maintenance (ESM) support applies retrospectively i so fyouhave Ubuntu 1604, running somewhere, you can keep it shipshape uni Apa 2026. Infact. if youhave the previous LTS release, Ubuntu 1404 (Trusty Tah). running Canonical has anounced that paid ESM support is now available fr this (unt Apri 2026). Just because you can do something doesn't mean you should, though. and in general, you should upgrade to the latest LTS release wel before the regular support period expires, The Hacker's Manual | 15 Distros Add some customisation Make Ubuntu your own by installing the applications you need and tweaking some pertinent settings. ve covered te sss noi tinea WCW erection fatter eten ou nay mnt tFegte crests = eroumon oon war me Googe Diner eat OeDres ulae ihe fear ean tho nesta Gat irom rote emat acon scan soos wins Ecmgrortercers menos Yorvar tocowecttscupsnis avert tec rer arb Oe seas secon te Sets op Eater ered peal ew seston and stead es tepntr t g Jos thw stn The eaalongo gtr at Sates weeping yaa pcre tara tan the app Getoprs emacs Ts url cont win hate but acest Srtrowentin he opeslgschte sat yd td yg te sue code Go sf tA or do yous Ove pt seas avounecnontciopes ave aed hat ‘at ener appdomtpetsto cet res movie spats name ey etc (eure nao Aplnegs wer by bold gat sondadad tne nes he Patel rahtes/ anasto) sane popularity for GUI apps. Canonical pushing ahead With its own format ~ Snaps ‘Apart from making ite easier for devs and distro teams, these universal packaging formats al offer some degree of confinement for increased security. Snaps and Flatpaks have fine-grained permission ‘management, so they can only access the resources they need. When you search for something in the App Center, the search bar separates the results into Snap packages and Debian packages (Ubuntuis based on Debian). Allthe featured apps there are Snaps ‘nowadays, and Canonical iskeen to point out that ‘Snaps can be used to package system services and server too's, which Flatpak isnot designed for. Good (sn)apples and bad apples The problem wth allowing anyone to publsh onthe Sap Store. or otherwise put ther packages in Flathud or other storefronts, is that some people il attempt to distribute malvare this way. The Snap Store and Flathub both ge welt known apps averied ick, but nether has the resources to ef every contribution. Nt ong before we wrote ths. a developer was found to have uploaded 10eryptocurrency wallet’ apps tothe Sap store. Not one ofthese was legitimate: n fac, all of them would netariouly cain any wallet a user A Vitlmcm oleae \ ole ‘The most popular Ubuntu flavour is probably Kubuntu, which uses the KDE Plasma desktop ~ a fully featured stylish affair that (by defauit) has.atractional taskbar and apps menu set up. The latest KDE Plasma 6.0 arrived too late to make itinto Ubuntu, but were running a desktop special showcasing it next issue. Tune into find out how toget iton Ubuntu 2404 Ifyou remember the original Ubuntu, or the Gnome 2 desktop that it was bult upon, check out the MATE flavour. This is lightweight and pries ise on “traditional desktop metaphors” while providing 16 |The Hackers Manual ‘modern conveniences (such as being able to insta-search the applications menu). The lightest flavour is Lubuntu, which uses the LXQt desktop. Or for something in between, try the Xfe-based Xubuntu, There's also Ubuntus Cinnamon and Budgie, which Use the desktops from Linux Mint and SolusOS respectively. And for Chinese users, there's Ubuntu Kylin Ifyou remember Canonical’ in-house Unity desktop (which reigned from 2010 to 2017). or like the ook ofthe screenshot on the previous page, you might want to check out the Unity flavour After Canenical > Lubuntu’s elegant and lightweight desktop Is hart fut itched its desktop, a brave hacker took onthe mantle and resurrected Unity with modern applcation/liorary support It's been an official flavour since Ubuntu 22.10. Read more about Ubuntu flavours at https:/uibuntu, ‘com/desktop /Mlavours jubuntu Finally, besides the desktop flavours, there are also EduBuntu and Ubuntu Studio, “These both use Gnome but the former comes packed with tools for education, and the latter comes with ‘everything you require to make musi, art or video, 2 Thee ad ether nding ene and recive poe ma ein the Sap Stree op Cats rw You can configure ‘everything {including Onine ‘Accounts) from the ‘Settings panel >We were pleased tosee TNNF (the most popular PC racing game) was prominently ‘bdvertized in the ‘App Center The Hacker's Manual | 17 Celebrate STi Aeris € ») aH | IE = ij wr yy) of Linux! How a 21-year-old's bedroom coding project took over the world and a few other things along the way. wr : 30 years of Linux Inuxonly exists because of Christmas (On January 5 1991, a 21-year-old computer science student, who was currently ving with his mur, ‘trudged through the (we assume) snow-covered streets of +Helsink with his pockets stuffed fll of Christmas git money. Linus Torvalds wandered up ta his local PC store and purchacedhis first PC an ntl 386 DX23, with 4ME of ‘memory and 2 40MB hard dive. On ths stalwart mache he woul wit the fst-ever version of Liu. From tis moment Cn. the Fistor of Linux becomes lve story about community colaboration open-source development, softare reedom and open patios Previous to waking into that computer store, Linus Torvalds had titkered on the obscure (UK-designed) Sinclair QL (Quantum Leap) and te far better-known Commodore VIC-20. Fine home computers, but nether was going to birth a wori-stradaing kernel. A boy needs standards to make something that willbe adopted worldwide, and an IBM-compatible PC was 2 perfect place to start. But we're sure Torvalds’ mind was focused more on having fun with Prince of Persia at that point than specifically developing a Microsoft conquering kernel Let's be clear a 21-year-old, barely able to afford an Intel 386 DX33, was about to start a development process that would support a software ecosystem, which in turn would run mast ofthe smart devices in the ‘world, a majority ofthe internet, all ofthe world's fastest supercomputers, chunks of Hollywood's special effects industry, SpaceX rockets, NASA Mars probes, set driving cars, tens of milions of SBC lke the Pi anda whole bunch of other stuft How the heck di that happen? Tur the page to find out. “A 21-year-old, barely able to afford an Intel 386 DX33, was about to start a development process that would support a software ecosystem...” The Hackers Manual | 19 Distros Pre-Linux development Discover how Unix and GNU became the foundation of Linus Torvalds’ brainchild ouderstnd how unucat stared yuneedto OT essen sth opr stm standard trough the 1850s ote 170s hs arent) power mairares bultby te es BML HP ar Mer ans tthe =ey were mega cepa ating thr ps ound gon raat the development of Un youl see cera parle wth nx retaining academe pes wo were hen ein to develop at ny want But eres Un wasuimately bored info cose surce corporat, ed toa fred and nding development ter rod by of marina awe’ te, ‘Gowe tat oloned Lnaevaced reeset ‘open approach. This enabled free experimentation, dovelopment and collaboration on a worldwide scale Yeah, yeah, you get the point! Back to Unix, whichis an operating system standard that started development in academia atthe end ofthe 1960s as part of MIT. Bell Labs and then part of ATT. ‘The intially single or un: processing OS, spawned from the Multics 08, was dubbed Unis, with an assembler editor and the 8 programming language. At some point that “es” was swapped to an"x” probably because it was cooler dude. [At Some point, someane needed a text editor to run ‘ona DEC PDP-L1 machine, So, the Unix team obliged and developed rot and tof, the frst ital typesetting system. Such unfettered functionality demanded documentation, so the “man” system (stillused to this, day) was ereated with the ist Unix Programming Manual in Novernber 1971 Ths was alla stroke of tuck because the DEC POP-1L was the most popular mini ‘mainframe ofits day, and everyone focusedon the neatly documented and openly shared Unix system. In 1973, version 4 of Unix was rewritten in portable C, though it would be five years until anyone tried running Unicon anything but a PDP-1. At this point, a copy of the Unix source code cost almost $100.000 in current. ‘money to licence from AT&T, so commercial use was limited during the 70s. However, by the early 80s costs had rapily dropped and widespread use at Bell Labs, [ATE and among computer science students propelled the use of Unix. It was considered a universal OS standard, and inthe mi1980s the POSIX standard was proposed by the IEEE. backed by the US government. > Ken Thomas (left) and Dennis Ritchie are credited with largely creating much ‘ofthe orignal UNIX family of operating systems, while Ritchie also created the language. ‘This makes any operating system following POSIK at least partly f not largely compatible wth other versions. Linux runs everything Developing software or supercomputesis expensie During te 1980s, Cray was spending as much on software development as it was ons hardware. 8 tren that woul only grow. Cray tially shifted to UNIX System V then ‘a BSD-baced 0S, and eventual 2004, SUSE Linuxto power is supercomputers. THs was matched across the sector andthe op 500 supercomputers (ww.top500.0rg) now all ron Lin, Internet services have ago al been developed to run on Unik systems: Nerosot and 25D systems do retain a good sce of Services but over 50 per cant of web servers ae powered by Linux Recent moves to virtual Series with contamer based deployment are 20 |The Hacker's Manual all Lnuxbased Meosot’s cou ‘Service Aaie reports that inst argest Seployment OS and, more to ‘he point. Google uses Litt power most ot Its series, 8 do mary other service suppbers aka AWS, ‘reds mobile OS share dropped in 2020 to ust 84 percent its powered by Linux Google bought the start that was veloping Andros in 2005. LineageOS {https://lineageos.org) saw ‘maintained fork of Andro and supports most popular handeets wel after their ‘manufacturers abandon them ‘Space was thought tobe Linx’ final ‘ron, because snot a erties Ceterministic OS which the gol standart for eatime OSes mn missional situations. Tums out that SpaceX rockets use Linato power the tght systems. using a tuple redundancy system. while NASA ‘sent Lina to Mars in eliopter one Ingenuty.Tesiais a0 reported ening Holiwood's special etc since 1997's Titanic usee 3 Lnux server frm of DEC Aphas tDigtal Domain to create is COL Dreamers Shrekin 2001 was the fst lm that was entirely rested on Linux systems, Meanwhile, Poa ported its Renderman system Linux fom SG and Sun servers ‘around 2000 in tee to produce Finding Nemo n 2003, At the end of the 1980s, the Unix story got messy, with commercial infighting, competing standards and Closing off of standards, often dubbed Unix Wars. While ATI, Sun Microsystems, Oracle, SCO, and others ‘argued, a Finnish boy was about to start university We GNU that Before we dive into the early world of Linux, there's another part ofthe puzzle o its success that we need to put in pace: the GNU Project, established by Richard Stallman. Stallman was a product of the 19703 {development environment: afreethinking, academic, hippy type. One day, he couldn't use a printer. and because the company refused to supply the source code, he couldn't fx the issue ~ supplying source code ‘was quite normal atthe time. He went apoplectie and established a free software development revolution: an entire free 0S ecosystem, free software licence and philosophy that's stil going strong. Take that, Proprietary software! Linux Format interviewed Richard Stallman, the creator of the GNU fee software movement, In 2011. 30 years of Linux Linus Tovalds| being interviewed by Linux Format ‘ack in 2012, ‘The GNU Project was established by Stallman in 1983, with GNU being a hilarious (to hackers, at least) recursive acronym for “GNU is Not Unix” Geddit? ts aim was to establish a free OS ecosystem with all the tools and services a fully functioning OS requires. Do keep in mind that most of the tools created then are stil being used and maintained today, By 1987, GNU had established its own compiler, GCC, the Emacs editor, the bass of the GNU Core Utiities (basic fle manipulation tools such as list, copy, delete and so on), arucimentary kernel and a chess engine (Gee LXF273). But more importantly, Stallman ad Cemented his idea of software freedom with the 1989 “He established a free software development revolution: an entire free OS ecosystem, free software licence and philosophy that’s still going strong.” ‘copyleft” GPL software licence, and his manifesto setting out the four software freedoms enabling users to.un, study modify and distribute any software ~ including the source ~ for any reason. ‘The GPL remains the strongest copyleft licence, and while ithas perhaps fallen out of vogue it's stil regarded as the best licence for true open-source development, and cements most Linux aistros. GOC is stil an industry standard, Emacs remains a feature-rich development environment, and the GNU Core Utilities ae stil widely Used in certain POSIX systems and most Linux distros ‘Yu could argue that without the GNU Project being established, Linux would never have taken off. The GPL. licence (adopted early on in Linux development) forces all developers to share back their enhancements to the source code. I's a feedback loop that promotes shared improvements. Alternative open-source licences enable corporations to take source code and never share back improvements, meaning the base code is more likely to remain static. This was backed by a generation of The Hackers Manual | 21 Distros >We have to mention Tux, the mascot of nur, because a penguin once bit nus True story! gt pe L the turn of the milenniur to, mong other things. get Linux nto data centres and Moston’) empoyerin THE LINUX FOUNDATION ‘developers that grew up studying and using Unix looking to contribute toa truly freed open-source OS. Let's all Freax out! We're getting ahead of ourselves. Linus Torvalds had his Intel 386, was studying computer science atthe University of Helsinki, and was using the MINIX 16-bit (OS and kernel. MINIXis a POSIX-compatible Univike (8 and micro-kernel. In 1991 ithada liberal licence, costing just $68, offering the source code but restr ication and redistribution imagine the 16-bit limitation spurred Torvalds to create his own 32-bit kernel, but he states the licence restrictions were also key So. on 25 August, 1991, he posted to compos. rmintx that he was developing his own free OS. He said that it was “nothing professional ike GNU? andi’ only support AT disks, a that’s all he had, This was developed ona MINIX system, compiled on GNU GCC, and he'd ported (GNU bash, Torvalds had planned to call his OS Freax, combining Free" Freak” and Unix” but once | he'd uploaded it to fepfunet i volunteer ‘admin (A Lemme) renamed it Linux, as he thought it was better, So, version 01 ted of The Linux Foundation orks. Tey became whopermited —( ues merged ta ) Today the Ls Patinum Inte 22 | The Hackers Manual him to continue kemel development alongside been set up. By 2007 its work was most ding people to steht Linux, andthe two ‘of whom, contribute (bs a milion dlrs required for Platnum stats) great deal of code tothe Keene in 2012, when Microsoft wanted to get Linux working nits Azure cloud they were fo atime the > Minis fr alo its creator's protestations to its superiority has ceased development, even though it runs Into's CPU Management Engine. ‘of Linux was released tothe world in September 1991 One teling part of the release notes states: "A kernel by itself gets you nowhere. To get a working system you need a shell ‘compilers, a library tc. Most ofthe tools used with Linux are GNU software and are under the GNU ‘copyleft. These tools arent the distribution ~ ask me (6r GNU) for more info! Importantly this outlines Linux's reliance on other GPLicenced tools, and shows the use ofthe term ‘cistribution’ naw shortened to “cistro” As Torvalds points out, an operating system isnt a kernel alone: it's collection of tools, scripts, configs, drivers, services anda kernel, lumped together in an easier form for users to install and use, {A forthe licence, Torvalds intially used his own, which restricted commercial use, but by January 1992 he'dbbeen asked to adopt the GPL and had stated the kernel licence would change to align it withthe other tools being used. It was December 1992, and for the release of v0.99, the Linux kernel was GPLV2 licenced. This cemented the legal clause that anyone using the kernel source has to contribute back any changes used in published code. bagestcontibutr Besicesfuneng the source projets, ncuding Let's Enerypt. the (pends Foundation and te Core Butts not all code and corporations provide interviews and coverage trom the fnnual OpenSource Sum We ook foward toconference season resuming, We con got back the snack tors and cofle counters, the halt 30 years of Linux Early kernel development Refining the very heart of Linux hasn't been an easy ride over the years... reyouaecnt int cone hos hao A tiaras ramet oth og cation la mabearng aero ober ang ares Then spare up orthse ey apts whe Dusrovors onmetheutroees bined hal or contrporr deep Lint pent cmparthely feats ney posbl testy yur menor bye natgntormaton Ever sts th Gu Ty eine on wt on iy le inte erty dys ven gtig arouse to verk was non tN rene Weer tote aint meal cater ot asad ooo ao tortura Got prood tet made mane cven mercer sung uti kor oes comcresogucsnd tren though has prerete an APN fe wien carse ys hatte yours So ie n 2000 uso whined abot dows Me beng sew and Subir ear mode 60S your werage Cin use wou amp ne ett roses competed Evo avg hastage twoutsee feta opts ostppus he OS woud boc Steely Herdvre acon wes wal ‘icin oof fon ee tbo ren Cn mos weet rducion aly Yesoehon tne poner persed: mony wae Nemnase at € repicaions compar OOH Desktop preferred the DOS way of working, which began tobe sidelined asthe millennium approached. Windows users ‘were having their les abstracted away ~My Computer epitomises ths movement In January 2001 Kernel 24 was released and with it ame suppor for USB and the exiting nest Penta IV processors. among ather things. was of particular importance to desktop users thanks toits unified treatment of PO, ISA.PC Card and PnP devices as well ‘a8 ACPI suppor. The dot-com bubble was ust about to burst, bt all th excitement and speculation around it meant that many computer enthusiasts had a broadband connection in thei home, some even enjoyed the hnury of ovning more than one computer User-unfriendly Linux “This soved some major entry barriers to Linux: people could row downlad it much more easy o-te documentation was easy acess are when Line sft to disappear eres interact connection (r render te system unbotabe), he other machine could be used to seek fuidance. Butthe user experience was sion the whole ‘woeful inhospitable, While some instal had evohed ‘aphical eapabities, these mor atten than nat were more ‘rouble than they were worth Users were expected to understand the ard ou of sun 6), 068 a The Hackers Manual | 23 Distros sk partitioning, ane abe to dscern which packages they required rom often terse descriptions. ‘Windows XP was released in October 2001. and while this was seen asa vast improvement over its predecessor. many users found that their machines weren't up to running. Afterall it required 64MB RAM ‘and a whopping L5GB of cis space. Remember that 'B10Ses had only recently gained the ability to address large drives (there were various limits, depending on the 10S, 21, 4.2 and 84GB were common barriers). So ‘many people couldn't install ton their hardware, and ‘many that met the minimum specs found the Performance rapidly degraded once the usual pantheon Of ofice suites and runtime libraries were installed This provided the motivation for another minor ‘exodus to Linux, and the retro-hardware contingent continue to make up a key part of the Linux userbase (and berate us for not including 32-bit distros). Before 2006 all Macs had PowerPC processors, and mary of these (as well as early Intel Macs), long-berett of software updates from Apple, now run Linux too, Gnome makes an appearance ‘The Gnome 2 desktop environment was released in 2002 and this ould become a desktop so ifuental that some stil seek (whether ot of nostalgia atavism orcurmudgeoiy Cstke of moder ternaties) to reproduce it tamedtobe as spl, teskable and tute, and i’shard to argue _aaint its achieving allo these adjectives. One of the major ‘enablers was its strict acherence to the Grome Human Interface Guideines, which set out some key principles for application designers. This meant the desktop was consistent not justinteraly but in respect toallthe GT apos that e9ple woud gon to write fort ‘Also released was KDE 3, which vaguely resembled ‘Windows ~ in that it was cosmetically similar and slightly more resource-demanding than Gnome. People ‘and distributions sided with one or the other. SUSE Linux (predecessor of openSUSE) alvays aimed to be ‘desktop agnostic, but went KDE-anly in 2008. Today it ‘eaters to Both Gnome and KDE. Inlate 2002, DVD Jon Johansen was charged ‘over the 1999 release of the DeCSS software for circumventing the Content Scrambling System (CSS) used on commercial DVDs. Ths software enabled Linux users to play DVDS, a feat they had been hitherto unable todo since DVD software required a licence key from the DVD Copy Control Agency, one ofthe plaintifs in the suit. later emerged that CSS could be broken much more trivially and Johansen was eventually ‘acquitted. By this te iPods and piracy meant that MP3 files were commonplace. Thase were dogged by patent issues with a number of bodies asserting ‘ownership of various parts of the underying algorithm. ‘Asa result, many distros shipped without patent- ‘encumbered multimedia codecs. The law is murky Big Business vs Linux Being the oo ofl ei whenever money is invohed, tangs can turn nasty. So, when the big players inthe enterprise and business markets began to see Linux tos as a threat. layers were cal, sere of leaked Microsoft memos from ‘August 1998, known 35 the Halloween Documents forthe date they were released detaled Merosott's pate worse that Linux, and open-soure development in general was ‘direct treat to is business, along wth ways to combat its untae, This privat view wasn direct contict wth the company's ule ine on the mato, though Steve Ballmer ‘un the x86 UNKX market. aso fated infamously calles Linux acancerin 2001, The documents are avaiable at werncatb, (72/~esr/halloneen,andin them Microsoft predicted that "Linus on tack to eventualy Iwas comect There was ite Mcrosof could oto combat Linux as cul be bought. ‘The documents suggested extending open protocols wth Merosots oun proprietary tertension (that ent wor) and seeding the ‘market wt ear uncertainty and doubt FUD) “Tere was another angle owever:help a company thats sung ver copyright iefringement of the source coe. in 2003.2 ‘company called SCO cama part of ts UNIX System V sourcecode was beng used wit Lux making it an unauthorsed derivative of UND SCO sued IM for Sion (among many other companies), and demanded end users pay a Linux lence fe. Microsoft leaped int action and pad SCO $105 milon as detailed ina leaked ana verified SCO meme, After years of egal ‘arguments code aud found thereto be no ‘evidence of copied UNIX code inte Linux kernel. SCO went bankrupt 2008, but parts ofthe laws stirumbie on, o = x) = — SCE Coe 24 |The Hacker's Manual BEES i ECU! though, and rights holders have shown restraint in fling suit against FOSS implementations ofthese codecs. Most clstras are prudent and leave it upto the user to install ese although Ubuntu and derivatives wil do so ifyou tick a box. The MP patent expired in 2017. though itdoesn't really matter ~ we have plenty of open formats ‘and codecs now (OGG, FLAC, VPx and x264), I's stil technically DMCA violation to use lidess (a modern ‘and much mare efficient way of cracking CSS, used by the majorty of media players on Linux) to watch a DVD, but that only applies in some countries and to date, no ‘one has challenged its use, Early kernel development As Linx gan tract, fst among academics and Tebbysts and then. y the mi 30s when busmesses Sart t form around it the numer of contours tiooned One tale fom Lins mooi thet one the XMindows System was working on ux th x05) ¢ ovame much mote apeaine Se one could hat eventn1992 people wer aa ofthe command ine ‘Ths popirty eto te etait of te Trantarer etary so that patches submited could Se reviewed and promoted effete to Lins source tree though ha rt version othe MAINTAINERS le escbes Lio burod sive nema Te eralcentri evelopment proves stil folowed tody-exept hatte ofl nus Kee Mating List wos setup in 1997 and now Gt suse or vers contre Softeatat easr to aka sre you's worting onan upto-date rane, tthe traning to weatforfoppes nthe mai Patches are stllgererated Using if to stow whch ineshave been changed whith fes Before Git he proprtary BKoper Concurent versioning system (CVS) was use. Ad wine hsatengemert come oan end (rele by Andrew Tdge’s reverse engineering mischa) Tonalds gpthackng end 0 day ter there vos Gt fer two yearsin development Kemel 26 was released n2008 This was avast sferent beast 0 2a featuring scheduler entancerents, proved suppert or ndtgrocesse ayaa (rcocng rypertveoang NPTL and NUMA suppor), str /0 Shag omeunt of ectranardvae support We ako Saw the Pye ess Extension (PAE) that 32 it machines coud adress up to 640 of RAM (before they wore mtd to about 3268) Aso iosuced wos SOE POG poorer) Perey 30 years of Linux erry Ces imated to have saved pers eros fs “The venerable Advanced Linux Sound Architecture (ALSA) subsystem enabled (almost) out- of-the-box functionality for popular sound cards.” the venerable Advanced Linux Sound Architecture (ALSA) subsystem. This enabled almost) out-of-the- box functionality for popular sound cards, as well as. support for multiple devices, hardware mixing ful ‘duplex operation and MIDI, The most far reaching new feature was the old device management subsystem, devs, being superceded by udev. This didn't appear Lntil 2.613 (November 2003), at which point the dew directory ceased tobe alist of (many, many) static nodes and became a dynamic reflection ofthe devices actually connected tothe system. The subsystem udev also handled firmware loading, and userspace events and contributed toa much more convenient experience for desktop users. Although you stil relied on such arcana as HAL and ivman in order to automount a USB. stick with the correct permissions. Linux (having already been ported to non-x86 64 bt processors) supported the tanium’sIA64 instruction when i was released in 2001. This architecture was doomed to fall though, and Intel eventually moved to the more conservative AMD64 (or x86-64) architecture, which has been around since 2003, Pacer eee’ Peres Cre h ‘Blender The Hacker's Manual | 25 Distros > Asus EeePC Limox was based ‘on Xandros but beginners ide ke, ant o = o = ke “Thanks to open source development, Linux users were running 64-bit desktops right away, while Windows users would have to wait until 2008 forthe x64 release ‘of XP Various proprietary applications (notably Steam {and latsits games) run in 32-bit mode, which provides ‘some motivation for distributions to maintain at last some 32-bit libraries. Debian 1 will support 32-bit x86 in some form until 2026, but most ather distros have abandoned it. Eventually such machines wll go the way ofthe 386,n0 longer supported on Linux since 2013. Enter the archetype In.2004, a sound server called Polypaudio was released bya hitherto unknown developer called Lennart Foettering and some others. At this time desktop environments relied on sound servers to overcome shorteomings in ALSA's dix system: Gnome was using the Enlightened Sound Daemon (ESO) and KDE was sing the analogue Realtime synthesizer (ats) Polypaudio was designed tobe a drop-in replacement for ESD. providing much more advanced features, suchas per application volume control and network transparency. In 2006 the project, citing criticism that nobody wants polyps renamed itself PulseAudi (it was infact named attr the sea-dweling creature). With ts new name and increased demand fora sound system comparable with that of OSKor the newly released (and mach maligned) Windows Vita PulseAudio enjoyed substantial development and began tobe considered for ncusion in mary distros. As is tractional Fedora was the fst to adopt, incorporating it asthe defautin version 8, released i iate 2007 26 | The Hackers Manual Ubuntu followed sun 804, although its implementation attracted much eriticism and resulted in ‘much anti-Puise vitriol Poettering atone stage even scribed his brainchild as the software that currently breaks your auc” It took some time but eventually Ubuntu (and other distros) sorted out implementation issues, and it mostly worked out of the box. Now we have Pipewire in the works fora new generation of aucio-based rage against the machine. The cost of “The year 2010 may be remembered by some as the cone Ubuntu started tose the plot. Its Ubuntu Software Center row included paid-fr apps athe Netbook remixused anew desktop called Unity. nthe 1.04 release though, this became te new shel forthe main release too. Ubuntu had long taken issue with the new Gnome 3 desktop, which athe time ofthe Ubuntu feature treeze was not considered stable enough to include inthe release anyway. and Gnome 2 was aready 2 relic, Sina sense Ubuntu had no choles, but no one likes change, and users were quick to bemoan the new desktops. Of course thngs have come fll circle with Ubuntu using Gnome 3 once more since 2004 and people bemoaning the loss of Unity ‘Gnome 3is not without controversy too. Fist. many preferred te old Gnome 2 way of ding things and this Clearly was not that. Second, athe fancy desktop effects required a reasonable graphics card (and also working drivers). There was a fallback mode, butt severly crippled desktop usability. Finally this appeared tobe something designed for use on mobiles or tablets yet even today mobile Linux (not counting Android) has never taken af so why should users be forced into this mode of thinking? Many foun though. ‘that once some oldhabis are unlearned and some sneaky keyboard shortcuts ae learned (and Gnome's “weak Tools installed), thatthe Gnome 3 way of working could be just s efficient. f not moreso than its predecessor. KDE users looked on smugly, having aiready gone through athe rigmarole of desktop ‘modernisation (albet ess drastic than Gnomes) when KDE 4 was released in 2008. ‘Around this pont we ought to mention Systemd as well but there's not much to say that hasn't been said etseubere the oldint system was creaking a the seams: anew and beter one came along: t wasn't everyone's cup of tea, but we use anyway; the internet slander Lennart Poetterin Cre Cee fe Distro developments 30 years of Linux Asingle kernel has enabled a good number of Linux distributions to blossom into life. ‘ter looking into the development ofthe Linx erneitsel andthe surrounding supporting software's turn to how Linux distributions (distros) fom ths point were developed and branched into a wide-ranging ecosystem Distros enabled the use of the Linux kernel to grow rapidly. Not only lid they ease the installation of Linux (which early on was a complex process of source compilation, gathering the right tools, creating filesystem layouts by hand, and bootloader, al from the terminal on systems wit limited resources), out ‘one distr can also become the base fer a whole new distro tallore for anew use or audience. Primordial soup ‘As Linux v0.01 was only released in September 1981 the first cstribution of Linux - though by modern standards. it's lackingin every department created by H.Lu, was simply called Linux 0.12. Released atthe end of 1981, came on two 5 25:neh op cks, and required @ HEX eitor to get running, One disk was a kernel boot disk the other stored the root OS tools Inthose early days of cistro evolution things changed rapidly. Development was quickly adding base functionality, and people were trying out the best ways, to package a Linux-based OS. MCC Interim Linux was released in February 1992 with an improved text-based installer, and was made avalabe through an FTP serec. Xindons ~ the standard Unix windoning system was ported, and TAMU Linux was released in May 1992 witht packaged: makngit the frst graphical distro. While all ofthese are notabie as being among the first Linx cistros, they dit ast. The same can be said for Softanding Linux System (SL), als released in May 1982, which packaged X Windows and a TCP/IP network sack. I's notable, though, because of its shortcomings (bugs and a change tothe executable system) inspired the creation ofthe two longest unning and, in many ways, most influential Linux distros: Slackware and Debian. Nowadays, a number ofbase distros appear. reliably PENRO PNET es eed an ‘maintained by individuals groups, or businesses. (Once they're established, stable and become popular, offshoots branch from these root distros offering new specialisations or features. This creates a number of base distro genera, formed around the original package ‘manager and software repositories. The effet isa Linux famiy tree (see page 43), where you can date ll distros back to an initial root release, ‘Some branches sprout and di: either the group ‘maintaining it cisbands or there's no wider intrest. ‘Some branches become so popular they create a whole ‘ew genus, becoming te bass fora further expansion, Evolution, not revolution ‘As wth plants and arimals, offshoots inert tras, the base instal, package manager and software repositories being key. A package manager ishow the 0S installs, updates removes and maintains the installed software which includes downloading software packages from the managed software servers, called repositories. This can become contentious these child distros are leeching of the parent's bandwidth ~ but intially. while theyre growing this use won't ook much diferent rom normal user activ Bear in mind we're back in 1992, You're lcky it PE t 50 Shy Crocodile 2015 my The Hackers Manual | 27 Lire astro, ‘aptly named: Une 022. Thankful, by boing buesy SoftLandingLinox Kickstarted some ‘ood distros! The Rasparry Pi was rleasedin 2012 Inspire in party the success ofthe BBC ero (hence the monogram ‘model nares) nthe erly 1980s, the Raspberry Piaimed to ring practical the classrooms and bootstrap the UK electronics industry. as computer sie there's a 14-4Kb/s dialup madem at home: expensive TL lines (.54Mb/s) are limited to academic institutions and larger businesses. The early TAMU vLO distro required 18 disks for the 26ME binaries, and 35 disks for the 50MB compressed (200MB uncompressed) source code. This obviously limited access in these early days. ta academics and those in suitable businesses, so distro evolution was slow. Meet the ancestors Softlanding Linux System was popular, but it was buggy and badly maintained so in July 1993, Patrick Vokerding, forked SLS and created Slackware ~ so named because itwasn'ta serious undertaking atthe time, and was a reference to the Church of the SubGenius. This isthe oldest Linux distro stil maintained, and it's about to see its version 15 release after 28 years. Slackware is. interesting because it's very much controlled and maintained by Volkerting, while folowed by a small but, enthusiastic band of users and contributors. Whereas 28 |The Hackers Manual only ever expected to have been producedin the thousands Ofcourse when vas launched. Lnuxwas the de arto OS of chatce. ‘Whe many ofthese vies are now empowering young coders, a reat del have become pat of diverse mar-cave projets “he 30-somethings whocut ther toeth on ‘many other distros have taken an modern enhancements, Volkerding sticks to older more traditional"Unix’ ways of controling services on ‘Slackware. There's no formal bug tracking. no offical way to contribute tothe project, and no public code repository This all makes Slackware very much an ‘oddity that stands on its own in the Linux world, Due toits longevity, however. Slackware has attracted a couple of dozen offshoots, and atleast haf are stil ‘maintained today. In August 1993, lan Murdock, also frustrated by Sotianding Linux System, established Debian, a Combination of "Debby."hs grriend’s name at the time, and “lan” From the outset, it was established as. 2 formal, collaborative open project inthe spirit of Linux and GNU, Early on in the Debian project, Bruce Perens ‘maintained the base system. He went on to draft a social contract for the project and created Software in the Public Interest, a legal umbrella group to enable Debian to accept contributions. At the time, Perens was ‘working at Phar, so all Debian development builds are named attr Toy Story characters. The Debian logo also has a strong similarity to the mark on Buzz Lghtyear’s chin Debian is arguably the single most influential and important Linux distro ever. Just the sheer number of branches f distros from it would atest to that, bt Debian is renowned for its stably high level of testing dedication to software freedom, and being a rigorously \wellrun organisation. Its testament tots creator lan “Murdock, who sadly passed away in December 2015. Things were stil moving slowly into 1994 - there was lust single Stackware fork called SUSE and a few random Linux sprouts appeared, but ll died out. Then '88Cs,Spectrums and Commadore 4s ae reliving and reving the tras atte interface cf coding and creativity. The Raspberry Pis {GPO pins mean that al manner of ade-ons have Deen developed. otha the pnt sized computer can power anything rom robots to remote watering systems “The lingua franca of projects is Python \ahich ie Basie, easy ola. Unie Base though. t's consistent extensible and wont feed tobe unlearned should users ‘move onto more advanced languages ‘The P's suppor for 30 graphess lomressive, but CPUswae fs mare late, ‘The orginal is strug to function s a cesktop computer, even withthe mecest Raspbian istrbuton (although recent work nthe Epiphany web browser has improved te) In 2015 the Pireceivec the P2eboat gaining a quad-core processor aera RAM. and et stil ony cost £25 Jump forward sx ears and we have the iin vaious forme Inctding ful-deskdop capable BB version the P:400.a range of industry trendy models and over 30 milon sales Splenda, In October 1994, Red Hat Linux was publicly released. Red Hat was established asa for profit Linux business, intialy seling the Red Hat Linux distribution and going ‘on to provide support services. Red Hat went pubic in 1999, achieving the eighth biggest first day gain inthe history of Wall Street. t entered the NASOAQ-100 in December 2005 and topped $1 bln annual revenue in 2012. IBM purchased Red Hat in October 2018 - 24 years after its fist release ~ for $34 bln, So that worked out very well Atale of hats and forks RedHat Linux was relaunched as Red Hat Enterprise in 200, {and its commercial sucess attracted a wide ange of forks. Notably, RedHat directly supports Fedorasits testing sto ‘and CentOS ats free community eto. Orit. CentOS 'sboing shuttered ~ to understandable community scan ~ and a roling release, CentOS Stream. replacing it AS an alternative Red Hat Enterprise is now offered freely to community projets with fever than 6 serves. 30 years of Linux Meanwhile in Germary, SUSE (Software Lund System Entwicklung) stated life as a commercially sold German translation of Slackware in late 1992. In 1996, an entre new SUSE distro and business was launched, based on the Dutch Jur Linux, sling the new distro and support services SUSE was purchased by Novell in 2003, and in 2005. the openSUSE community ecition was launched, while SUSE Linux Enterprise was developed in tandem for its commercial arm. SUSE was acquire in 2018 for $2.5 billon and returned double-digit growth through 2020, with a revenue of over $450 millon. Yet despite its success, SUSE and openSUSE have only ever attracted a couple of forks. We could be wrong when we say this is possibly down to their European roots It's a distro inferno Between the creation of Red Hatin 1994 and 2000, ‘there were a number of Red Hat spin-offs, because at that point there was clear commercial interest in Linux ‘Throughout this period Linux was best suited to business server tasks, where much of the open-source Unix work had been focused. However, by the end ofthe 1990s, 56k modems had become commonplace, early home broadband was just appearing, and modern ‘graphical desktops were in development. Linux was about to get a whole new aucience organisation.” ) The Inte fan Murdock founded the influential Linux distribution Debian in 1993. Linux Format spent time talking with him in 2007, “Debian is renowned for its stability, high level of testing, dedication to software freedom, and being a rigorously well-run > Debian is the distro that launched more distros ‘than any other! arms ca > Chart the ne fama elgeemtoryeur | | ANGFONIK ‘avourte distro here a ‘OREDIT: Besedon te LnuTinelne yells, GA Fee Documentation Lice v3 tpt con Fabel oa/LnixTimeine/reenastr The Hackers Manual | 29 Distros With big bucks, comes big offices! Here's the Red Hat HQ sporting ‘Reo ogo. One early example was Mandrake Linux, in mid1998, A fork of Rea Hat, it was crazily aimed at making Linux easy tose for new users, using the new Kool Desktop Environment (KDE), The French/Braziian development team gained a lot of attention but ultimately, financial problems closed the project in 2011. However its spirit Continues inthe excellent but less wel-known Mageia and OpenMandriva projects. A distro with humanity in mind With Mandrake posting the way the early 2000s saw an explosion a sto releases. Nw thatthe Debian projet at this point wae wel etabished, well regarded and wel known. itbecame the basis for hundreds of Linux distros. But well ‘nly mention one: Ubuntu released in 2004 by South rican rillonae Mark Shuttleworth. who jokingly cals ise the set appointed benevolent dictator forte. The Ubuntu Foundation was created in 2005 as a philanthropic project — ‘Ubuntu is 2 Zulu word meaning humanity ~ to provide quality open source software, wth Canonical asthe supporting ‘commercial arm, Ubuntu asa branch of Debian has itself seen over 80 lstros fork from it, while Ubuntulas the highest share of all desktop Linux installs ~ though this isnatorously ‘CREDIT Bre, CC Y'SA.10 tpn wiped or// Re Hat /esa/ Flee Ho rdeparer a Rlogh, North Carina US.~9 Nowmber 2013p Get your Linux game Thor's aways been anche interest n gaming con nx but thes was mostly done through Wie, which has been around since the mc ‘90s and frankly alvays et tke stcking Plaster to enable Word af Warrat ar Whatever the current Windows game of choice was tobe played on Liu Linux game distin. Inaddton, at the end of 2013 Ve 30 |The Hackers Manual Things startet changed when Vave patted its Source engine to Linux tong with releasing is Steam for Linx cent in 2012 This opened the gate for Souce-based native announced was creating Steam0S a hard to measure ~ when users ae polled, Why Ubuntu became so popular is hard to fully pinpoint. Key is just lke Mandrake before it, Ubuntu set out to make desktop Linux easy for fisttime users. It aso offered the distro (on free CDs viaitsShipt service until 2011 alongside fast, relable server downloads. Furthermore, it was based on the popular Debian. it jumped on the new, slick Gnome desktop. andi set out a regular sicmonth release cycle, with a Long Term Support release every ‘wo years. Support was for 18 months (now nine months) for regular releases, and 36 months for LTS ‘ones (now five years). Ubuntu aso offered great forums and help sites, ‘along with a community council and support for forks such as Xubuntu, Lubuntu and many others. Ithad sane defaults, too, and made it easier to install display drivers (an absolute pain 10-plus years ago), while offering a huge catalogue of tested, ready-to-run open-source software and dedicated server builds, We guess when {yu say allthis out loud, it sounds peetty compelling! ‘wo core release branches well quickly mention are ‘Arch Linux and Gentoo, both released around 2000. Gentoo (named after the fastest penguin inthe world) is. ‘a buil-from-source distro compiled with specific ‘optimisations for the hardware t's going to run on. This is very clever, but also very time-consuming, Google ‘Chrome 05 s derived from Gentoo, In early 2002, Arch Linux was released, devised as a minimalist distro, where the user does much ofthe installation work to create an OS with just the parts required. This DIY ‘approach was partly why Arch is renowned fr its ‘amazing documentation and for roling out the earliest release of new versions of software, [At the height ofthe distro madness (around 2010), ‘there were almost 300 Linux distros, we'd argue an Lnsustainable number, with mary just repeating basic ‘desktop functionality already available in core raat distros, Progressing ito the 2000s, and with increasing dicated Deban-based astro for runngts ‘Steam chent. This as oti in iter with its {ald attempt at creating a Steam Macrine ecosystem. Today there ae over 7000 native Lux games avalabeon Steam, out of ‘around 14000 total, Perhaps more significant is that Vabe never stoped ceveloning Steam0S,cespte its Steam Machine fare In 2018 Valve ‘released ts onm ternal fo of Wine called Proton that was itepatedinto Steam sof and prope Linux supper for Windows ames toanew evel wth curently 2 Fepartea 80 pe cent of games fering Platinam compat, But why ll hs work ust tohelp one cent of Steams Lnucusing gamers? Ths ‘summer Va reves ts Sear Deck, 3 Une powered harehed PC console, hich it Promised would run all Windows games vats ‘Steam Proton iver Pethaps 2021's year of the Linx desktop ater a complexity in maintaining a ‘moder OS, the number of Linux distros started to reduce, but that didnt stop well ‘organised groups creating popular new distro forks when they felt a need. ‘Agood example is Raspberry Pi OS, a rebrand of Raspbian. itself a fork of Debian. The new Arm hardware platform needed a dedicated operating system, so picking up Debian and refiting it for the Raspberry including educational software, ibraries for its GPIO access, and talored tools to configure its hardware, made absolute sense, Linux hardware specialist System76 was tired of rigging sotware issues associated with using other distros, and wanted direct control So. it introduced Popl_OS, a fork of Ubuntu to not only rectly support its laptops and desktop hardware, but also its customers’ needs. I's slick, modern distro, with support for popular software and hardware. Linux Mint stated in 2006 as a small personal Ubuntu fork project. When Ubuntu changed tots ‘madecn” Unity desktop design in 2011, many users revolted. The Linux Mint project created its own ‘clasic” desktop called Cinnamon, in 2012, and it ‘brought many former Ubuntu users with it.The Linux Mint project has stuck with ts “user fist” design ‘approach, and evolved remarkably well This doesn't even touch upon commercially focused Lux Mint became one of the most popular distros by, Unbelievably, giving users what they wanted! distros, such as Android, Chrome OS, Intel's ClearOS, Google's Wear 0S, Saitish OS, and the host of server: specific distros. Even today, there ae well over 200 active Linux distros, and they're as diverse, interesting, and wonderful as the communities that use them. Looking forward But what ofthe future? Technology peeditons are notoriously tricky, but why would we ever et that stop us? Wil Tuxstillbe active in 30 years? Weld say that's a safe bt: evn fall development stopped now. people would Keep onusing it for years i not for decades. There are retro computer systems that are stil ticking cover almost as long later, and the Linuxkerne is far ‘more tunetional than they ever were. ‘Amore ley scenario Google as an example ‘moving to an altemative kernel ~ Fuschia, say ~ though this woud likely just be for Android and its loT devices. Yet evenif Google moved iterally everything it runs to Fuschia, the Linux kernels used sa widely elsewhere that it would just keep on trucking 'AS we've seen, the Linux word is large than just its kemel.An OS isa whole ecosystem of interconnected systems that have tobe developed tested and packaged inan orchestrated manner. Linux was built on GNU tools adits cence: his widened the appeal ot Linux and enabled the kernel wth suitable distros tobe deployed in such vastly difering devices rom the fastest super computer inthe world to lowly $4, “The Linux kernel sn tied to the sucoess of anyone corporation. Sure, there's the Linux Foundation and Torvalds himself but succession has aleady been put into place to keep kernel development going i Torvalds should step down. And while the Linux Foundation isn't necessary. it's certainly handy to orchestrate and hancl funding and trademarks. Patallof that aside, the reason Linuxhas succeeded is that i's damn good at its jb and everyone can contribute. t's the single greatest software development project of modern times, which doesnt mean it's perfect ~ is software afterall ~ buts contnualy improved and ennanced.i's stron copyleft open source fostered a fabulous cormmunity and’ given usall endless opportunities So keep on enjoying it 30 years of Linux > Google's Android (not a Astro) is frowned "upon in the Linux ‘wort, but you can't deny the cffect it had on the market. The Hackers Manual | 31 KERNEL 79) of the operating system, as well as some things you might think belong elsewhere. This includes drivers, filesystems, network protocols, schedulers (process ‘and I/0), memory allocators and al kinds of other treasure. Inthe early days of Linx, users would regularly have to face compiling their own kernels, sometimes to get new hardware suppor, sometimes to reconfigure their ‘way out of brokenness, and sometimes to improve performance. Users of Linux from the Scratch or Gentoo days willbe familiar withthe kernel compilation process, since its more or less mandatory there. Butts an option for any flavour of Linux, so we thought weld have a goat making building kernels more accessible ‘As well discover, the Linux Kernels hhuge and complicated. t may be tempting for some to pore overt with a fine-toothed comb, trying to “optimise” it fr speed or size, But this is forthe most part hopeless, and more likely to resin breakage than anything else. If you want a faster, more responsive kernel, then a better approach is touse one ofthe many custom efforts that are avaiable. Build the Kernel Grasp the kernel basics Just what is a kernel and why is it telling my computer what to do? en out an operag ten) WW saint re thats respraic er eer compet oes fe te BOS/UEN has ce corhto toteota espn syeme suchas de sninesDs sony hare rsyting ego es, Traweechocet dope noon obra toe (opcomrantneandorealwaytrenacecore SGoistow tue te’ dnd) Ou tckar acting: ae mad roar fe pages en Ueto ott oer og sean smache Seraratd ye chou canon aly he torn eke los tte atone Creare splreor ron et ttensut ao Sourngatomtos otra “heart macO i basedon erty ny arn nls revo eto Clint Ost region thn te) te Dann OS uponwncht tases Bown sapen sue suport SSD and ut aso barons tometer fe arcu NOCTTEF wet vas by sol ‘99h Danfoss rela XN on Srompmonchatn). whee ioe ard thus anyd scoped toa mort ai Dexa thecal ray esearch ret ‘fomirchamls no ctr aed erate ESO ese terre) The ores rst macoS ‘ame res GL ne Oa/Caon otras od (Gros apptson sere areal pray arta "StetocowoS0 Driving the deal The IU tere has sown river API caled Kt. ane Windows Kernel has theless magi ted “Windows Over Modal Drivers (popas tat ato rardnare ar perhaps the easet component ofa tered og yorhaod around Bosco soy to Sewn they need tobe thee The oi ees most modern Lng sos have very fw ders bake nt thar teres Instead, the prterred appreach sto ila divers comple as eral es, tic Conve loaded eat oni the boot process by Ute stn the corespordngharare detected. Modules plug straight nto the erel ae fo the mest prt act, ts thoy wre aor of Otter eel corpane nis can te todas nd ade on demand ton but eran Towel sjstems (or example, te one fr loading tmadats inthe st ploe), have tbe bln othe Linux Kernel corainecrivers or every bit of tarware superted by Linux Wel, mest Modern ordre (artery Wand GPUS) often eau Ierae tobe uplaed tit on every book ears it wor'twork Ts mar general not ncn Gtrinibor's Kemal source pacha ance tsk Seutce code and sometimes prope), but rater Shipped ne separate Inu firmare phone >The kernel ‘samodular masterpiece that ean un everything fom ld AGP graphics tothe Large Hadron Collider. Since this package is required for all the drivers the kernel (usually packaged as limuximage-..) to work, we can’t forget its size (Mb/firmware occupies over 700MB (on our system), Drivers themselves, ccupy fairly negligible space. Mai ‘ver the page we ook at comping a trvally modtied Ubunty kere ‘Canonical apply patches ana haexported tues tothe keels, wth he eect ‘that an Ubuntu eral bearing te version number 5130, say (which we gt by ‘unring uname on our uns 2008 VM) may be coasttutonaly very Giterentroma"matnine” Kernel 5.13 that you would download rom https” ermolong, You might vant to bale your own mainline Kemal. for example yu suspects bug hasbeen fi upstream (or ndeed you thnk that an Unto patch rtrecuced the bug. Thats easy: just extract the source tree and fellow fhe instructions over the page. ‘Wat's ven easier is using the pre-packaged mainline Keres produced by the Ubuntu team Fst reac the blur at https://wikiubuntu.com/Kernel/ ‘MainlineBulds then flow the ink there > the Manne Kernel Archive You se that wise Ubuntu 2.10 ane LS its lee out withthe Harare Enablement stack) are unning Kernel 513. the current in-devlopmentsenes(contusgly so caled"marine")'s 517 We ‘on acvise trying out these release canccate (RC) kernels at fret. But you ining ‘may have reason to try the Longer branch which currently is 515, As of {ts branch s used by Pop!_OS ae’ what the next LTS of Ubunts wll be based on The Linux Kernel Archives A | > A smorgasbord of eres canbe found at htps://kernelorg. from bleeding edge-RCs,to the SLTS 44 series, Hacker's Manual | 33 Distros Compiling a kernel Get straight to business and build your own Ubuntu-esque kernel —_ ~~ et ‘compile your own kernel using Ubuntu I (or any distro that uses Ubuntu kernels, for ‘example Mint, elementary OS, but not Popl_OS) the fst steps to get haldof the kemel sources, ‘The official channel for vanilla keel sources is hittps://kernelorg, but this srt necessarily the best place to star, Instead, well use an Ubuntu kernel, which includes numerous patches and backported features. It ‘also has the advantage of coming witha configuration very lose to what you're currently running (in fact it's identical i you have the same version). So if we make ‘only small changes there, then we'd hope the resulting kernel stil has all the functionality ofthe ol. Besides the kernel source files, we also need the required build tools. I you've ever compiled anything before youl probably have al these. But not. get them with the falling '$ sudo apt build-dp lini lnsx-image-aname 1) Using uname like this ensures the build tools you're ‘about to dovnload correspond tothe kerne! youre running, and that both are new. Ifyou updated your system before this command, you might want to reboot (in.case a new kernel was available) and then fetch the bul too's (ana kernel sources). the command ‘complains about nat being able to find source packages, Yyoumay need to uncomment the lines beginning eb-s0 in /ete/apt/sources.lst for both the main ‘and updates repositories. Alternatively, since we've got abit of a Per favour going on this issue, thistle ‘snippet wil doit for you: ' sudo perl bak -pe “a/"# (debate ilsb releases) (updates)? main restictedS)'$1/"/ete/aplsources list Those dependencies are plentiful (and include Java ‘and LaTeX). but our storys not yet done. The (slightly outdated) Ubuntu wik at https://wikiubuntucom/ Kernel/BuildYourOwmKernel mentions thatthe previous command doesnt install everything required ‘And that statement i stil correct. The folowing, packages should filin any gaps, but if not youl be told What's missing ‘sudo apt install bncurses dev fakeroot kernel package ‘You may see a warning about updating kemnel-img. contin which case you should choose to instal the package maintainers version. In any event, lets get hold of those sources: > Switching trom ZSTD to LZ4 compression reduced the time taken to load the bemel on our virtual machine although not by anything significant. ait tacker’s Manual $ apt source linuimage-unsigned-S(uname +) Hf you're running the HWE kernel, which you probably are if you're running an up-to-date desktop edition of Ubuntu 22.04, then the sources willand in te Hmpx- hhwe-513-5.130/ directory. You'lalso be told thatthe HWE kernel package is developed on Gt, and that more Up-to-date sources can be acquired via: S git clone giti/itaunchpad.net~ubuntu-kerel/ “ubuntu/+sourcefinux/4givfocal Ether way, once we have the sources we may as well lsable the source repositories. If you used the Per! command earlier you can do this wth $ sudo mv 4 /etcapt/soureslist bake) Incidentally the apt source directive wll get the source code to absolutely any package in the Ubuntu (or whatever apt-based distro your using). Neat. We didn't use sudo in the apt command because sources are downloaded tothe current directory, which we carefully made sure was the home directory. The full kernel sources are large (12GB for Ubuntu 21.10) and ‘2p vl fll if there's insufficient space. If this happens hit Ctr, delete the linuxhwe® fies in your home directory, and try again somewhere with plenty of space Time to compile Having success downoad te sources, t's confgur anc compile them When you compe the Linux kerma youre re to include or exclude whatever components you wart, Tadtonaly. these were selected froma gonius tr based menu accessed by running ‘make menuconig. Tis hve moved on wand there's amodern configuration interface Dont get too ected, though = ssl tet based, bt now its powered ty nerses ond has a hacker syle ack bacground Summon tis th Sedlinuchwe'5.135130/ Sake nconfig See? Glorious. Navigate through the menus using to cursor heys and Enter. Option are selected or deselected (or solctd tobe bul as modules) using Space but don't change anting just yet jou can alvays ut by pressing Escape, thot saving and rn the st command again to return), Instead, let shave 3 leo at whats in your karl Everything's onarised nis menus, one of which is Devce Dmers ich we've alread take about You also see sections for Memory Management. Networking, Vitualsation and afew others that a right be expected to apperin an OS. Sections that house further options have => at the end ‘Welstart by making single. smple change. Go tothe General setup category Inside youl ee ats of Cenfusing options, ore of wich have been selected fccorcng to Ubunt's default configuration The option to use ZSTD compcession. you might recall became the dleautin Ubuntu 2004 \We can find out more about a particular option by highlighting it and pressing F2. Doing this in the kernel ‘compression made option tells us something about ‘hich compression options work best on what system, ‘as wellas a considered note about who to contact f certain options don't work. Let's switch to LZ4 Build the Kernel Note this s documented precisely nowhere. Finally let's build the thine: $ fakeroot make-kpkg 4 “Sinproc)” initrd ~appendto- version="sid” kernelimage kernel-headers ‘Now make a cup of tea because the stock Ubuntu kernels rather fully featured. You'l se fs being sted as. Compression and see if we can spot a difference. they're being compiled, inked and generated. I's , reasonably pleasing to watch, but you may need another ‘See what's on the SLAB ‘cup of tea. On our XPSI3 it took most of a lunch hour It youlke odd sounding acronyms, have a lok nt (Choose SLAB allocator menu (toward the bottom ofthe General setup menu). Before you get dragged deep into the rabbit's warren of kernel options exit by pressing F9 and make sure you save the configuration. Youll be toldit’s stored ina fle named config, One slight quirk with using the Ubuntu kernel is that it's configured by defauit to use Canonical's Trusted ‘Systern Keys. Because these arent included in the kernel sources, the build wil fall without some intervention. We can either manually disable the Keys (they re deep inthe Cryptographic Services menu). fr we can use the helpful Debian scripts $ scrips/config~setstr SYSTEM. REVOCATION KEYS. $8 scipts/config ~setstr SYSTEM_TRUSTED_KEYS This sets these to blank strings. The config program alsohas a disable argument, but if youuse that here it breaks because a string value is required here (Who said you were allowed an hour for lunch? = Ed) to finish up. over the course of which i got rather hot. Even in Covid-ree craughty corridors of Future Towers ‘All going wel you should see two .deb packages in your home directory (not the source directory): one containing the kernelimage. and one containing the headers, We've been careful to only do avery trivial ‘moafication (so, only changing the compression format) for our first outing. And with good reason, These packages are going to replace the current kernel packages onthe system. This shouldn't really bea problem since Ubuntu always has fallback kernel on hand, but we don't realy want our fist effort to result in akernel panic. See how you fare wth $ sudo dpkg -linux-deb ‘The kernel shouldbe installed as Grub’s new default, Check after areboot wth the uname-a' command, and if necessary hold dawn Shift to bring up a boot menu. > Compling ernels wl really put your (CPU through ts ces. Our laptop ot too hot to type on (now there's an excuse Colonel Kurtz advises. id we say final? Not quite ~ we til nee to run aed to ‘enumerate our modules andthen (finaly) undate grub with da updated Using the Ubuntu (technical Debian toot build kerels isa wall id good. But youre just hacking away ona kernel for personal usage you might rot want tog tthe Bother of packaging ial And its certaniy inconvenient od as we've dane and replace the current > you tke kere! packages with custom ones, since those packages willbe cverrten soon as Ub rlare an eel. - endless options, It'snot recommended to try and bul these packages with terent setings at nares, anc it's kal to break things you Wy to use ary other kind of ny fal werlaround here instead, you can build keels using the mainine arnoans| tools and not worry about packaging them You can run ml ion ee from the sources directory touse the (medern) ncurses configurator. Then once you've saved mais to bald and sudo make ‘module sal ona the mocules, nal, you want to copy the eral imageto Aboot with sudomak instal Hacker's Distros Kernel minification Perfection is reached not when there's nothing left to add, but rather when there's nothing left to take away... B bereretesiterenenae rcs thereon atte fautn ere youcort pout Tis provay tent pele ae IRerstodin rag hehe orate Toole burr arbedded pt whe stage space anime ae ean nar vars pos Fah apo cute rl error tat tre ely poomarc or memory item having so many unused divers compiled as modules. However, theresa disk space it, although perhaps not as large as you might think (see box, below). ‘Another reason for removing thingsis demonstrated by te Linuxiore kemel, Here, divers that require proprietary firmware o microcode have alleen removed. As has firmware and microcode itself which if youtake alook at your /lb/firmware directory (ours was over 700MB) adds up toa substantial saving, OF ‘course, removing firmware les shouldbe done carefully, since any device depending on them will cease to function. There's also the annoyance of carefully removing unneeded files, only for anew linwxfrmware package to appear and not only replace them, but ade yet more unnecessary rut At st glance, theres alot of supertiuous rivers in the | ermal But younever know when youll need ‘tape access. Spotting superfluous fireware Depending on your hardware it might be easy to see which mwa fies you need, o atleast which ones you don't need. For example, fyou don't have an AMD graphics card then you can remove the S6MB of firmware in firmware /amdgpu,o°indeed the 7MB of bits in iemware/radeon for olde cards, There's a small volume of irmvare forthe Nouveau diver, the open source offering for Nvcia cards, but t's nat really worth worrying about at ths stage. To get some idea about which rmware has been leaded on your syste. run journal -b to bring up the journal forthe current boot. Press / to instigate a search, land search fr firnare. On our XPS we found the following lines (and then some irrelevant matches to do Colonel Kurtz advises. ‘Space atleast the space taken up by the eral) on modem hardvare shouldnt be 3 concern. The compressed kernel image 7 ‘boot/vminuz ocr PoplOS system cecupies a mere IIMB, And the accompanying modules, foundin by ‘modules /515./ occupies around 425M. Ary other Unt based system wl have ‘ilar statisti (unless you have been ‘tweaking things area). hata gabe is important to you (which it might be ono hardware) hen comping a leaner kernal (th ony the quired arvers) woul be one way to achieve that Natural that comes vith the downsie that ityou ever scare Further vestigtingin the modules/ rectory reveals that the network. media and (GPU device drivers together occupy the mast space (165MB) Ifyou examine futher you ‘see that AMDGPUS the ages raps Arivr at around 20M. Nouveau, the FOSS Arivr for Nika caress by comparison a tiny 34M So axing whichever ofthese you dont reed is a str oslo down your ker. ‘rivers on Linux ar smal you mht have noticed Even AMDGPU istiny compares to the equialent massive (450M) downoad on Windows, Thecference is that ery ite of that Windows packages driver Most of its freware, oh ana shan but usles (rot ‘utright annoying) gameware applications So inrealty removing civers one by one sa fal thankless exerse(the terme configuration intertace doesn't make this easy ether. unlikely t berate more than ‘couple of hundred megabytes. Of couse theres plenty else to remove too but aga removing swathes of them hey going oto fend you up witha beoken (but undeniabsy = 2 The kernel sources directory gets big once you start compiling. Here the Intel grapes bits are occupying hal a gleabyte. [dem] Finished loading DMC frmrare1915/kbL dme_ verl_otbin (v1.4) _athl0k_pei 0000:2:000: firmurare ver WLAN.RM.44.1- (00157-QCARMSWPZ-1/ ‘So our Intl graphics need to run DMC (nice) frmware ‘and our wireless chip needs something too. The latter doesn't explicitly tellus which firmware file it needs, butt \we ook atthe output of spel we can obtain a model ‘number (QCAGI7A). And turns out there's a /Ib/ firmware athlOk/QCAGI7A directory, so that's probably what we want ‘Again, unless you're seriously strained for space i's ‘not really worth picking your firmware directory apart lke this Atleast it wasnt on aur XPS. But we do ‘maintain a growing collection of old hardware, including the undying Eee PC from 2007, With only 2G8 of SSD, there can be no wasted bytes. Indeed, such old hardware doese't need any firmware a ll. Natural, we've ‘slimmed down the kernel to next to nothing as well. If you're making a kernel that's talored for particular hardware, then a common technique is to build any required drivers into the kernel image as opposed to building modules. The kernel configuration interface ‘even has its own mechanism for selecting modules ‘based on what's currently loaded. To use this, make sure any hardware you'd like the ‘new kernel to support is plugged in and working, ‘S make localmodconfig This generates a configuration based on the current kernel configuration together with any currently loaded ‘modules. In general this results ina kernel that still has a ‘number of extraneous modules, but ifyou have the patience to iteratively compile, test and remove then eventually you'l find your way te kernel bss, can be taxing to manualy load every possible driver, andin some cases i's hard to resolve hardware names to ‘modulenames. I's particularly frustrating when you ‘miss a key module (yes, you do need SCSI disk support believe it or not) and have to rebuild the whole thing. One too that can help you with this ts Modorabedb (soe https://gthub.com/graysky2/modprobed-db), which keeps a database of al the modules ever loaded (on the system. This increases the chances that hardware youhaven't plugged into the system forages wil stil ‘Work withthe new kernel Where to compile your drivers? you'd rather have those divers compiled into the etre, a opposed to as modules, you can use the ‘command Jocalesconfig instead. ita previous configuration from an older kernel exists, youllbe asked bout new drives that nave been aded othe new sources, Usual its okay to accept the defaults here. ‘Once the new configurations written out we can use a handy seria to see any diferences, ke so $ scrptlaiffconfig conig.ad contig ‘ou should notice at of ines in the new le (prefixed by +)arenow set tonegative. Let's try bulding our cit sized kernel with a simple $ make jsinprc) The mproe incantation (used onthe previous page to) ensures compilation i divided ito paral jobs, one for each CPU core This might make your machine dificult to work wth while ital building, but wll certainly speed up compilation time. We're not using Build the Kernel ‘makekpkg this time, going instead back to frst > Proiie Arch principles. So this approach should work on other distros contributor tao, Once the image bulds we need to follow the Grayshy has instructions in the Colonel Kurtz Advises box. Let's eee assume you've done that, and installed your modules. = is modprobe andkernel, run depmod and the lke femora ‘Those steps should bulld a corresponding initrd (ina ramaksk/rams image) and putitin Aboot where it-can be found by GRUB. If you're not using GRUB. for example you're on Popl_OS which uses systemd-boot, then extra work may be required to get the bootloader to Give modules the heave-ho “If you’d rather have those drivers compiled into the kernel, as opposed to as modules, you can use the command localyesconfig instead” pick up the new kernel. We were pleasantly surprised this all worked almost without a hitch on our Popl_OS laptop. But do study the documentation forthe kemelstub utility before going in with all guns blazing, ‘Systemat-boot requires the whole kernel ta live onthe EFI partition, and you don't want to accidental fil this up ‘As you become more involved with bulding kernels, you'l grow more and more familiar with the configuration interface and where particular options hide. You'l aso find that, contrary to widely mishela bole, Linux does in fact support a huge amount of hardware. From HAM rac to steering wheel controllers (new in 5.5) to ISDN modems (remember them?) “There's also a good amount of weicdness fyou nosey deep enough into the kernel sources themselves then you can find plenty of interesting stu The arch/xB6/ purgatory subdirectory for example contains \VMspecific code, Specifically, purgatary is an object that sits between running kernels (for example, wher a ‘ew kernels about to be loaded) Ifthe process goes wrong the kernel hangs with a fendly“Im in purgatory ‘message. I's possible to disable purgatory, but this won't absolve you of your sins. The Hacker's Manuel | 37

You might also like