0% found this document useful (0 votes)
200 views

The Complete Linux Coding and Programming Manual - March 2022

Para los que se inician en el mundo linux, aprendiendo a programar en este sistema operativo.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
200 views

The Complete Linux Coding and Programming Manual - March 2022

Para los que se inician en el mundo linux, aprendiendo a programar en este sistema operativo.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 148
~_, BDM's Complete | Manual Series Linux Coding & Programming The essential step-by-step manual to improving your Linux coding skills LLSMOGNIM * a Black Dog Media PRINT tT i FEATURED INSIDE: Navigating the Start Menu Connecting to the Internet | How to personalise Windows 11 Web browsing with Edge Using OneDrive Cloud Storage Pie Video chatting with Skype a A Email, Social Media & Messaging EMMIS reang windows tse Taper | ea Wi-fi and Personal wi-fi hotspots sta rom gainrew sis and Speeding up your computer Poetrand es Troubleshooting & User Advice and much more... ” Getto grips with ‘all the essential core features, apps ‘and functionality Click the link to BUY NOW from AMAZON ~~ Available in all good bookshops eg BOM: 's Complete Manual Series Linux Coding & Programming ea aT eee ee Te ae SM RUC RIS ee eee eae ey operating system for the fastest supercomputers in the world and it’s Pee SCN Rus ue nae tenet Cele lightning fast and completely free of charge. DORMS EWS Nc Rony operating system. Its unique configuration allows the user to customise Pore ukemi CAC Ace Meee ee change their OS look and feel from one day to the next, install Renu eRe Meee seus Cue Rc eee Maier cs Pa So uC RU Rene eee Oa ont aie eM co none Ruma Om geet an Oe meu a ht coe) Prete Roun R Cu ok eae Se h oke macMet Oe mun Mr ese MOS eR enone meek kgs uke at ae Linux users. The tutorials within these pages will help you get to grips ea OMS ole akon irene ee lnees MU MCR MCA e ea oui ee ORC Melisa) felon ae ePrice ot Contents wy Using the Terminal eC a ace Install Apps via the Terminal - Part 1 eesti amar eae CNet ae meee eee Ca En cua asco a SCR Dunc Rea eee ne CNet gee cE) eerie eat eeaa) Cre eee) eget See) CCTs eres aon Pens eee a ay creat ree Peru ETc enna ce Fee eae lae Fe eee a Fee ead eee See See a Se Se 2a Sie eee Cen ea CoE er reer eke egal ese al oles SMC eget ns (RARER USPS TERE ecco eee edged Gethin ec ate CO) @ERnER een DN tac mere Cae em ao ry Ee Mt ere Cae Mme uu eyes each eter cee SC et eee ceed Genes Sn eens ses rd cr een komen 124 SCM Tee ard eat re) ET eer Lats 130 Crecente lees) cerd Tr Minuet cry Sent qe omeeester cer cc ccc rd Mm cene cory Black Dog i-Tech Series (Linux) Seer cu) Bareterentae rus Ce CeM se Pret acan ats Ver emus Nar Pees? Bana fora Vesa PEt acme ees ‘Common Coding Mistakes coor Say Hello to Linux “How did you know so much about computers?” “| didn’t, it was the first one.” a Say Hello to Linux Why Linux? What is it? Where do I get it? Why are there so many different versions of it? Most beginners ask these, and many more, questions when starting out. It’s true that Linux is an incredibly versatile and powerful operating system but where do you start? Thankfully, you can find the answers in this section. There is so much you can do with Linux but you need to know where to start; we're here to help you out. In this section you can learn what Linux is, what a distro is and what a desktop environment i You can also begin to explore how Linux works and how it can work for you. Why Linux? BED se retototinx ) Why Linux? For many of its users, Linux means freedom. Freedom from the walled garden Serene aria cuem ies Kner e loser cr Entire ion Mee Relea eNO Kaeo TO AED) you may think though. FREE AND OPEN Linux isa fantastic fit for those who want something different. The efficiency of the system, the availability of applications and stability are just a Few good reasons. ‘The first thing you need to know i thatthereis no such operating system called Linux. Linux isin act the operating system kernel, the core component of an OS. When talking about Linux what we, and others, are referring to are one of the many distributions, or distros, that use the Linux kernel. No doubt you've heard of atleast one of the current popular distros: Ubuntu, Linux Mint, Fedora, openSUSE, Debian, Raspbian, thelist goes on, Each one of these distros offer something alittle different forthe user. While each has the Linux kemel atits core, they provide the user with a different looking desktop environment, different preloaded applications, different ‘ways in which to update the system and get more apps installed and a slightly different look and feel throughout the entire system, However, at the centre lies Linux, whichis why we say Linux. Linux is a great operating system on which to start coding, peain~ Linux works considerably ciferently to Windows or macO'. It's free Fora tart: Free to download, Free to install on as many computers as you lke, free to use for an unlimited amount of time and free to Upgrade and extend with, equally, free programs and applications. This Free co use element is one of the biggest draws for the developer, While a Windows license can cost upto £100, and a Mac considerably more, a user, be they a developer, gamer or someone who wantsto put an older computer to use, can quickly download a distro and get to work in a matter of minutes. Alongside the free to use aspect comes a evel of freedom to customise and mould the system to your own uses. Each of the available distros available on the Internet havea certain ‘spin, ‘There are thousands of free packages available for programmers under Linux. in that some offer increased security, 3 fancy looking desktop, a gaming specific spin, or something drected toward students. ‘This extensibility makes Linux a more desirable platform to use, {as you can quickly mould the system into a development base, ineluding many different kinds of IDEs forthe kes of Python, web development, C+, Java and so an; or create a base for online ‘anonymity, perhapsas a Minecraft server, media centre and much more, ‘Another remarkable advantage for those looking to learn how toccode, is that Linux comes with most ofthe popular coding environments built in. Both Python and C++ are preinstalled in a high percentage of Linux distros available, which means you can, startto program almost as soon as you instal the system and boot ft up for the first time, Generally speaking, Linux doesn’t take up as many system resources: ‘as Windows or macOS; by system resources we mean memory, hard drive space and CPU load, The Linux code has been streamlined and i free From third-party bloatware’ which hogs those systems resources, A more efficient system of course means more available resources forthe coding and testing environment and the programs Yyou eventually create. Less use of resources also means you can | Use Linux on alder hardware that would normally struggle or even = 8 = — Ch Mandriva etackraze a Wer ach distro offers something unique to the user but all have Linux atthe core, (© debian refuse torun the latest versions of Windows or macOS; so rather than throwing away an old computer it can be reused with a Linux distro. It'snotall about C++, Python or any of the other more popular programming languages though. Using the command line of Linux, also called the Terminal, you'e able to create Shell scripts, \which are programs that are designed to run from the command line and made up oF scripting languages. They are used mainly to automate tasks or offer the user some Form of input and output For a certain operation Finally although there are many more advantages we can list, there are thousands and thousands of free programs and apps avalable that cover nearty every aspect of computing. Known as packages, there are (at the time of writing) over 8,700 specific programming applications just on Linux Mint alone and an incredible 62,000+ ‘overall packages catering for everythina from Amateur Radio to WwWtools. Linux then, isa great resource and environment for programming in. t's perfectly suited For developers andis continually improving and evolving. I you're serious about getting into coding, or you just want to try something new, give Linux a try and see how it works, Foryou. ‘A.Lnux programming environment can be as simple or as complex as you need itto be. ——_> A Say Hello to Linux ) The Best Linux Distributions BUNCE d eX (Leola Nel Lae) ER Pa eee CooL) different ethos and approach. Here are five great distributions to try and where you can get them. GOING LINUX ‘The installation process for most distributions is similar. You download a disk image from the website and burn it to an optical disk or create a USB Flash Drive installer. Just be careful to get the right distribution for your hardware and read the instructions carefully. Nae By far the most popular Linux distro distribution) is Linux Mint. Mint began life back in 2008, as an alternative to the then most popular distro, Ubuntu, Although based on Ubuntu's Long Term ‘Support bul, Linux Mint tooka different direction and offered the user a better overall experience. Linux Mint has three main desktop versions avalabe with each new version of the core OS it releases. This may sound ‘confusing at fist but i's quite simple. Currently, Linux Mint Uses the Cinnamon Desktop Environment as ts flagship model; there's MATE and xfce models available too. CGinnamonis a graphically rich desktop environment, MATE uses lessfancy graphics, and is more stable ona wider variety oF desktop systems, and Xfce isan extremely streamlined desktop ‘environment thats built for speed and ultimate stability, Throughout this tie wellbe using the Cinnamon version; however, you can try out any ofthe other desktop environments ‘as you wish, In Fact, its recommended that you do spend some time trying different environments, and even different distros, tosee which suits you and your computer best ‘wwwilinuxmint:com TONLE} The second most popular distro available is Ubuntu, which isanancient African word meaning humanity to others Ubuntu’s popularity has Fluctuated over it Fourteen year life, Atone tine, it was easy the most used Linux-based operating system n the world but some wrong choices along the way vith regards to ts presentation, and some unfavourable, controversial elements involving privacy sadly sav topple From the number one spot. That said, Ubuntu has since made amends and is slowing crawling its way back up the Linux leader board. The latest versions of the OS use the GNOME 3 desktop environment, an Impressive environment, although it can bea little confusing for Former Windows users and isa litle heavy on system resources, especially Fyou'e planning on installing it on an colder computer. Ubuntu, For allits Faults, is a good Linux cistroto start experimenting with. sa clean interface, easy to use and install and offers the user a complete Linux experience ‘wwwubuntu.com £ Arch is one of longest running Linux Archisa distro for when you're more distributions and forms the basis of experienced with Linux. You start with many other versions of Linux. Why install rothing but the commandline and from Mint or Ubuntu when you can install ‘Acch? Many users do exactly that but it's not ideal for beginners. Ubuntu and Mint both offer an easier installation path and come with software packages to help there you have to manually partition your hard drive, set where the installation Files go, create a user, set the OS locale and Finally installa desktop environment along with the apps you want. you get started. The advantage though, for allthis hard E arch on the atherhand,isa more work isadistro that you have created. This hare bones’ affair. Ach is committed to Free software and ‘means your Arch distro won't comewithall the unnecescaryflesand Its repositories contain over 50,000 apps to install, including apps that others have preinstalled: its custornmade foryou,byyou. multiple diferent Desktop environments, and use as you would with any other distro. wwwarchlinuxorg Nahar 'No doubt you've heard ofthe Raspberry PL. l’shard not to have, asthis remarkable, tiny computer has taken the technology world by storm forthe last sixyears since it was introduced There are several aspects to the Raspberry Pithat makeit such asought after piece ofthe computing world For one its cheap, costing around €25 for whats essentially a Fully ‘working computer. I's smal, measuring nat much bigger than a creditcard. You can build electrons witht using a Fully programmable interface; andit comes with Raspbian, ts own custom» made, Debian based operating system that includes an office suite alongside mary different programming languages and educational resource RRaspbian fs exclusive to the Pi hardware, since the Raspberry Puses an ARM processor to power it. However, the Raspberry Foundation has since released a PC version of Raspbian: Raspberry Pi Desktop. Most Linux cstributions fall into two camps. There are ones, with the latest Features and technology lke Ubuntu a Mint and those with Few new Features but rack solid reliability, Uke Debian, Just lke the Pi version, Raspberry Pi Desktop comes with the allthe coding, educational and other apps you will ever nee It's quick stable and works superbly. Ifyou‘ interested in stretching your Linux experience, then this s certainly one of the top distros to consider. Meanwhile, openSUSE attempts to cover bath bases ‘OpenSUSE Leap isthe rock solid system. I's developed openly bya community along with SUSE employees, who develop ‘anenterpriselevel operating system, SUSE; this powers the London Stock Exchange amongst other things. is designed for mission critical environments where ‘there is na scope for instability. you find all that too sensible, openSUSE “Tumbleweed isa roling release with al the latest Features, and the occasional crash. wwwwraspberrypi.org/downloads/raspberry-pi-desktop | openSUSE isa hight respected Linux distribution and many ofits core contributors work onthe Linux Kernel ibreOffice, ‘Gnome and other key Linux areas. In short, openSUSE is where youllfind the pras hanging out. wwwopenSUSEorg sciences _ A Say Hello to Linux ) Equipment You Will Need The system requirements For successfully installing Linux Mint on to a PC are EUs ersiare] Wa oMSoR WUE Reel 101-1 Oi eeS 0-1-1612) OR Un] ey VARS aro However, it’s worth checking you have everything in place before proceeding. MINTY INGREDIENTS. Before we start working our way through this book, here's what you need to install and run Linux Mint. You have several ‘choices available, so take your time and see which works best for you. SYSTEM REQUIREMENTS ‘The minimum system requitements for Linux Mint are asfollows USB INSTALLATION You can install Linux Mint onto your computer via USB or OVD. We look into each alittle later on but If you're already familar \with the process, or thinking of USB and just gathering the hardware youneed, then you're going to 2 need a minimum 4G8 USB Rash drive to store the Linux Mint SO. cPU-700MH2 RAM/Memory ~512MB Hard Drive space - 9GB (20GB recommended) isplay - 1024 x 768 resolution (Obviously the better the system you have, the better the } experience will be and quicker too. DVD INSTALLATION 2 DVD installation of Linux Mint simply requires a blank DuD-R disc. OF course, you also need an optical, drive (a DVD Writer drive) before you're ableto transfer or burn the SO image tothe disc ( Equipment You will Need Installation toa virtual environments a Favourite method of testing and using Linux distros. Linux Mint works exceedingly well When used ina virtual environment but mare on that later. There are many different virtual environment apps avaliable; however, VirtualBox, from Oracle, is one of the easiest to into. You can find the latest version at www.virtualbox.org. Sarvs a7 VirtualBox It goes without saying really, that an Internet connection is vital For ‘making sure that Linux Mint is up to date with the latest updates and patches, as wel asthe installation of Further software, Although you don't need an internet connection to use Linux Mint, oul miss out on a world of free software avallable forthe distro, although Linux Mint can be installed onto @ Mac, there's a school of ‘thought that recommends Mac ‘owners use a virtual environment, such as Virtualbox or Parallels; and wihy not, macOS is already a splendid operating system. I you're wanting to breathe new life into an ‘older Mac, make sure t's an intel (CPU model and not the Power PC ‘models. Beware though, i's not as pain Freeas installing onto aPC. wen bdmpubliations.com “wy Say Hello to Linux Desktop Environments WHICH MINT? ‘A Desktop Environment is the graphical interface which you use to interact with the core Linux system. Just as the graphical desktop for Windows 10 is also called Fluent Design, Linux Mint offers the user 2 choice of versions ofthe distro: Cinnamon, MATE and Xfce. While that may sound alittle confusing forthe newcomer, essentially each of the versions available contains the same core Linux structure and kernel, the kernel s the core oF the operating system, that handles all the instructions between the software and hardware ach version's simply a diferent desitop environment, the Graphical User incerFace (CU!) that you use to interact withthe ‘operating system, Each of the desktop environments uses different apps to access or use the system, such as the Fle manager to browse the operating system's file structure or the way t launches other ‘Again though, the core available productivity, video and graphic suites are the same, and Functionin the samme way, wera bdmpubiations.com \Why bother then with a different desktop environment? Simply pu, its down to personal taste. Some users prefer MATE, as MATE sa Fork of the classic GNOME 2 environment and salittle more menu-centric and performs well on older computers. Others prefer Cinnamon, which isa more modem environment that works better an recent hardware and features some cutting edge desktop code. Xfce, on the other hand, isa lightweight desktop environment that works well on older hardware due to is extremely low use ofthe avaliable system resources, In short, Cinnamon i the Flagship desktop environment for Linux Mint. MATE is more compatible with a wider variety of hardware. Where Windows, For example, only offers ane desktop environment towork in, Linux offers many. Linux Mint has therefore opted to bring the user a wealth of choice. DesktopEnvironments BEST MATE MATE sa simple to use and intuitive DE that's Fast and stable. In comparison to Cinnamon it looks a little antiquated but that's only on the surface. There's plenty to like with MATE. FAB FEATURE 1 MATE isan excellent desktop environment For older computers. It ‘works better with a larger numberof hardware components that Cinnamon generally does buti also just as capable of delivering a great looking desktop as well as advanced customisation, FAB FEATURE 2 Due tots highly configurable nature, MATE can be customised to 8 fine degree. There are plenty of options avaiable to the user who demands alittle more from their desktop environment, including ings, where you're able to configure all manner oF ‘evena 3D desktop wor bdepublictions.com PY say tettoto tinux Which Distro? DISTRO HOPPING Distro hopping isa term used by the community For people who never sticctoa sinole distribution Instead, they hop from one to the othe and back agai, testing each, using them, then moving on to another oranenly released dstro, ping, ast’ @ good way to get to the elements of one distro The problem “There's nothing wrong rips with what's out there and disco ‘ver another that may or may not appealto your tastes. oF course is which one do you use overall? While distro hopping isa good thing it'snotexactly a stable way to enjoy Linuxand get the most from it We're not saying you should sick toone distro and never look elsewhere, as you would be missing alot oF great content out there, but instead we recommend you finda handful and slow progressthrough them based on your increasing Linuxstils For example, Linux Mintis an ideal starting place I's an easy to instal and use distro, hasalthe software you would normally use on a day basis already installed out-oFthe-box and gently eases you day ino the unique world of Linux and how it works and performs. Ubuntu offers much the same experience butit does thisin a sightly different way. Theres generaly less preinstalled with Ubuntu than with Linux Mint, so you would need to manual install ic yourself Another point worth considering is the sheer volume of content and help pages dedicated to Ubuntu users when using Linux. Fyou get stuck, you're never too far from a solution tothe problem ‘Moving on, as you begin to grow more confident with Linux, you may test out the kes of openSUSE, Fedora or Debian, These ae all excellent distros and each offers the userasighty different perspective on how the system runs. Same are more demanding, in terms of Linuxskils than others, but essentially they each have some valuable lessons to learn forthe user. You may find yourself moving toa particular distro because it offers something radically different from the norm, Tas Linux, for example Isa distro that’s designed purely for online anonymity t contains ccomplexand miltary grade encryption tools as wel as tools and browsers designed to help you browse the web without ever being detected, traced or monitored, Kal Linuxis designed for security fF ethical hacking ‘worabdmoubiations.com tools preinstalled, that a user can run For penetration testing against their network. There was once even a Hannah Montana Linux dlstribution but the less we tak about thatthe better, The point being, there's adstro out therefor you. Needless to say, once you've mastered Linuxtoa relatively high degree, probably a power user ability, then you will want to expand your skis and begin to build your own Linux distro based on Arch, Debian or one ofthe many other cistros available. Doing so involves a lot of command line knowledge, as well as knowledge on how the Linux system works and interacts withthe hardware in the computer. You wil need to partition your own hard rive, installa desktop environment and eventually install the apps and programs you want. Doing $0 takes timeand again there are a lot of skis youre going toneed to learn, Eventually you can consider yourself technical Linux user but never consider yourself an expert after all we're always learning something new. You can bull your own distr From scratch, help ather Linux Users out with problems, maybe even contribute to the improvement of distro during itstesting phase or build, Where next then? (Oddly enough, mast higher-end technical users find themselves, back at square one, using a istro lke Linux Mint. The main reason is Usually because i's an easy option, andit’s a stable environment Just because you know the system inside and out, doesn’t mean you always want to be fixing potential isues. Most of us would prefer the easy life, especially where technology is concemed, so, the logical choice would be to choose a distro that's simple, yet stil powerful enough to do everything you want ta do, hence Linux Mint. However, in the end, t's purely down to choice, your own personal choice. You may Find that after going through the tutorials in thistle you don't ke Linux Mint orthe Cinnamon desktop. Fine, yournay prefer Ubuntu, Debian or openSUSE: that's the beauty of Linux. The Freedom to change what you want, to distro hop From one to another without being penalised by cst or ack of access. The answerto the question, which distro is any which one you lke! canbeas complexor easy as you needittobe, aslongasit does what youwantitto do, then Ws perfect. scbdribianinn Ind Getting Started with Linux Getting Started with Linux om It’sall fine and well talking about how good Linux is but how do you get it on your computer? Installing Linuxis remarkably simple but there are several options available to you. This section looks into how you can download the Linux ISO, install it on a PC as your main operating system and even how to install a virtual environment. With a virtual environment you can run Linux while still using your main operating system, be that Windows or macOS. Intrigued? Read on and find out more. 20 Creating Linux installer on Windows 22 Installing Linux on a PC 24 Installing a Virtual Environment 26 _ Installing Linux in a Virtual Environment oo Ey Getting Started with Linux) Creating a Linux Installer on Windows You need to transfer the downloaded Linux ISO to either a DVD or a USB key before being able to install it onto a computer. This will be a live environment, which allows you to test the OS prior to installation, but first you need to create the bootable media. DVD BOOTABLE MEDIA We're using a Windows 10 PC here to transfer the ISO to a DVD. process is extremely easy. IF you're using a version of Windows from 7 onward the Fist locate the ISO image of Linux you've already downloaded, You can usually find tin the Downloads folder in windows 7, 8.1 and 10 computers, unless you speafied a different location when saving it I Quick access | iuamint18.1-cinnamen-Sit ‘3 Dropbox (eam BOM) & Onedrive [a thisPc © co rve Hite oo Network ESTe ER Next insert a recordable DVD disc into your computer's optical drive. After a few seconds, while the disc sread, Windows displays a pop-up message asking you ‘what to do with the newly inserted disc ignore this as we're going touse the builtin image buming Function, Drive (€) PRPISED) Richt-clck the Linux SO and from the menu select Burn Disc image. Depending on the speed of the PC, Itmay take a few seconds before anything happens. Don't worry too ‘much, unless i takes more than a minute, in which case it might be worth restarting your PC and trying again, With luck, the Windows Disc Image Burner should launch, |-cinnamon-64bit Mount Bum disc image [Ed Scan with Windows Defender. 2 Share Open with BD Open wth Winkar B Add to archive. Fee With the windows Disc image Bummer dialogue box ‘open, click on the Verify disc after burning’ tick box, then the Burn button. The process should take a Few minutes, degending on the speed of your PC's optical drive. Once it's complete it runs thraugh the verification stage and when done the optical crive should auto-sject the disc for you. x © Windows Dise Image Burner Dice image file: _linusmint-19.1-cinnamon-64bitico Disc bumer: BO-ROM Drive (0) Status Burning disc image to recordable disc. Creating a Linux Installer on Windows Gm USB BOOTABLE MEDIA USB media is Faster than a DVD and often more convenient, as most modern PCs don't have an optical drive installed. The process of transferring the image is easy but you need a third-party app First and a USB flash drive of 4GB or more. PEPE Fistopen Fame EIR when you're ready, cick onthe Start button at the upawed “Sve properties bottom ofthe Rufus app. This may open up anther browserand goto www, ar dialogue box asking you to download and use a new version of fufusakeose/. Scroll Someone © Sysinux.SysLinuxis a selection of boot loaders, used to allow a own the pagealitle and TST main vo pay MOdEINPCtO acess and boot froma USB flash drive, tis necessary, youcome toa Downioad — ponssoun ras soi asked clickon Yes'to continue heading, underwhich bo 2: ii isthe latest version of A RE omar sean Rufus. Left click the link to incor the taation es er Sm 03 2041008 ronmat Options statthe download sane vena wt vet opt one ete snd pelrtrererhimreeriirentepier end Tantessticadeen cca (ameca’ ce tener Seca cinerea Note Te fle wt be downendes inte caret apcstonSectony ndwilbe rete automa # present. ite We wo BEE Oodle Fcino = BRFBBIER) the nent step asks which image mode you want click the Linux 50 to be written to the USB flash drive Drive Properties thedownlondedfutes iBth methods wor ferent slo but gentle a = _recanmandstso age ode the move populates tis tothewindowssecurity Sm ao op muey) Models preselected and click OK to continue, Followed by OK again ‘questionand esto. Suse mic to confirm the action, Seliaior noes i a. ‘With Rufus launched Shon aha ee pees | 4 Eoucov stat), moni | nemgorrgr nana oi nanan oe ae Portree coats late UseAeive Ft jt eee en wen sic SECTS sea nemirigniin — Socs pa ctennntymuiciomninianige = (rach? epee orm ees aa Snmcnoomaeneae —_ | a fet ane the Rfsiterce aoa le Theta Pu a config bude worsen ce see Son Tobesinwith clcontheseiicrbutan et tobe Dsker6O —anferedtotheUsD Steen : Image (Please select) pull-down menu. This launches Windows flashdrive. The process ents ae Cobrervindowehereyoucmioatcanisccctheunns0, — sheliitaketwiong, iam eo Pasa Sates, speed of the USB device : = = and the PC. You may ind Rufusauto-opensthe use Format Options “drive in windows Explorer [Sxrner cama) during the process; don't) sevse ene ‘worry youcan minimise or . =e close itif you want: When the processis complete, Status click on the Close button. a0 ooze (ae | aa a ne Getting Started with Linux nN Installing Linux on a PC UEFI BIOS ‘The Unified Extensible Firmware Interface (UEF) is used to identify hardware and protect a PC during its boot-up process. It replaces the traditional BIOS but can cause issues when installing Linux. insert your DVD or USB flash drive into your PC and SAD 1 havent avedy, shutdown windows a this instance we're using the USB boot media but the process i vitally Identical. Star the PC and when prompted press the appropriate keysto enter the BIOS or SETUP, which could For example be:F2 Delos even F12, looking for isa section that details the Boot Sequence or Boot Mode. Here you have the option to turn off UEFI and choose Legacy or disable Secure Booting, Most distros work with UEFi but it can be a tricky process to enable ieto boot wera bdmpubiations.com FETED there are different versions ofa UEFI BIOS, so covering them all would be impossible. What you're With UEFI turned to Legacy mode, there are now BL oy toting nto the Live Emirorment The firsts via the BIS you're already in. Locate the Boot Sequence and change the first boot device fram its original setting, usually Internal HDD or similar, to: USB Storage Device forthe US media option, or DVD Drive for the DVD media option. eee eT Pree et Pe on aT ri FETS “teratively use the Boot Option Menus With this ‘option you can press F12 (or something similar) display list of bot media options; From there, you can choose the appropriate boat media. Either way, you can now Save and Exit the BIOS by navigating to the Save & Exit option and choosing ‘Save Changes and exie ‘Mesa betces otork Sot trom aH ZO #2 ater Setup? INSTALLING LINUX Once the Live Environment has booted, you see the option to install the distro to your computer. Have 2 look around and when you're ready, look For the Install option on the desktop. FERED ®'oviding you're connected to the internet (F not, then do so now) and you're inthe Live Environment, start the installation process by double-clicking on the install Linux Mint icon on the desktop. Other distros display their own name, of course, butthe processisthe same. Click Continue when you're ready, Whe the instalation process very srr across suse ‘most Linux distros, some offer different questions. daring the instalation. Generaly the qvestonsaert too dict, nothing very tecical but some sucha stalin thd party {oftware.,canbeconfsng ths case you can clk Conthue but you're unsure have aninernetconneced deuce avalable to ak any questions FETIP efore the installation process begins, you're asked ifthe choice you made regarding the erasure of the hard drive is correct. Thisis your last chance to back out. IFyou're certain you don’t mind wiping everything and starting again with Linux Mint, click Continue. Ifyou need to backup your files remove the Linux diso/USB, reboot, backup and tart again, FETS) Eventually you are asked to set up your Linux Username and password. Enter your Name to begin with, then the Computer Name, which isthe name its identified ‘on the network as. Next choose a Username, followed by a good Password, You can tick the Login Automatically option but leave the Encrypt Home Folder option for now. PETS The installation process can be quick, and there may be more questions to answer, or it may simply start instaling Linux based on your previous answers. Either way, you tend up being asked to Continue Testing the Live Environment or Restarting to use the newly installed 0S. Fyou're ready to use Linux, then click Restart Now. a; FP cetting started with Linux Installing a Virtual Environment GOING VIRTUAL Using a Virtual Machine (VM) takes resources from your computer: memory, hard drive space, processor usage and so on, Make sure you have enough of each before commencing FOTERE DD We're using VirtualBox in this instance, as t's one of ESTEE D) With the correct packages downloaded, and before the easiest virtual environments to get to grips with, 9 you install anything, you need to make sure that the Enter www.vttualbox.org and cick on ‘Download VirtualBax..This computer you're using is able to host a VM. To do this, reboot the takes you to the main download page, Locate the correct host for computer and enter the 8105. When the computer stars up, press your system: Windows or Mac, the Host being the current installed operating system, and clckthe lnk to besin the download the Del, F2 or whichever key is necessary to Enter Setup. g VirtualBox re) 0. : aa ‘Next, while stil at the VirtualBox download page, Each BIOS is laid out differently and t's very difficult locate the VirtualBox Extension Pack link, The to.assess where to look in each personal example. Extension Pack supports USB devices as wellas numerous other However, asa general rule of thumb, you're looking For Intel extras that can help make the VM environment amore accurate Virtualisation Techn emulation ofa ‘reat’ computer. logy or simply Virtualisation, Found usually within the Advanced section ofthe BIOS. When you've lacated it, Save, then File > Quit, Reboot Linux Mint and you should notice sight hike in performance. BEER ERD Securty is always concern in this moder digital While Linux Mintisa secure system, it's advisable to always try and improve it, Click the Menu button and search for Firewal; click the Firewall Configuration icon and enter ‘your password. In the Firewall window, click the Status slider to On, wor bdepublictions.com ZW Getting to Know Linux os _| Apollo 11 [010 You know... JAxaMano eT esa asm mankind first stepped on the moon, The Pana eee Ria ee eee nat ators at the time and had to be developed eer nia storing programs called Rope Memory, Seca acer ane P Laboratory populated the memory with a Beers eee NA eee Le ee POU neces) em Ra ee Ese aT Rene eeu Perce at ieee a such as Burn_Baby_Bumn, in particular line Se cou ake Rec Perea Rae Ca erate - Ss Programmers arentwithowt Seewhatelsets inthere. r One giant leap For \ mankind, and coding. Em Getting to Know Linux.) Creating Users TSN oleae: OMA alae Leorn ielO kre cong NLR AUR AUT STURM ae-lecot aa eee Me Reo ERR ole) tote Reagan R Oneal) (Oe NEW USERS Having different users means each user has access to his or hers own areas on the system. Documents, pictures, videos and so on are separate, as with multiple users on other operating systems. Click on the Linux Mint Menu and type ‘users to begin searching for the relevant console, From the search results, choose Users and Groups and enter your password. “The Users and Groups consoleis quite basic looking, and thankfully ‘easy to use. At first, you can just see your own username From when {yu installed Linux Mint. Toadd anew user, click the Add button atthe bottom ofthe console. There are two types of User you can create, Standard and Administrator. Unless the new ‘ser has need to install new apps or access parts ofthe file system beyond their Home Folder, then opt For the Standard account type. Otherwise, use the Administrator account type. ae EE rs snesiczcccon Enter the new user's Full Name, followed by the Username they need when logging into Linux Mint, ‘Make sure the usemame is all in lower case, -z and 0-8 characters only. You can have ful stops, underscores or hyphensif you wish. Click the Add button when you're ready to continue nr to “The new user appears in the list of current Linux Mint users, In alphabetical order. At present, there's no password set so click the user inthe list of current users, then lick the No Password Set option under the user's username. eee You can now entera password for the new user Cr click the curled arrow at the end of the New Password text box to generate a password for you, as well as displaying it. Naturally, t's a good idea to come up with as strang a password as possible. When you're done, click the Change button. C Once logged in the new user fs required to set up Suan their own desktop wallpaper, icons, Panel, Menu and so on, Depending on what Account Type you set up for them, Standard or Administrator, they won't be able to install any new apps. This screenshot is from a Standard user account type. SUE now, as the new user has been created. If you click the Mint Menu, Followed by Logout, you are presented with the Mint Login Manager. The new users now present inthe list of ‘currently available users. lick on hinyher to log them in, COMMAND LINE ACCOUNTS ee ea eos rey eee eters “The process for addin command line relatively simple, To begin with STEP 1 (MfJecdo adduser \it7¢ausernane>| rere een ice eter ig ‘password for the user, along with theic Fullname and other detall Clicky to confirm the details and create the user account. You can close the Users and Groups console window Youcan rate asmary new accounts a you Sua need and you're able to switch between them when required, 'sbestohave stone account thats capble of isang new ower, that way yu can keep ack o hat son your system Session Log out ofthis system now? Switch User Reem ee Ree, ‘You can check the details and account type For piEne Cn menue een eu s enter: STAN MERRCTETaTTASin the Terminal or dick the Peete reel a; Em Getting to Know Linux. ) Customising the Desktop (ate ar ele cece Ta Clare ee) PLEA US eR re Natl Lee MeoM aT OR VeLU ROLL AMIS Melt Rem -r eU Aan) company logo. Whatever your reasons for having your own desktop, here’s how it’s done. YOUR DESKTOP. Linux is probably one of the customisable operating systems ther some imai you can create something incredible. is. With just a Few tweaks, one or two extras installed and Thefetaoe.f ton ctomiatin sto TEER) Yount met he mabe om ay out change the wallpaper. Right-click the desktop and Suse) of the locations provided to have them install as the choose Change Destap Background Thisopes the Backgrounds desitopwallpaper nddertaly, you havmagestoredn anther ‘app in Linux Mint; remember, other distros may present their location on your system or network, you can add them by clicking on background walpaper selection toe erent, the Plesymbolat he botom of the Sacground corso ung thefe manage oat em, PEPER) Morerecent versions of Linux Mint display available PYAR sy clicking on the Settings tab you can, instead, backgrounds depending on the version the users play numerous images as a sideshow or change the running, You normally get three categories followed by afourth, _aspect of the walpapers toa variety of choices Pictures, which is separated From the others. The Pictures option isdifferent because treads the image content From the Pictures Folder in your Home area (_ Customising the Desktop om STEP 5 1 ofthe available wallpapers take your FERED themes allows you to change the way certain Fancy, open a browser and search forthe type of aspects ofthe Mint desktop look Window background image you prefer. When you've found the image you Borders, icons, Controls, Mouse Pointer and Desktop. Inthe ‘want asthe desktop wallpaper, ight-lckit and choose Set As Settings tab you can extend the options with afew on/oftslider Desktop Background from the lst of options. When the Set Desktop buttons, to. Background console open, click the Set Desktop Background button. FETED Test2. txt: This wil create the Fle Test2.txt and put the Terminal into an editing mode. eavidedavi Fle Edt View Search Terminal Help PEP Youll notice that the cursors Flashing below the cat > Test2.txt command, without the usual prompt. This editing mode will allow you enter the text thatthe file ‘ill contain, Enter some text, then press Ctrl+D to exit and write the contentsto the file BERRA OF course you don't always have to use the Terminal to-enter textintoafile, Mint comes with a text editor called Xed, which s similar to Windows’ Notepad. To view the previously created file in Xed, type into the Terminal: xed Test2. ‘ext, and press Enter. Creating a File Using the Terminal Xed is a GUI app, and you can enter text and save the ile, or any ile, accordingly by using the apo's ‘main window, and the File > Save, or File > Save As Functions From itstop menu bar options woejas 2 ee le richie Ere however, you prefer to remain working in the Terminal to edit/save/create files, you can use Nano. Nano isa simple Terminal-based text editor. To tryit with the example, enter:nano Test2. txt. There'sa menu along the bottom of the screen. To ext and save any content in Nano, press CCrlex and follow the on-screen instructions PEPE Wic've used the Terminal to launch Mint app, ed, but any app can be launched from within the Terminal. For example, try: Firefox, and press Enter. Close Firefox to return to the Terminal, Providing you know the name of the app, itcanrun from the Terminal, Additionally, entering fireFox& opens Firefox, AND lets you still use the Terminal wen bdmpubliations.com 57 ane LY) using the Terminal) Creating and Removing Directories As with creating files in the Terminal, you can also create and delete directories, or folders if you prefer. Directories form the structure of your File system, without logical directories the filing system would be in utter chaos. MANAGING FOLDERS Learning how to create and delete Folders in the Terminal is an important Mint, and indeed Linux overall, skill to master. Here's the basics for you to try out BSTSEDD withthe Terminal open enter ed ~ tormake sure ESTED {you were to enter the command again, mkdir Yyou'e in your own Home directory. Now enter ls testdir, youll recelve a message stating: mkdir: toview the current folders you have housed in the Home drectory. cannot create directory ‘testdir’: File exists.lt ‘You't notice that folders are labelled in Mintin cyan (light blue). {goes without saying then, that you're only able to have one uniquely Let's start by creating anew directory. Enter: mkdir testdir. named directory within the current directory. However, as Linux's case-sensitive, you can have Testdir,TestDir,testDir and so on. BED (oerceescomn outs tinenen EEE scence esestindeeresyaie SPacncyanc tarinke cialis ‘isn cin For tora ae other dretoviesinthe Home area Obvesythecmmandmkdi" dreton/thcdtestdtr/ flowed byst lt the ole rt ISwhetceaesthecrectoy. and no doubyenive aedy guessed Nataly theres nothin present. as youve jit ested the crete. islands for Make Dect. Now crop bscktsHomevithed-andentermkdirtestdir/ reports Cobacktothe testi, ed testdie/ ond sagan 5B) wonbdmoublcationscom PETER) The command to create directories s quite logical, therefore. Youll create the directory, and any sub- directories within, However, what if you want to create e directory ‘and a sub-directory ina single command? Make sure you're at Home (cd~) and entercmkdir -p Temp/finances. Now, ed Temp/, and \stolist the new directory, STEI ‘The--p option is what enables the mk commar to create the sub directory as wells the parent directory. In Linux, commands always follow the same structure: Command, Option, and Argument: Inthe previous step example, command (mkdir), option (-p, and argument (Temp/finances), File Edit View Search Terminal eso Help Pore ory str FETAE AD ‘you want to drill down into the various options ‘available For the mkdir command, you can enter Inkdir =-help into the Terminal. This will provide a quick help, guide detailing the options and how the command structure works, (_ Creating and Removing Directories PEPE Now that we've created some directories, let's see ‘about removing them. Start by entering the testdir directory and listing its contents: ed testdir/, then ls. The previously created reports sub-directory s present. One vay to remove its to enter: rmdir reports, then ts again to confirm is not there. FETs / cuick warning: removing a directory inthe Terminal doesn't place it in the Mint Rubbish Bin, via Nemo file manager. The same goes for any files, too. \Fyou remove a directory from the Terminal command then ts gone For good. REDD rir wil only remove empty directories, to remove directories containing sub-directories, o even files, yout need to use the rm command with the -R option For example, onthe Tempjfinance directories, use rm -R Temp. A.quick s reveals thatthe parent Folder and al of its contents are removed. Careful when using this command, wombdmpublestionscom (58) A LY) using the Terminal) Fun Things to do in the Terminal Despite the seriousness of an operating system, the Linux community are certainly no strangers to a bit of Fun. The developers over the years have created and inserted all manner of fun and odd elements into the Terminal. TERMINAL FUN ‘You'll be working exclusively in the Terminal for these next two sections, so start warming up your Fingers. After all, all work and no play... as the saying goes. PEPE The frst command we're going to useissh it's BRED youve ever fancied having the computer reada ‘ot installed by default so enter: sudo apt-get random fortune out to you, then you'e in Luck. Most install 1. The command canbe runwith stand when executed dstros require youto install the Fortune app, however Linux Mint will display @ Steam Locomotive travelling across the screen (hence differs somewhat by having It already pre-loaded. Allyou need to do ‘51. Entering LS, nate the upper case, also works isenter the command fortune into the Terminal, and enjoy ESTEE Fensofstarwarsevengetafixwhenit comesto ESSN, The rev commands cerainiy interesting, and at he Terminal. By inking toa remote server via the First what seems 2 quite useless addition to the telnet command, you can watch Episode IV: ANew Hope being (0S. However, it can be used to create some seemingly unbreakable played out, albeitin ASCIL To view this spectacle, enter: telnet _passwords. Enter rev, now type some text, when you press Enter towel. blinkenlights.nL next, everything you typed in will be reversed. Press CtrlaC to exit. Ce PEPID youre stuck trying to work out all the possible factors For any particular number, simply enter Factor Followed by the number. For example, factor 7 does offer much output, whereas Factor 6 displays more. There'sa fine line between the rather cool and really quite-weird, Having an ASCII cow repeat text toyou could potentially fallin the latter. Enter consay followed by any text you want, such as: consay Linux Mint is ace! In Fact, you can even output the ls command through the cow, by entering: Ls. | cowsay. Fun Things to do in the Terminal FETED you really wancto expand the whole cow thing, For whatever reason, then pipe the Fortune command throught, with: Fortune I consay; and for the ‘graphical cow equivalent: fortune | xconsay. Plus there's always cowthink Try. conthink ...This book is anesome. FERED the command toilet doesn't inspire much confidence, we'll admit. However, it's natas bad as itfirst sounds. Start by installing itwith: sudo apt-get install toi Let. Then when installed, type something along the ines of: toilet David. Or perhaps list the contents ofthe current folder Uhroughit, with: Is I toilet. FETTER) further the cow element, there's even aaraphica ie, noneTerminal, cow available. Installt with sudo apt-get install. xcowsay, then when tsinstalled enter something similar to cowsay, such as: xconsay BOM Publ ications. PERRET R) &xpanding the toilet command, you can actualy generate some decent looking graphics through it, Forexample, try this toilet =f monol2 -F metal David. You can enter toilet =-help,foralist ofthe command line arguments to expand Further wombdmpubliationscom (GH 8 LY) using the Terminal) More Fun Things to do in the Terminal IF the previous list of Fun, and quite bizarre, things to do in the Terminal has you wanting more, you're in luck. We've put together another batch of some useful, and some not so useful, commands for you to try out. MORE FUN, YAY Since the Terminal session is already open, and your keyboard digits are nicely warmed up, here are another two pages of Terminal nonsense. BRTeGEED Remember the old 2x Spectrum days of computing, ESTEEM Having aitle white cat chase your mouse pointer when you could type in 10 print “Hell”, 20 goto 10 around the desktop may sound tke a terrible waste ‘and Hello would list down the screen? Wellin Linux Mintyou cando of time. Oddly though, itis't Enter: sudo apt-get install the same. Simply enter yes followed by some text,e.yes Linux _oneko, then type oneko to have the cat appear. Move your mouse’ 15 ace. I'l keep going until you press Ctrl. cursor around the screen and the cat wil chase't, Use Ctr +C to exit the action, ERTee RD The Matrixwas one of the most graphically copied FEST This entry is alittle more serious than the previous, films ever released: there's even a version ofthe Iscalled the Fork Bomb and what it does, basically, Matrix code available For Linux Mint Installit with: sudo apt-get is continually replicate itself until it has used up al the available install cnatrix. When t's done enter: cnatrix.and follow system resources, thus causing your computer to crash. You don’t the white rabbit, Neo, Unlike the real Matrix though, you can press have tatry itbut t's interesting nonetheless. Simply enter : CL Ctrl+C to exit. £1:& }: and be prepared to reboot. Fle E6t View Search Terminal Help cress GB) wempublcationscom ( More Fun Things to do inthe Terminal @2Y FEPIED stinging several commands and piping them PPT) Used as a music demo from the old Amiga and through other commands is what makes scripting DOS days, the bb command reminds us of getting such a powerfulelement to an OS, Using the while command, for _hold of three and a hal inch Floppies crammed with all manner oF example, together with tlle, can yield some impressive results, demoscene goodies. We've already installed bb Fram the previous Enter while true; do echo “$(date ‘+XD 7” | toilet step, sojust enter bb. Follow the on-screen instructions, and turn up -f term -F border --metal)”; sleep 1; done. your volume. BERD Talking computers were the craze of the 20s, enter: PPMP this entry is in two parts. First you need to get espeak “Hello, this is Linux Mint” hold of the necessary packages: sudo apt tohave the computer repeat the text inside the quotes to you. get install Libcurses-perl. when that’s done enter: ed Make sure your volume is turned up, and try the following: 1s > Downloads/ && wget ht tp://search..cpan.org/CPAN/ folders. txt && espeak -f folders. txt. Thiswill have Mint authors/id/K/KB/KBAUCOM/Term-Anination-2.4. tar.gz read back the contents of the Is command. 88 tar -xf Term-Animation-2.4.tar.gz && cd Term Animation-2.4/. Then: perl Makefile.PL && make & make test && sudo make install View Search Terminal Hel FTEEE AD 4 co21ing ASC Fire isnt the most usefulcommand JEEP with that tittle lot done, onto the next. Enter: cd to have at your disposal, but it’s Fun. Install it with =. && wget http: //wv.robobunny .com/ sudo apt-get install libaa-bin, then when installed use projects/asciiquariun/asci iquarium.tar.gz 8& tar afr t's not exactly warming butyou get the idea. Toexpand —=xf-asciiquarium.tar.gz && cd asciiquarium1.1/ the above, enter: sudo apt-get install bb caca-utils, && chmod +x asciiquarium. Providing al went well enter ./ then, cacafire, ‘asctiquarium and enjoy your very own ASCIF-based aquarium, wonbdmpublestionscom (G3 LY) using the Terminal) Linux Tips and Tricks As you've seen, the Linux Terminal is quite an exceptional environment. With a few extra apps installed, and a smidgen of command knowledge, incredible, and often quite strange, things can be accomplished. TAKING COMMAND ‘There are countless Linux tips, secrets, hacks and tricks out there, Some are very old, originating from Linux's Unix heritage, while others are recent additions to Linux lore. Here's our favourite ten tips and tricks, SIC rec steed isearestriece ot OEE fred sia stieto browse the internet From contains a hidden Easter Egg? With Emacs installed (sudo apt-get _the Terminal? while not particularly useful itis quite a fascinating Install emacs25), drop toa Terminal session and enter: thing to behold. To do so, enter: emacs -batch -1 dunnet sudo apt-get install elinks Dunnet isa text adventure written by Ron Schnell in 1982, and sti hidden in Emacs since 1994, Enter the website you want to vist. rete Patiern am 2:0 on the ciassic 1982 arcade game, PERM TSN Tem Snowing in the Terminal console isn't Moon Patrol, Moon Bugay appeared on, something you come across every dy. IF the home computers of 1985 amid much praise. I's cracking Atari _ you're interested, however, enter: game, and it's available in the Linux Terminal by entering SSUELICIeNET IETS eres sudo apt-get install moon-buagy 1505483/ran/7d024716ea57e69FbS2632FeeO9F42 — 753361c4a2/snawjob..sh cchmod 4 snawjob.sh mmoon-buggy -/snowjob.sh Enjoy. caer BA) warnbdmpublcationscom A Taelnat elecm "you need to see what apps are consuming the most memory on Linux, simply enter: Ps aux | sort -rnk 4 “This sorts the output by system memory use. toretrieve it. However, to securely and permanently delete a file, use Shred shred ~zvu NAMEOFFILE, txt. Replace NAMEOFFILE with the name ofthe file to delete, PTT when you delete afile, there's chance of someone withthe right oftware being able ( LinuxTipsand Tricks @FY PSE | 22ck in the days of diat-up connections, the online world was made up of Bulletin Board Systems, These remote servers provided hang-outs For users to chat, swap cade, play games and more, Using telnet in Linux, we can still connect to some active BBSes: telnet battlestarbbs.dyndns.org ‘There are countiess operational 88Ses avallable, check out hetps:// wurw.telnetbbsguide.com/bbs/list/detaiy, For more, Fence i vouwant tocreate an entire directory or Folder) tree witha single command, you can use: mkdir =p Nen-Dir/ {subfolder1,subfolder2,subfolder3, subfolderd} This creates a NewDirwith four sub Folders within FEIN GA AD 45.1! art can be quite striking when applied to some images. However, i's often difficult to get ust right, You can create some great ASCIlart from the images yyou have by using img2ext ‘img2txt NAMEOFIMAGEFILE .png Replace NAMEOFIMAGEFILE with the actual name of the image file on your system. IF ing2txt instal installed, use sudo apt-get install caca-utits. Ere) Crop t=Ke ASD (snot easy trying toremember all the available Linux commands. Thankfully, we can use apropos to help Us. imply seit, along with a description of the command: ‘apropos “copy files” ‘apropos “rename files” wombdmpublistionscom (G5 Vv Ee a) UO e a) x =) = 7 DID YOU KNow. that Linuxis at the heart of the cience behind the Large Hadron Collider? Using a combination of Red Hat Linux and CentOS (an ultra-stable distro built From the Red Hat core) as the bas distributions of choice, scientists, developers and engineers have created SL — Scientific Linux. Using SLas the base, the clever people at CERN have developed several different versions of their ‘own custom Linux distro to help with all aspects of the LHC. Most notables SLC, or Scientific CERN, also known as CERN6. According to reports, there are stems running SL, a LY) using the Terminal) Creating Bash Scripts —Part 1 Eventually, as you advance with Linux Mint, you'll want to start creating your own automated tasks and programs. These are essentially scripts, Bash Shell scripts to be exact, and they work in the same way as a DOS Batch File does, or any other programming language. GET SCRIPTING ABash script is simply a series of commands that Mint will run through to complete a certain task. They can be simple or remarkably complex, it all depends on the situation, FOTESE DD You'llbe working within the Terminal and with a text editor throughout the coming pages. There are alternatives to the text editor, which well look atin a moment but forthe sake of ease, we'll be doing our examples in Xed. Before you begin, however, run through the customary update check: Sudo apt-get update && sudo apt-get upgrade. File_E8t_ View Search Terminal Help ‘There are several text editors we can use to create ‘Bash script: Xed, Vi, Nano, Vim, GNU Emacs and so on.In the end itall comes down to personal preference, Our use of xed is purely due to making it easier to read the script in the screenshots you see below. FETED To besin with, and before you startto write any Scripts, you need to create a folder where you can pputall our scripts into, Start with mkdir. scripts, and enterthe folder cd_scripts/. This will be our working folder and from here ‘you can create sub-foldersif you want ofeach script you create, FED Windows users will be aware that in order fora batch file to work, asin be executed and follow the programming withinit, it needs to have 2 BAT file extension. Linux isanextensioness operating systern but the convention isto give scripts ash extension, Co Let's start witha simple script to output something tothe Terminal. Enter xed helLoworlLd. sh. ‘This wil launch Xed and create aie called helloworld sh In ed, enter the following: #1/bin/bash, then on anew line: echo Hello World! Fe ft View Search Terminal Help Fle Edt View Search Too Documents. Hebe Abalns xoo ag o1binybash echo Het to word! FERED The #!/bin/bosh line tells the system what Shell you're going tobe using, inthis case Bash. The hash (8) denotes a comment line, one that is ignored by the system, the exclamation mark () means thatthe comment is bypassed and will Force the script to execute the line asa command, Thsisalso known, ‘asa Hash-Bang, Fle Et View Search Toots Oocuments. Help Poaje~ xeon ag 1 /sin/ash echo Hetto world! You can save this ile, clicking File > Save, and exit back to the Terminal. Entering 1, will reveal the script inthe Folder. To make any script executable, and able to Tun, you need to modify its permissions. Do thiswith chmod +x helLoworld. sh. You need to do this with every scrit you create, Fle Et View Search Terminal Hep (Creating Bash Scripts— Part 1 oy FERED when you enters again, you can see that helloworld.sh srint has now turned from being ‘white to green, meaning that’s now an executable fil. Torun the script, in ather wards make it do the things you've typed into enter: ./heLLoword. sh. le Edt View Search Terminal Hep PEPED though ies notterribly exciting, the words Hello, World should now be displayed in the Terminal ‘The echo command is responsible for outputting the words after itin the Terminal, as we move on you can make the echo command output to othersources. Fle Edt View Search Tose Documents Help Doajn+|/xyeonjaa fm etiersh bin/bash FETED DD Think of echo.as the old BASIC Print command. displays either text, numbers or any variables that are storedin the system, such as the current system date. Try this example: echo Hello World! Today is $(date +XA). The $ (date +%A) scaling the system variable that stores the curr! of the week. ————_

You might also like