100%(1)100% found this document useful (1 vote) 527 views147 pagesThe Complete Linux Manual Ed2 2019
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
i Complete
Balen
forts ;
Peeled
to improve :
ratte ills 9) ( p)Discover more of our complete
manuals on Readly today...
The Complete The Complete The Complete
owe | Ubuntull | Linux Mint
ICI Manual Manual
Y
Sapient
MW iryey:y
ve
The Complete
Building Your
Own PC
Manual
(a droid The Complete An ao
fe} ress
ncrol Google Manual
Manual Manwal
yy ‘The Complete
Outdoor
Photography
Manual
it a
iF pe
Layer)
Velale rel(Wf Black Dog i-Tech Series
“That's what makes Linux so good: you put in
something and that effort multiplies. It’s a positive
Feedback cycle.”
Linus Torvalds (developer of the Linux kernel)
Linux is everywhere. It powers the Internet as the main operating
system behind the Web's servers, it powers spacecraft, it's the
operating system for the fastest supercomputers in the world
and it’s used in smart TVs and mobile devices. Why? Because it’s
ultra stable, lightning fast and completely free of charge.
However, there’s more to Linux than simply being a free to use
operating system. Its unique configuration allows the user to
customise and personalise the OS into any form they wish. A
Linux user can change their OS look and feel from one day to
the next, install thousands of freely available apps and programs.
and take back control of their computer.
Linux is about freedom. Freedom from the walled-garden
approach of other restrictive operating systems, freedom to
choose what you want on your computer, freedom to alter it
and use it how you please. It’s a worldwide community of like-
minded users, all striving to get the best development from this
incredible OS.
With this book, you too can becomea part of the open community
of Linux users. The tutorials within these pages will help you get
to grips with Linux, show you how it works, what you can do with
it and how you can code with it to take your Linux experience to
even greater heights.
Discover Linux. Discover freedom.
8 @bdmpubs fi BDM Publications
www.bdmpublications.comContents *
CPS
The Complete Linux Manual
8 Why Linux?
10 The Best Linux Distributions
12 Equipment You Will Need
14 Desktop Environments
16 Which Distro?
18) Getting Started with Linux
20 Creating a Linux installer on Windows
22 _ Installing Linux on a PC
24 Installing a Virtual Environment
26 Installing Linux in a Virtual Environment.
CPt aaah t)
30 Introduction to the Cinnamon Menu
32__ Navigating the Cinnamon Desktop
34 10 Things to do After Installing Linux Mint
36 _DidyouKnow...Apollo 11
38 Creating Users
40 _Customising the Desktop
42 Becoming Anonymous Online
a
46 Basics of the Terminal
48 Update Mint via the Terminal
50 _Install Apps via the Terminal - Part 1
52__Install Apps via the Terminal - Part 2
54 Did you Know...Linux Kernel 0.01
56 Creating a File Using the Terminal
58 Creating and Removing Directories
60 Fun Things to do in the Terminal
62 _ More Fun Things to do in the Terminal
64 LinuxTips and Tricks
66 Did you Know...Linux and the Big Bang
68 Creating Bash Scripts- Part 1
70 Creating Bash Scripts —Part 2
72 Creating Bash Scripts — Part 3
74 Creating Bash Scripts~Part 4
76 Creating Bash Scripts~Part 5
7B PixLinux= The Perfect Combination
80 Command Line Quick Reference
82 AZof Linux Commands
84 Did you Know...Good enough for NASA
CORT aratn
88 WhyPython?
90 Howto Set Up Python in Linux
92 Starting Python for the First Time
94 Your First Code
96 Saving and Executing Your Code
98 Executing Code from the Terminal
100. Did you Know...Space Invaders102
104
106
108
110
112
114
16
Numbers and Expressions
Using Comments
Working with Variables
User Input
Creating Functions
Conditions and Loops
Python Modules
Did you Know...Debugging
120 WhyC+4?
wn dmpublcationscom
122
124
126
128
130
132
134
136
138
140
142
144
Your First C++ Program
Structure of a C++ Program
Compile and Execute
Did you know...Virus!
Using Comments,
Variables
Data Types
Strings
C++ Maths
User interaction
Did you Know...The Hobbit
Common Coding Mistakes
ee:TY index
“How did you know’so much
about computers
Kelemen aa lol ae
~ Admiral Grace Hopper (pioneer programmer)
DM ay ee el ee
blackDop Tech Series ~2nd Etonwn bmpublcatonscom
Say Hello to Linux “vy
Why Linux? Whatis it? Where do | get it?
Why are there so many different versions
of it? Most beginners ask these, and many
more, questions when starting out. I'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 environments.
You can also begin to explore how Linux
works and how it can work For you.
8 WhyLinux?
10 The Best Linux Distributions
12 Equipment You Will Need
14 Desktop Environments
Which Distro?
ack og Tech Series 2nd EtonZz Say Hello to Linux
Why Linux?
For many of its users, Linux means Freedom.
Freedom from the walled garden
Erkan Molen ReLle(eTeR aan LOSE Roe)
Eire Kne gd Cease Kole CN eee Clee eon aT aera)
you may think though.
FREE AND OPEN
Linux is a Fantastic it For those who want something different. The efficiency of the system, the availablity of applications and
stability are ust a few good reasons.
‘The First thing you need to know is that there sno such operating
system called Linux. Linux in Fact the operating system kernel, the
ore 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 kemel. No doubt you've heard of atleast one of
the current popular distros: Ubuntu, Linux Mint, Fedora, openSUSE,
Debian, Raspbian, the lst goes on. Each one of these distros offer,
something a itle different for the 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
anda sightly different look and Feel throughout the entre system.
However, atthe centre lies Linux, which i why we say Linux
Linuxis a great operating system on which to start coding.
Linux works considerably differently to Windows or macOS. I's Free
Fora stat: Free to download, Free to install on as many computers
asyou lke, Free to use for an unlimited amount oftime and free to
upgrade and extend with, equally, Free programs and applications.
This Free to use element is one ofthe 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 wants to 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 level of freedom to
customise and mould the system to your own uses. Each ofthe
available distros avallable on the Internet havea certain spin,‘There are thousands of free packages available
for programmers under Linux.
in that some offer increased security, a Fancy looking desktop,
‘8 gaming speci spin, or something directed toward students
This extensibility makes Linuxa more desirable platform to use,
‘you can quickly mould the system into a development base,
including many different kinds of IDES forthe likes of Python, web
development, C++, Java and so on; or create a base for online
anonymity, perhaps asa Minecraft server, media centre and.
‘much more,
‘Another remarkable advantage for those looking to learn how
to.code, is that Linux comes with mst ofthe popular coding
environments builtin, Both Python and C+ are preinstalled in a
high percentage of Linux distros available, which means you can
start to pragram almost as soon as you install the system and boot it
up For the Fist 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
{andi ree from third-party ‘bloatware’ which hogs those systems.
resources. A more efficient system of course means more available
resources For the coding and testing environment and the programs
you eventually create. Less use of resources also means you can
Use Linux on older hardware that would normally struggle or even
Se
Ol Mandriva stackrsre
@ =
Each distro offers something unique to the user
butall have Linuxatthe core.
refuse to run the latest versions of Windows or macOS; so rather than
throwing away an old computer, it can be reused with a Linux distro,
It’s not all about C++, Python or any ofthe other more popular
programming languages though, Using the commandline of
Linux, also called the Terminal, you're ableto create Shell scripts,
‘which are programs that ae 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
‘certain operation,
Finally, although there are many more advantages we can lst, there
are thousands and thousands of free programs and apps avaliable
that cover nearly every aspect of computing, Known as packages,
there are (atthe time of writing) over 8,700 specific programming
applications just on Linux Mint alone and an incredible 62,000
overall packages catering or everything from Amateur Radio to
WWW tools
Linux then, isa great resource and environment for programming
in. It’s perfectly suited For developers ands continually improving
‘and evolving. If 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 Linux programming environment can be as simple or as complexas you need itto be.
wndmpublcationscom
sucoesitesever-insecinZz Say Hello to Linux
The Best Linux
Distributions
BU 1d Col eLo meson elm MUN TC Lol MOOTED enol een So Te EE)
Ciclo) kere eC Melee eal eee CoM RUA Cole)
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 carefull.
Tae
By ar the most popular Linux astro (distribution) i Linux Mine.
Mint began ife back in 2006, as an alternative tothe then most
popular distro, Ubuntu. Although based on Ubuntu’s Long Term
Support bud, Linux Mint took different direction and offered
the user a better overall experience.
Linux Mint has three main desktop versions avaliable with
each new version ofthe core OSit releases. This may sound
confusing at first butt’s quit simple. Currently, Linux Mint
tses the Cinnamon Desktop Environment as its Flagship model;
there's MATE and xfce models available too.
Cinnamon sa graphically rch desktop environment, MATE uses
less Fancy graphics, and is more stable ona wider variety of
desktop systems, and XFce san extremely streamlined desktop
environment that’s built for speed and ultimate stability
“Throughout this tite well be using the Cinnamon version;
however, you can try out any ofthe ather desktop environments
asyou ish. fact, it's recommended that you do spend some
time trying different environments, and even different distros,
tosee which suits you and your computer best
‘wwwilinuxmint.com
TN)
‘The second most popular distro available is Ubuntu, which
Isan ancient African word meaning ‘humanity to others
Ubuntu’s popularity has fluctuated overits fourteen year ie
‘ALone time, itwas easy the most used Linux-based operating
systemin the world but some wrong choices along the way
with regards toits presentation, and some unfavourable,
controversial elements involving privacy, sadly sawit topple
from the number one spot.
‘That sai, Ubuntu has since made amends and isslowing
crawting its way back up the Linux leader board. The latest
versions of the OS use the GNOME 3 desktop environment, an
impressive environment, although itcan be alitle confusing
For Former Windows users and isalittle heavy on systern
resources especialy if you're planning on installing ton an
colder computer.
Ubuntu, forallits Faults is good Linux distro to start
experimenting wth, I’ a clean interface, easy to use and install
{and offers the user a complete Linux experience.
www.ubuntu.comArch is one of longest running Linux ‘Arch s a 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 nothing but the command line and From
Mint or Ubuntu when you can install there you have to manually partition your
‘Arch? Many users do exactly that but i's hard drive, set where the installation
notideal for beginners. Ubuntu and Mint files go, create a user, set the OS locale
both offer an easier installation path and and finally installa desktop environment
come with software packages to help along with the apps you want,
you get started
‘The advantage though, foralthishard
onthe other hand, is amore work isa dstrothat you have created. This
‘bare bones’ affair. Arch is committed to Free software and means your Arch ditro wor't come withthe unnecessary files and
its repositories contain over 50,000 apps to instal, including apps that others have preinstalled t's custom made for you, by you,
‘multiple different Desktop environments, and use as you would
with any other distro,
sig 14sec
NadoubtyueheardoftheRaspbenya. shad nottohine, |
be hsaizant heer sail ask vuln
Sere ae eee
‘There are several aspects to the Raspberry Pi that make it
such asought after piece of the computing world, For ane
it's cheap, costing around £25 for what s essentially a fully
working computer. t's smal, measuring not much bigger than
‘creditcard, You can build electronics witht, using a Fully
programmable interface; and it comes with Raspbian, its own
custom-made, Debian-based operating system that includes an
office suite alongside mary different programming languages
and educational resources.
Raspblan is exclusive to the Pi hardware, since the Raspberry
Pluses an ARM processor to power it. However, the Raspberry
i Foundation has since released a PC version of Raspbian:
Raspberry i Desktop.
‘Most Linux distributions Fall into two camps. There are on
with the latest features and technology lke Ubuntu and
‘Mint and those with few new features but rock solid relabil
lke Debian.
Just lke the Pi version, Raspberry Pi Desktop comes withthe
allthe coding, educational and ather apps you wi
Tes quick, stable and works superbly. you're
stretching your Linux experience, then ths s certainly one of
the top distros to consi
“Meanwhile, openSUSE attempts to cover bath bases.
(OpenSUSE Leap is the rock solid system. It's developed openiy
bya community along with SUSE employees, wha develop
an enterprise level operating system, SUSE; this powers the
London Stock Exchange amongst other things. Itis designed
For mission critical environments where there is no scope
Forinstablty’. you Find all that too sensible, openSUSE
Tumbleweed sa rolling release with all the latest Features, and
the occasional crash
‘www raspberrypiorg/downloads/raspberry-pi-desktop
eee =
openSUSE s hight respected Linux distribution and mary
ots core contributors work on the Linux Kernel, ubreOfTice,
GGnome and other key Linares. inshore, openSUSE is where
youll find the proshanging out
wwrwopenSUSE.orgZz Say Hello to Linux )
Equipment You
Will Need
BO ene Mietunedotecr iM urea f en acer ery
SU poracaiale WAR ooo emer ees ir Oreo ROT ar) MR en Kel ecom
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.
SMe Vy Ty eeue)
‘Tae minimum system requirements for Linux Mint are ‘Yu can install Linux Mint onto your computer via USB or OVD.
asfollows We lookinto each alittle ater on butf youre already familiar
with the processor thinking of USB and just gathering the
= hardware you need, then you're going to
SR ee ‘need a minimum 4G8 USB Fish crive
RAM/Memory—512MB to store the Linux Mint 150.
Hard Drive space —9GB (20GB recommended)
Display 1024 x 768 resolution
‘Obviously the better the system you have the better the
‘experience willbe and quicker too
DVD INSTALLATION
DVD installation of
Linux Mint simply
requires blank
DYDR disc. OF
course, you also
need an optical
drive (a DVD Writer
drive) before youre
able to transfer or
burn the SO image
tothedisc,
FED eteck 009 rec Series and tion(Equipment You will Need vw
Installation toa virtual environment i a Favourite method of testing and using Linux distros. Linux Mint works exceedingly well
‘when used ina virtual environment but more on that later. There are many different virtual environment apps available; however,
VirtualBox, from Oracle, is one ofthe easiest to into. You can ind the latest version at www.virtualbox.org
X Asatte
BB cnange Desop ckround
wr bdmpublcationscom
Clckonthe Men andtype system settings and
Ese) ‘open the resulting icon. This takes you to the
system Setting options, romhere you able to conl and edt
the way Lux Mint Cinamon os and works 2 well add new
users manage the frewall and enable acess option.
eageaea
Be eaoana
a ogesa
aoee
oees Oa
PEPER 0 short Linux mint cinnamon can be configured
tolook quite extraordinary. There are many
examples available of how good it can get and what can be
‘achieved. You can go as complex or as simple as you want, adding
ifferent component and animations or just keepingit plain and
easy toread.
‘ack 0og Tech Series 2nd Etonmy Getting to Know Linux. )
10 Things to do After
Installing Linux Mint
Linux Mintis a polished distro out of the box but, as with most Linux distros, there are
some tweaks that can be applied to improve the way it works. Although these are Mint-
specific tweaks, most can be applied to other distros.
LINUX TWEAKS
Some of these post installation actions are highly recommended, while others are just handy additions and simply tweak the
system or add a customisation.
The first, and most important, postnstallation Click the OK button and you can see a couple of
actions to update the system. Clickon the shield ‘Updates ready for installation. Before you update
icon in the Panel, found at the bottom right of the desktop next to though, click on the blue bar OK button to switch toa Lacal Miror.
the time and date. This launches the Update Manager. This opens the Software Sources option. n the Mirrors section, click
cn the Main and Base drop-down menus and selecta server closest
toyour current location,
PEPER Linux Mint offers the usera three level policy Bee ick the Update the Cache button and close the
approach to updates: Don't Break My Computer, Software Sources window. Back n the Update
Optimise Stability and Security and Always Update Everything Manager, click on the Install Updates ican and enter your password,
The recommended options the Optimise Stability and Security, __The updates automatically apply themselves and relaunch Update
which only updates safe, essential patches that won't impact critical Manager, this time with a lot more updates, Again, click instal
elements ofthe core OS, Read through the descriptions but choose Updates, OK any messages and wait for ther to Finish
the middle, and recommended option.10 Things to do After Installing Linux Mint 4)
SED the und: graded by level, 1 being alow
level update, level 5 being a dangerous one. Stick
to level 3 updates, is our advice; and click Replace For any messages
-egarding overwriting a configuration file, With regards to the
Software Rendering issue and lack of drivers for non-VirtualBox
Users, click the Menu and type ‘river ina the search box.
Be When asked to accept the changes, enter Y and also,
when asked to configure ibdvd, Make sure OK is
highlighted and press Enter, then Yes to any Further questions. Next
up, stilin the Terminal, enter: cat’ /proc/sys/vm/snappiness;
the result should be 60. IFyour computer has less than 4GB of RAM/
memory, then enter: gksudo xed /etc/sysctl.. conf.
Click the Driver Manager app that appears asa
result ofthe search and enter your password, Mint
10 analyse what's available and presents you with
a selection of potential drivers based on your detected hardware.
‘Those with graphical problems, such as Software Rendering, should
‘optto use the latest, recommended Graphics drives
Sy
takes a moment
PEPTSEM) A this point you'll probably need to restart Linux
‘Mint, sa do that now. Aftera reboot click the Menu
button again, followed by the Terminal. The Terminal icon is found in
the lefthand column, above the Files icon, With the Terminal open,
enter: sudo apt-get install Libdvd-pkg, press Enter and
type in your password. This enables encrypted DVD playback
wr bdmpublcationscom
ESTTSEDD This tweak helps speed up systems with less than
4G8 RAM/memory. Scroll down to the bottom of
the file you just opened and add the following new lines:
# Decrease snap usage to a more reasonable Level
‘vm. swappiness=10
Click File > Save, then File > Quit. Reboot Linux Mint and you should
notice a slight hike in performance
Security is always a concern in this modern digital
age. While Linux Mintisa secure system, i's
‘advisable to always try and improve it. lick the Menu button and
‘earch for Firewall click the Firewall Configuration icon and enter,
yur password. In the Firewall window, click the Status slider to On.
BlackDog iTechseries-2ndestion EE4
Apollo 11
[DID YOU KNOW... PARRA
Seer ea Ces aC)
DUIS ne ue ua
Beare oe eters
Preece euros
Peer ered tcc)
from scratch. Using a new method of
Pere eure cele eeay
eee see a
eee nee uN aE)
Bere
Incredibly, that code is freely available
eeu eakelg Memes er Tee)
researcher in 2003, you can view the code
ER eR eine A
ean Atco mees eso
erate Mune a Ono
Sea Sedu i ak ee Meo
Sees
Poe oad ce]
Syetie) i: ae
sence a humour,
Seewhatelsel
inthere1 One giant leap For
\ mankind, and coding.Zz Getting to Know Linux
Creating Users
When you first install Linux Mint it is configured For use with a single user. While
Birla eMac UTM Rn SCRE aC a MeO eRe RR elt)
need to create separate users with their own unique Home folders.
NEW USERS
‘on are separate, as with multiple users on other opers
different users means each user has access to his or hers own areas on the system. Documents, pictures, videos and so
systems.
Clckonthe Linux Mint Menuand ype ‘Wes to
Sua begin searching For the relevant console, From the
search results, choose Users and Groups and eter you password,
The Users nd Groups console squtebasiclookng, and thanifuly
tasy tose. tis you canis see your own username rom when
you tale Uno in
PEPTIPD) To add a now user, click the Add button a the
bottom of the console. There are two types of
ser you can create, Standard and Administrator. Unies the new
ser has need to install new apps or access pars ofthe filesystem
‘beyond their Home folder, then opt forthe Standard account type,
(Otherwise, use the Administrator account type
EX) sect op ech series 2nd ton
Enter the new user's Full Name, Followed by the
Sars Username they need when logging into Linux Mint.
Make sure the username'sallin lower case, 2 and 0-9 characters,
‘only. You can have full stops, underscores or hyphens if you wish
‘lick the Add button when you're ready to continue.
‘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 lst of current users, then
Click the No Password Set option under the user’ username.
eran roups -0
entiFER vo nroncic sneer nvcn we
displaying it. Naturally i's a good idea to come up with as strong a
password as possible. when you're done, click the Change button,
‘age rset =
re elf
se
al ber
You can lose the Users and Groups console window
SHEP 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 user is now present inthe ist of
Currently avaliable users, Click on hier to log them in
COMMAND LINE ACCOUNTS
(_ Creating Users
PEISED) Once logsed in the new useris required to set up
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 beable to install any new
‘app5. This screenshot is From a Standard user account type.
installing new software, that way you can keep track of what's on
your system.
Session
Log out ofthis system now?
Switch User Cancel
ust as you'd expect, you can also create a new user within the command Line. Open up a Terminal session under the main
ite cure tenie
PRED the process for adding a new user fromthe
command line is relatively imple. To begin with,
ee Dipcusernane>);
the new user's login name, You're then asked to create a new
tga rte amine ee
MeN ee hee see ort
wn dmpublcatonscom
PREM vou can check the details and account type for
the new user from within the Users and Grou
PI eee eee
‘enter: SURANGA TREATIES n the Terminal orcick the.
Peer Maier enon
anaoesitenseie-insecinZz) Getting to Know Linux.)
Customising the Desktop
Ce leolu I iiate en nein Le ale Bt Ke hve) ela NIZ ASOT MA el el)
Roe Rec eeck ae ea eae RRO MLS CN eMC UC aad
company logo. Whatever your reasons for having your own desktop, here's how it’s done.
YOUR DESKTOP
Linuxis probably one of the customisable operating systems there is, With just a Few tweaks, one or two extras installed and
some imagination, you can create something incredible,
Thefistotofceleopentoiatinsto — ERRERE vousatredtocckthe nalenags rom any
Susy change the wallpaper. Right-click the desktop and BERS) of the locations provided to have them install as the
choose change Dest backround Thsopensthe Backgrounds deskop walpaper neta you have ages sored in araher
pinunoxMin remember other ditrosmay presenter locaton on ouster eto youcen a the cing nh
Background walpaper selection took dierent, the Plusmo atthe betom ofthe Balground conse, sng
thee managerto locate them
PEPER) ore recent versions of LinuxMint display available EFM ay clicking on the Settings tab you can, instead,
backgrounds depending on the version the user is play numerous images as slideshow or change the
running. You normaly get three categories followed by afourth, aspect ofthe wallpapers toa variety of choices.
Pictures, which fs separated from the others. The Pictures option
's different because it reads the image content from the Pictures
Folder in your Home area,Casing the eston QE
Kroneohhe alse walpaentateyou ETP Thenesalowsyoutochnoetie way etain
SHEDS Fancy, open a browser and search For the type of sua aspects of the Mint desktop look: Window
baclgroundimageouprefe whenyouve foundtheimageyeu Borders cons, Contos, Mouse Pointer an Delp, Inthe
wantas the desltop walpaper ightlckitand choose Sets __Setngstabyou can extend the options witha fe on/off sider
Desktop Background rom test of optors When the Set Desktop buttons, to,
Background console ope, lc the Set Desktop Backround bon
CS) BES a re
SED cistern consent ese EEE rye ces one rarer steno
console allows you to pick the layout, desktop icons and options __ default view from a numberof preinstalled themes. lckthe theme
for multimonitor support you want. You can experiment with the you want, then click the Install (downward-pointing arrow) button
‘options For the best setup, according to your personal tastes. toenable't.
ESTEE AD |" addition to changing the desktop wallpaper, BETS ERERD lick back on Themes, then Desktop and you can.
and how the icans are displayed, you can also alter locate the newiy installed theme and apply to your
the overall theme for Linux Mint.From the Mint Menu, search for _ desktop, ny installed Themes can also be uninstalled via the Add
‘themes’ and click the Themes app asit appears in the search results. Remove button. I's worth spending some time personalising your
desktop how you want it and there are some incredible themes
available too.
inbnseisin snd ooiteseie-anscaion CIEZz) Getting to Know cr)
Becoming
Anonymous Online
The digital age has led to many great advances in communications; however, it has
Elrod reeltte eoa Met Rema R ee uleLe) Teme elmore ACOA
frequent news stories of governments, secret organisations and underground hackers
breaking our privacy but how can you combat this?
ANONYMITY WITH MINT
While it’s virtually impossible to become totally anonymous online, you can take measures to ensure our privacy is atits best.
FETTER Setting withthe basics, use HTTPS instead of the [ENSINEM Atthoush using Gooale may seem tke the obvious
standard HTTP when browsing. Tis means that choice for a modern Internet search, the company
anything that's transmitted over HTTPS is secure (hencethe part does track all searches made by an individual. Instead, consider an
atthe end) and encrypted. alternative search engine, such as DuckDuckGo, a search engine that
doesn't store personal data or track you
sreenumrese scart Eriieane icant
‘browse without the details being stored for later scrutiny by NoScript and Adblock Plus to block trackers, adverts and other data
BT): 0cstensee-antation(Secming tones onine QE
VPNS AND TOR
The previous steps can ald your online privacy but to really become anonymous you need a Virtual Private Network and Tor.
end resultisthatyourcomputersidentty on the Internets hidden Downloads/. Enter Lsto check the tax Toles present then
behind the VEN remote server; soyou culdiveinthe UK buthave enter: tar =xF tor-browser-Linux64-6.0.4 en-US. tar
aniPadéress he computer online ident) belonging tolcland. xz (Torls updated regularly of your versions diferent press Tab
to autocomplete the tor-bronser-Tiename), When the files are
unpacked, use ed tor-bronseren-US/ tocnter the new Folder.
HowMM works? ie ”
Be
Be
Be
BETES Most g00d VPNs chargea monthly orannualfee ESE A quick Is revealsa couple of entries: afolder called
butts worth the expense. We use CyberGhos, Browser anda file called start-tor browser desktop!
\wwrw.cyberghostvpn.com, which offers VPN connections for ‘To start the Tor setup, type ./start-tor-bronser.desktop.
\windows, Mac, Mint (as well as other Linux distros), Android and This command launches the Tor setup, where youare offered two
10S devices. Detals For each OS can be found at www-support. ‘options: Connect or Configure. For most users, the Connect option
«yberghostvpn.com/hc/en-us/articles/213190329-Read-me-f will suffice. Click Connect when you're ready.
Toe! Browser
crtechost ON 70-unbored
ESTEE 2 etherontionistouse Tor Torisanopennetwork EAM Aterthe connectionis established, the Tor Browser
that you can attach to that hides your IP address launches. Thisisa customised version of Firefox
behind countless nades around the world. k's available For Windows, and from here you can securely browse the internet without Fear of
‘Mac and Linux computers andis very easy to instal and use. Start being viewed or tracked. Mixing both a VPN and Tor makes for an
bbynavigating to www.torproject.org/download/download-easy. extremely secure and private connection to the online worl.
bhtmLen and clicking on the Download Linux 64-bit button,
ST emi CCNY
ieee sudo iteseie- scan CEA Index )
BA) stock op itech series 2nd tona
“Linux: the operating
system with a CLUE...
Command Line User
: Environment.
— Anonymous (Posted on comp.
software.testing)
wr bdmpublcationscom
(us .g the Terminal A
The Linux command line, the Terminal,
isan incredibly powerful environment.
From it, you can bring the OS to its
knees, or update it to something
spectacular. You can hack into remote
computers, look at an animated
ASCII camp fire, install new apps and
programs, watch Star Wars played out
froma server in the Netherlands, and
code intricate automated scripts.
In this section you will explore the
intricacies of the Terminal, and how it
works with Linux. You will learn how to
manipulate the Linux file system from
the Terminal, and you will discover
some odd, but fun things you can do in
the Terminal.
The Terminal rules supreme in the world
of Linux. Learn how it works, and you
can access all that power.
46 Basics of the Terminal
48 Update Mint via the Terminal
50 Install Apps via the Terminal - Part 1
52 _Install Apps via the Terminal Part 2
54 _ Did YouKnow...Linux Kernel 0.01
56 Creating a File Using the Terminal
58 Creating and Removing Directories
60 Fun Things to do in the Terminal
62 _ More Fun Things to do in the Terminal
64 LinuxTips and Tricks
66 _ Did You Know...Linux and the Big Bang
68 Creating Bash Scripts-Parts 1-5
7B PixLinux= The Perfect Combination
80 Command Line Quick Reference
82 AZof Linux Commands
84 Did YouKnow...Good enough for NASA
—————£9 Using the Terminal
Basics of the Terminal
Most operating systems use two kinds of interface, the GUI, which is the desktop
that Windows, macOS and Linux Mint boot into and the command line. While modern
operating systems shy away from the command line, Mint uses the Terminal to give the
user greater control of the system.
TAKING COMMAND
‘The command line, or Terminal, is an extremely powerful interface. Everything you can do on the desktop can be done within
the Terminal. Let's start by seeing how it works.
ntly ee inthe Terminalisyour login
Tete canbe acest yetterclciogon TERED visto
cua) the Terminal icon on the Panel, located between sue name Followed by the name of the computer; as you
{he Frefox and ies icons orlaunchedby opening the Menu and named. during setup wen you Fist installed Mint. Then then
selecting i From the left-hand quick launch strip, ends with the current Folder name; at fist this isjust a tide ~, which
means your Home Folder.
CPC COSC Eras
Eee The Terminal ives you access to the Linux Mint FETIP the fashing cursorat the very end ofthe line is
Shell, called Bash, wihich gives you access to the where your text-based commands are entered, You
underying operating system. Everything in Mint, including the can begin to experiment wth a simple command, Print Working
desktop and GUI is 2 module running from the command line. Directory (pwd), which outputs the current Folder youre in to the
screen. Type pad and press Enter.
WB) stock op iech series 2nd onFETED Ailthe commands you enter work n the same
‘manner: you enter the command, include any
parameters to extend the use ofthe command and press Enter to
‘execute the command line you've entered. Type into the Terminal
uname a and press Enter This displays some system information
regarding Mint
Before we getinto entering commands ts take
SUNS a moment to see what menus the Terminal has to
offer, The File menu option alowsyouto open anew Terminal
Create anew prof, where you can alter these, colours and
Behaviour ofthe Terminal ada new tab, nd ove allcurent
ete Terminal session
PEPTED) The Edit option lets you copy and paste commands
to.and from the Terminal and ather sources; handy
For when you want to copy a very long and complex command froma
web page. It also allows you to edit the current profile preferences.
wr dmpublcationscom
Basics of the Terminal
ew ad Searchoptosletyou ale the sng of
evans the Terminal window and of course search within.
the Tetrinal for any partir key words
From entering any commands into the Terminal: this is ood For when
You need to permanently display the Terminal contents.
PEPER Finally the Help option displays the help contents
and version number ofthe Terminal, orto be
more precise, GNOME Terminal well simply referto its Terminalin
Future, The Contents are worth having a quick read through, tohelp
familiarise yourself with how the Terminal works,
BlackDogiTechSeries-2naeation (47A Using the Terminal
Update Mint via
the Terminal
Up to now you've been using the shield icon to launch Mint Update Manager in order
to update the system and upgrade the currently installed apps, tools and other
elements. However, you can also accomplish a complete system update and upgrade
From the Terminal.
USING APT-GET
‘To update and upgrade via the Terminal you use the APT (Advanced Packaging Tool) command. It's a powerful command and
combines different elements depending on its use.
ESTEE Se2tbyopening anew Terminal orifyou already ESE) Apt get is used to update and uparade the
have one opened clear its contents with the clear software in Mint, as well as Ubuntu and other
‘command. This tarts you off witha clean slate on which ta work. _Debiarrbased distros. Using the Update element retrieves
new package lists and updates the list of source files. Uparade
downloads and performs an upgrade tothe latest versions of those
files. To start the entire Upgrade and Update process, enter: sudo
‘apt-get update, followed by your password.
ESTEE Ester apt-get into the Terminal This brings upa [EES Notice now the addition ofthe sudo command. The
list of the most used apt-get commands, along with sudo command once meant Super User Do; these
brief description of what the command does.lt’s worth havinga__daysit’s more acceptable as Substitute User Do. It means that the
laokat, even fit doesn't make a huge amount of sense at this time. administrative user (Super User) uses APT (Advanced Packaging
Too!) to Get any Updates. Now try this: sudo apt-get. upgrade,
WB) stock op ech series 2nd tonDepending onthe state of your updates, you
SUEDE have any waiting to be installed, you might be
asked youwant to aply he resuksof he sudo opt-get
Upgrade commana, You cn pressy to accept and cannve, Whats
happening here stat apget has some peated software to spp
to mint and youe ckaying the action
Update Mint via the Terminal
4
scent thas your systemis now uptodate
suse according to the available list of packages From the
apt-get update command, Youcan rn rough the process one
tore Une justo check everything wet ay To ea ee:
Sudo apt-get update, press Enter, tentype sudo apt-get
Upgrade an pes Enter.
TERMINAL VS UPDATE MANAGER?
‘Why use the Terminal to update and upgrade over the Update
‘Manager, regardless ofthe distro you're using? Some users
‘reatly prefer using the Terminal to update their Linux systems
‘and accompanying apps, in the belief that it’s better. However,
that’s not often the case.
Using the Terminal, apt-get upgrade, doesn't handle changing
‘dependencies between versions of packages, so if a package,
thas ts dependent files changed from one version to another,
then the upgrades held back.
‘The Update Manager, or Software Manager (depending on the
distro), often phases its updates and marks those packages
wn dmpublcatonscom
‘with changed dependencies for updating. However, and this is
‘where Linux can often get confusing, sometimes it doesnt.
Itall bolls down to the developer of the package being
updated and the way the package is held in the distro’s
repositories and whether the update is classified as stable
‘or not, In essence, From the point of view of the user, if you
‘update and upgrade using both the Terminal and the Update
Manager regularly, then you will be as up to date as possible,
‘and get the essential and necessary stable versions of the
packages and core software. If you're looking for cutting edge
package updates, then it's best to opt Fora rolling release
distro instead.
BlackOog Tech Series-2nd ection (49)A Using the Terminal
Install Apps via the
Terminal—Part 1
There are different ways to install apps and programs on Linux. You can opt for the
graphical route, using a Software Manager, or you can use the Terminal. Often, the
Terminal provides better control over the software being installed and sometimes, you
have no choice in the matter.
COMMAND LINE INSTALLS
Installing an app with the Terminal may require some nifty keyboard work but you get a better sense of what's being installed
and where,
ESTEE ERD stalling apps form the Terminalisoften relatively EASE You need to entery to confirm the instalation,
simple. First though, you need to make sure that which takes up around 5.SMB of storage inthe
the system is up to date. To dothis open up the Terminal and enter: system. Once Stellais installed, you can see again that Mint has
sudo apt-get update && sudo apt-get upgrade. Enter automaticaly created the Games category n the Menu as well as
your password and accept any necessary updates. the app shortcut.
ESTEE ust asyouveseen,sudoaptgetupdate/upgrade ES ESIPER Sometimes, when instaling software, you need to
and so on are designed to upgrade the software dd the app's Repository. The repository, or repo,
that's already installed on the system. How do you installore apps _ is simply the remote server location where the software isheld,
though? Iejust so happens that i's extraordinary simple. Frstyou along withallts dependencies (the vital ibraries and such it need:
need an app to install so let's use Stella again. Enter: sudo apt- to function). Start by typing inthis sudo add-apt-repository
get install stella pa: peter Levi /ppa. Press Enter when asked to and add the PPA
(Personal Package Archive),
BO) stock op iech series2nd tonInstall Apps via the Terminal—Part 1 4
BETTER) Thisadds the repo forthe app Variety Wallpaper ESTED Now toinstall variety, enter: sudo apt-get
Changer, an Ubuntu-based app that works in Mint install variety. Press to confirm and accept
{and changes the wallpaper automatically. Now that the repos added, the installation, and to continue with the install, Once installed, you
enter: sudo apt-get update, to update the new information and can type variety into the Terminal torun the app.
‘add the contents ofthe repo to the package database,
REMOVING APPS
In addition to installing apps, the apt command can also be used to remove any apps and helps keep the system tidy and free
up resources.
PEPER To uninstall orremove, the Variety app enter the EEN when you remove apps From the system you're
following: sudo apt-get remove variety. be informed that some packages that were
fer to continue with the uninstall ofthe app; notice also that automatically installed are no longer required, You already saw in
You're informed af how much space you'e Freeing up on the hard the previous tutorial, that you can tidy things up withthe following
driveas a result of removing the app. command: sudo apt-get autoremove, followed by pressing y
toaccept the process.
ie tat ven Seach Temi He
PEPER wile the apt-get remove’ command uninstals an BAAR Finally, to tidy upallthe non-used packages in
app, it doesn get rd ofthe extra clutter that comes, the system, and toremove elements that the
with an app, such as configuration and library files. To completely __autoremove command didn't, you can enter: sudo apt-get
remove the clutter,enter:sudo apt-get purge variety. ‘autocLean, These last Few steps are vital fr keeping your Linux
Mint setup in good working order and to trim off the unnecessary
cnanano ‘excess caused by installations and upgrades.
ie ttt ven Semi Tern Heb
wrdmpublcationscom ‘ack Tech Series-2ndstion (1A Using the Terminal
Install Apps via the
Terminal—Part 2
Most of the time you'll get to install apps from the Terminal using the standard apt-
get command. However, sometimes an app demands a little more work. This means
installing an app From its source code, which isn’t as scary as it First sounds.
FROM THE SOURCE
‘The commands you'll need to become familiar with here are Configure, Make and Install. You'l Find a lot of apps use installing
from source, so it’s certainly a skill worth investing time in.
Source code files for Linux usually come in the Fo The wget command retrieves content from the
Of TAR.GZ or TAR.822, Both are compressed files internet, in this case the 872 file For Vim. To check
holding allthe core files needed to ‘make’ the app. Start off this _therfle was downloaded successfully, enter: Is. According to Mint’s
tutorial by creating anew folder in Home: mkdir Vim Filesystem colour ke, the compressed file should be displayed in red
BEPIPR) view bythe way, isan advanced text editorwhich WAR weneed to uncompress the contents ofthe file
well use as an example to instal. Enter the new now, so enter: tar -xF vim-7.4.tar.b22 into
folder, cd Vim, then from within the new Vim folder, enter the the Terminal. Note: you can type in tar =xF vand pressthe Tab
following command into the Terminal wget ftp://Ftp.vim. key to autofil the remaining file name.
org/pub/vin/unix/vim-7.4.tar.bz2,
BB) stock op iech series 2nd tionInstall Apps via the Terminal—Part 2 4
for the main app, then as you upgrade apps through this method _with an error you can continue to the next stage ofthe installation,
the individual versions will each have their own Folder. Note: you may need to search online for some error messages,
Feat Vow Search Terminal Help
SED veinct viasiocne vei ndtsonin ED wena est /ongure nese
of fies reser: mostoretie appscorefles whdeathersllbe enterng:make nto te Tera Tsay take awe depending
labelled README or INSTALL I's always wise toreadthese fllesfrst on the sizeof the app,
asthey provide valuable information regarding the installation,
FETED The frst part oftheinstallationrequiresyouto enter [ESET Finally, you need to enter: sudo make install
/configure. The /configure command will check ino the Terminal. Ths wil install the app, and
yur system for any missing dependencies associated withthe app. IF make itready fr use inthe system, When complete you can execute
you received an error regarding aC Compile, then enter: sudo apt- the app in this case by entering vim into the Terminal or searching
get install build-essential. The third-party app Neurses __Foritvia the Dash,
\was recorded as missing. We need to instal that with: sudo apt
get install Libncurses5-dev LibncursesnS-dev.
wbdmpublcationscom flackDog Tech Series-2ndestion (83)Kernel command line: block2ntd.block2mtd=/dev /hda2,131072, rootfs root=/dev/mtdbl
lockO rootfstype=jffs2 init=/etc/preinit noinitrd console=tty0 console=ttyS0, 38
Cee ote
Gece mC
Eee eae Ce mec ra
Enabling unmasked SIMD FPU exception support... done
Hibbet iets Mente
PID hash table entries ee Bac
eae CORA
console: colour VGA+ 80x
console [tty0] enabled
Cieaemtss ome tt
Seances Cec OT eee eS
Heese CCR eters Roe ac)
Memory: 5112k/8128k available (14: Te PP ae a ee)
kk init, Ok highnen)
Cane ner mors
fixmap + Oxfffb9000
ml
a)
CCE ee
kB)
ote (1497 kB)
checking if this processor honours the WP bit even in supervisor mode. . .Ok
calibrating delay using tiner specific routine.. 4047.64 BogoMIP 1238210)
Ce eyDID YOU KNOw.
eee eerZY) Using the Terminal
Creating a File Using
the Terminal
Using the Terminal, you're able to create folders, files and even execute Linux Mint
apps. In truth, if you didn’t have the GUI at hand, you could still accomplish the same
From the Terminal.
MORE TERMINAL WORK
Creating content using the Terminal isn’t quite as strenuous as it may first appear. Yes, the Terminal can look a daunting place
for the newcomer, but once mastered it’s really quite intuitive.
SEED cust terintansmtearesaieinte BIER) ver conmantinshoudtrgtothe ele
¥youto the Home folder From wherever you're currently located, bbe nothing within the Folder, as you've just created it. The mkdir
commands fairly selF explanatory: Make Directory Followed by the
aaseanneniar name of your choosing
ie en seach Temes) He
PePTSE DD et’ start by creating a new folder within Home, PPD To create an empty text file, called Test.txt, enter
and call it Test. The command youtl need is inthe Terminal touch Test. txt. You can then
mkdir Test. Press Enter to create the folder when you've typed _—_use Ls to view the new file inthe folder. Touch sa standard Linux
inthe command, then cd Test and press Enter. This will Change command that allows the creation of files without the need to open
Directory (hence €D) to the newly created Test Folder. text editor, save the file, then close the editor,
BB) stock op iech serias2nd tonPEPER 2t's say you now wanted to create a text file, well
callitTest2.tx, complete with some content. To do
so,enter:cat > Test2. txt. Thiswill create the file Test2.txt and
put the Terminal into an editing mode.
aevideaon
Fleet View Search Terminal Help
Youll notice thatthe cursors lashing below the
cat > Test2.txt command, without the usual
‘prompt. This editing mode wl allow you enter the text thatthe file
‘will contain. Enter some text, then press CtrleD to ext and write the
contents to the fe
PEPTSED) f course you don't always have to use the Terminal
to-enter text into ale. Mint comes with atext
editor called Xed, whichis similar to Windows’ Notepad. To view the
previously created file in Xed, type into the Terminal-xed Test2..
ress Enter,
wn bdmpublcationscom
(Creating a File Using the Terminal 4
koa as
F however, you prefer to remain workngin the
Pe Terminal to edit/save/create files, you can use
Nano, Nanots simple Terminal basedtext edo, To ty eth
the example, enter nano Test2, txt There's 3 ent long the
bottom ofthe screen, Toexitand save any contentin Nano, press
tite ad Folow the onscreen structions
FETSETR) We've used the Terminal to launch a Mint app,
ed, but any app can be launched from within the
Terminal. For example, ty: Firefox, and press Enter. Close Firefox
toretum to the Terminal. Providing you know the name ofthe app,
itcan run from the Terminal, Additionally, entering fireFox8 opens
Firefox, AND lets youstil use the Terminal
“Caeaty “Gavens ESI Phone “Eee
‘lackOogTechSeries-2ndestion (87!+ 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.
SR Terrinal open enter dt make sure you were to enter he command aah nk
toview he crentfldesyouhavehowedhtheHome dreciory. camot ereate directory “eastair’s Five exists t
Yeu notice thtfolersarelabeledinsantincjan (ght ble). goesuthovtsain the, thar yore ony ble to have oneuiguely
Let's start by creating anew directory. Enter:mkdir testdir, named directory within the current directory, However, as Linux is
case-sensitive, you can have Testdir, TestDir, testDir and soon,
ESTEE | younow enteris again, youll see that the new PRIM You can create directories within directories youve
directory, testdir, has been created alongside the already ceated. For example, enter the testdir
‘ther directories in the Home area. Obviously the commandmkdir directory with ed testdir/ followed by sto list the folder structure.
iswhat creates the directory, and no doubt you've already quessed _Naturallythere's nothing present, as you've|ust created the directory.
itstands For Make Directory Now drap back to Home with ed ~ and entermkdir testdir/
reports. Gobackto the testdir.cd testdir/, and Ls again
BB) stock op ech series 2nd tonThe command to create directories is quite logical,
therefore. You'l create the directory, and any sub-
directories within, However, what iFyou want to create a directory
and a sub-directory ina single command? Make sure you're at Home
(cd~)andentecmkdir -p Temp/fnances. Now, ed Temp/, and
Istolist the new directory
The-p optionis what enables the mkircommand
to.reate the sub-directory as well as the parent
directory. n Linux, commands always Follow the same structure
‘Command, Option, and Argument. In the previous step example,
command (mkdir), option (p), and argument (Temp/finances).
File Edit View Search Terminal Help
PEPER you want to drill down into the various options
available forthe mkdir command, you can enter
mkdir --help into the Terminal, This will provide a quick help
‘Quide detailing the options and how the command structure works.
wr dmpublcationscom
Creating and Removing Directories 4
Now tat weve createdsome decries ets see
sus about removing them. Start by entering the testdir
folders. txt && especk -F folders. txt. Ths wil have Mint,
read back the contents oe command
ew Search Terminal Hep
Eee AD 4 02ring ASCH Fire isn't the most useful command
tohave at your disposal, bt i's Fun. instal t with
sudo apt-get install Libaa-bin, then when installed use:
afire. i's not exactly warming but you get the idea. To expand
the above, enter: sudo apt-get install bb caca-utils,
then, cacafire.
ru
wn bdmpublcationscom
More Fun Things to do in the Terminal
M
Used as must demo from the od Amiga and
eusny DOS days, the bb command reminds us of getting
hold ofthe and ahalFinch floppies crammed with al manner oF
demoscene goodies Weve beady instaled Bb rome previous
Step, ao jst ener bb, Foto the orseen nto and tun UP
yourvolume
get install. Libcursessperl when thats done ener-cd
Bowntoads/ 8& wget http://search.cpan.org/CPAN/
tuthors/id/K/KB/KBAUCOW/Tern-Anination-2-4. tar.gz
ik tar xf Term-Anination-2,4,tar.gz 8& cd Term
‘Animation-2.4/.Then: perl Makefile.PL && make && make
test && sudo make install.
This entryisin two parts, First you need to get
BED 01 ve necessary packages: suo apt
eh that ite ot done, ont the ned Ener: ed
Sua . && wget http://www. robobunny. com/
projects/asciiquariurvascii quarium. tar.gz 88 tar
ef aseliquariam.tor gz 8& cd oscliquarun1.1/
Ab chod x asc quorum Provangal went wel, ener «/
acl tquariumand enjoy your very own ASCH based aquarium,
flackOogTechSeries-2ndestion (63A 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.
Emacs thetext dor isa ret pec of
eases software, however, did you know it also
contains a hidden Easter Egg? With Emacs installed (sudo apt-get
install emacs25), drop toa Terminal session and enter
emacs -batch -1 dunnet
Dunnet is a text adventure written by Ron Schnell in 1982, and
hidden in Emacs since 1994,
PUTT cera {25ec on the cassic 1982 arcade game,
Moon Patrol, Moon Buggy appeared on
the home computers of 1985 amid much praise. l's cracking Atari
‘game, and t's available inthe Linux Terminal by entering
sudo apt-get install moon-bugay
Then:
rmoon-buggy
Enjoy.
MRNAS AEIND 5 orcedbeinaable to
the Terminal While not particulary useful is quite a Fascinating
thing to behold. Todo so, enter
sudo opt-get install elinks
elinks
Enter the website you wantto vst.
Saat Sowing in the Terminal console isn’t
something you come across every day. IF
you're interested, however, enter:
get https://gist.githubusercontent con/sontek/
1805483/raw/7d0247160aS7e69Fb52632Fee09F42
753361c4a2/snowjob.sh
chmod +x snowjob..sh
-/snowjob.sh
GA) sick Dog ech series 2nd tonLinuxTips and Tricks @@Y
PVA Tele ("vou need to see what apps are
consuming the most memory on
Linux, simply enter:
PS oUx | Sort =pnk 4
This sorts the output by system memory use
BESSA Wenyou delete a le, her'sa chance of
ARS, someone with the right software being able
toretraveit However, tosecurel and permanently delete ae,
use sired
shred -zvu NAMEOFFILE. txt
Replace NAMEOFFILE with the name of the fie to delete.
PCa cap 88! acccan be quite striking when applied to
some images. However, it's often dificuleto
‘get ust right. You can create some great ASCII art from the images
you have by using ima2bxt:
‘img2txt NAMEOFIMAGEFILE..png
Replace NAMEOFIMAGEFILE
with the actual name of the
image file on your system. F
lmg2txt instal installed, use:
sudo apt-get install
caca-utils,
wr dmpublcationscom
‘Back in the days of diatup connections, the online world
was made up of Bulletin Board Systems. These remote
servers provided hang-outs for users to chat, swap code, play games
‘and more, Using telnet in Linux, we can stillconnect to some active
Ses:
telnet battLestarbbs.dyndns.org
There are countless operational BBSes available, check out https://
www.telnetbbsguide.com/bbs/list/detaly, for more
you wantto create an entire
pI Ses MSLES directory (or folder) tree with a
single command, you anuse
ikdir =p New-Dir/
{subfolder1, subfolder2, subfolder, subfoldera}
This creates a NewDir with four sub folders within
CDK Seating
‘avaliable Linux commands. Thankfully, we can use apropos to help
Us. Simply use i, along with a description ofthe command
‘apropos “copy files”
‘apropos “rename files”
fackOog Tech Series-2ndestion (G8wv
Je
a)
1S
a
oO
x
=)
=
eywn bmpublcatonscom
DID YOU KNOw..
that Linux is at the heart of the
science 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 ba:
distributions of choice, scienti
developers and engineers have
created SL - Scientific Linux.
Using SL as 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
notable is SLC, or Scientific Linux
CERN, also known as CERN6.
According to reports, there are
over 36,000 systems running SL,
and over 15,000 running SLC.
acs Setes ninZ¥) Using the Terminal >
Creating Bash Scripts
Ore
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,
ESTER ED Youll be working within the Terminal and with a ESTED Tobeain with, and before you start to waite any
text editor throughout the coming pages. There scripts, you need to create a folder where you can
are alternativesto the text editor, which we'lllook at inamoment put allourscripts into. tart with mkdir scripts, and enter the
bbutfor the sake of eace, we'llbe doing our examples inXed. Before folder cd scripts/. This will be our working Folder and from here
you begin, however, run through the customary update check sudo you can create sub-folders you want ofeach script you create.
‘apt-get update && sudo apt-get upgrade.
Fle Et View Seach Tena Hep
le £8¢ view Search Terminal Hep
PEPER) There are several text editors we canuseto create [SSAIB windows users willbe aware that in order For a
a Bash script: Xed, i, Nano, Vim, GNU Emacs and batch file to work a in be executed and follow the
soon. Inthe end itll comes down to personal preference. Our programming within, tneedsto have a.GAT Fle extension Linux
se of Xed is purely due to making t easier to read the scriptinthe _is an extension ess operating system but the convention isto give
screenshots you see below. scripts a sh extension,
Fle Edt View Search Tein Hep
BBY) sch Dog ech series 2nd tionCreating Sah scints—rot EE
This will aunch Xed and create aie called helloworld.sh. InXed, _white to green, meaning that it'snow an executable file. To run
enter the following: #! /bin/bash, then on anew line: echo the script, in other words make't do the things you've typed into it
Hello World! enter: /heLLoworld. sh
File St View Search Terminal Hep Fle de View search Terminal He
Fle ES View Search Tools Documents He
AOealn~/xeojag
stench
n/oach
echo Hetto wortd!
TD vtriveesnincrinesremsnat stat RED) san ote en, was Heo
(#) denotes acommentline, ne thatis ignored by the system, the ‘The echo commandis responsible for outputting the words after
‘exclamation mark () means that the comment is bypassed and will __itinthe Terminal, as we move on you can make the echo command
Force the script to execute the line asa command. Thisisalso known output to other sources.
asaHash-Bang,
Fle dt View Search Toole Document Help
Doeales xenljaa
Fle Edt View Search Tools Documents. Help
poole» yen ag
(Bm Petoworssh >
1 /oinvvach
heloncrsh ¥
os /osnyach
dearer leche Hello World! This is my first script im Linux Mil
PEPTIED) You cansave thisfile, clicking File> Save, andexit_ IIMB think of echo as the old BASIC Print command. It
back to the Terminal Entering Ls, willreveal the clsplays either text, numbers or any variables that
scriptin the folder. To make any script executable, and able to {are stored in the system, such asthe current system date. Try this
‘un, you need to modify its permissions. Do thiswith chnod +x example: echo Hello World! Today is $(date 4XA).The
helLoworld.sh. You need to do this with every script you create. ${date +) iscalling the system variable that stores the current day
Fle Edt View Search Terminal Help 7
smn auaoesiteseies-insesin GIUsing the Terminal
8
Creating Bash Scripts
—Part 2
Previously we looked at creating your first Bash script, Hello World, and adding a
system variable. Now you can expand these and see what you can do when you start to
play around with creating your own unique variables.
VARIABLES
Just as in every other programming language a Bash script can store and call certain variables from the system, either generic
for user created.
Let's start by creating a new script called hello sh;
TEP 1
echoHeLlo $1. Save the file and exit Xed, Back n the Terminal
‘make the script executable with: chmod +x helo. sh.
xeolag
peo
FER tc scpissonccsannntoan,/
‘Hella’ is displayed in the Terminal. However, f you then isue the
‘command with a variable, itbegins to get interesting. For example,
uy ./hetlo.sh David
Fle elt Yew Search Terminal Help
FB) skckDop ech series 2nd ton
which are then held and passed to the script, So the variable
'$1" now holds ‘David. You can change the variable by entering
something different: ./heLlo.sh Mint.
Fle Edit View Search Terminal Help
rary
Peer
careers
FETIP DM You caneven rename variables, Modify the hell,
shscrint with the following: frstname=$1,
surnames$2, echo Hello $firstname $surname. Putting
each statement on anew line, Save the script and ext back nto
the Terminal
Fle Est Ven Search Tools Documents Help
noo xonjag
1/oin/bashhen yourun the script now you can se two
Suse custom variables: ./hello. sh David Hayward.
Natural change the wo variables wth your own name; unless,
you're abo caled David Rayuard atthe moment wee st printing
the contents soles expand the twowarble we ite
Fle Edt View Search Terminal Help
ESTED reate anew script called addition. sh, using
the same format as the helo sh script, ut
changing the variable names. Here we've added firstnumber and
‘secondnunber,, and used the echo command to output some
simple arithmetic by placing an integer expression, echo The sum
is $(($firstnunbers$secondnunber)). Save the script, and
‘make itexecutable (chmod +x addition. sh).
Fe Ee View Search Tools Documens Help
aoa ¥o0/ag
Bu stonah
1 /osn/bash
firstnumber=$2
‘the sum is $((Sfirstnunbersssecondnumber))
when younow run the adtion sh script we can
eUerY, enter two numbers: ./addition.sh 1 2. The
reste hopefully be vith the ermina paying Te sum
is3. Ty Ruth afew diferent numbers andsee what happens
See aso Fyou can alter the script and rename o mutation
and subtraction
View Search Terminal Help
wn dmpublcationscom
Creating Sahin ron
Let's expand things Further. Create a new script
Ss} HS
called greetings..sh. Enter the scripting as below
in the screenshot, save it and make it executable with the chod
‘command. You can see that there area Few new additions to the
script now.
Fle lt View Sareh Tole Oocumers Help
aoa
xo0jag
rend surnane
Jacke Hello stirst
Weve addeda-nto the eco commandhere
Bu which will leave the cursor on the same line as the
question nstesd of a newline, The read command soresthe
Users inputasthe variables stare ad surname, tothe ead
Dacklaterinthe lat echo ine. nd the clear command dears
thescren,
Fle Eat View Search Terminal Help
FETTSETR) 22 Final addition, let's include the date variable
‘we used in the last section. Amend the last ine
ofthe script toread: echo Hello Sfirstnane $surnane, how
‘are you on this fine $(date +KA)?. The outputshould
display the current day ofthe week, calling it from a system variable.
fle Et View Search Tools Documents Help
poo eojaga
Bu reeungssh x
s1ybinybash
echo /dev/nult )
44 UL 2m “soutput” 105 then
fe ~SoutputFETTER When executed the script waits for input from the
User, inthis case the file extension, such as pa,
‘mp4 and so on t's not very friendly though. Let's make it alte
friendlier. Add an echo, with:echo -n “Please enter the
extension of the file you’re looking for: “just
before the read command,
Here's an interesting, Fun kin of script using the
app espeak. Install espeak with sudo apt-get
install espeak, then enter the text below into anew script called
‘speak. sh. As youcan seeit'sa rehash ofthe ist greeting script
\we ran, Only this time, it uses the variables in the espeak output
ESTED We briefly looked at putting some coloursin the
‘output For our scripts. Whilst it's too long to dig a
little deeper into the colour options, here's a script that outputs
what's avallable, Create anew script called colours. sh and enter
the text (see below) intoit
wr dmpublcationscom
Creating Bash Scripts Part 5 Ci
The output From colourssh can, ofcourse, be
ELEM mixed together, bringing different effects.
depending on wat you vart othe ouput toa, Forearpe
white text ina red bsexground sin or linking) Say te
blinking effect doesn’t work on all Terminals, so you may need
change toa different Terminal
bara
aan
Whilst we're on making Fancy scripts, how about
using Zenity to output a graphical interface?
Enter what you see below intoa new script, menu sh, Make it
‘executable and then runit You should have a couple of dialogue
boxes appear, Followed by 2 final message,
While gaming ina Bash script isn't something
that's often touched upon, itis entirely possible,
albeit, little basic. Fyou Fancy playing a game, enter wget
hetp://bruxy. regnet .cz/linux/housenka/housenka. sh,
make the script executable and runit,I’sin Polish, written by
Martin Bruchanov but we're sure you can modify Hint: the title
screen isin Bases
aucioegiteeier-insesin GUEPExtainux=
The Perfect Combination
When the Raspberry Pi was in its developmental stages its designers needed to ensure that they were creating a piece of
hardware that could offer much more than simply being a cheap, but small, computer.
‘The Pi needed to be Flexible with what it could do, it needed to have as
Toamto gow nto ote anblious projec concep andl and
itneededtadosoinaseasytouse fashion as posse The galas
tote unersalloming platform, that students of ay 09e
Could expand on and ker ath wearing new concepts such
szprogranming, electrons and computing, tural once ,
the hardware was developed the only rea choice of aa“
‘operating system was of course, Linux
‘The verstilty of Linuxis legendary. This incredible
core OSis so malleable that can be steered
toward near any aspect of computing, from
supercomputing to robotic, the space industry to
‘more terrestrial engineering; education and
science, manufacturing and the Internet.
Think ofan industry, and you wil ikely
find a Linux installation somewhere inthe
background keeping itall together.
Raspbian i the recommended operating system for the Raspberry
Pi. a customised Debian-based distribution that comes packed with
‘collection of useful tool that cater For coding, electranics, and
‘general desktop computing duties. Alongside the apps are pre
loaded modules to help get the mast from each ofthe programming
languages you decide to learn and use, as well as software to
hardware modules that will enable you to power and use the
hardware speci items unique to the Pi. For example, there are
Python modules that interact withthe Raspberry P's 40-pin GPO,
allowing youto create content For any ofthe Hardware Attached on
Top devices
‘This combination is what makes the Raspberry Pian excellent base
‘of operations to learn not only cading on, but also Linuxin general
RRaspbian, being Debian-based, willbe ableto run any ofthe
Terminal commands listed in this book, as Linux Mint and even
buntu are also Debian based. And since the Raspberry is so
all, and costs very litte setup, you're able to have both your
regular, Windows or macOS computers, and have a Raspberry Plas
headless (a powered device that doesnt needa keyboard, mouse or
monitor attached, as you connect ta it remately) computer from which
you can connect to and learn how to use Linux and how to codeWHICH PI?
‘There are several Raspberry Pi models available, with each
‘offering something slightly different from the others. The
‘most recent Pi released is the Raspberry Pi 3 Model B+, and
while this model is slightly more expensive than some of the
‘other examples, itis the most powerful and feature-rich Pi
BEYOND RASPBIAN
‘The Flexibility of the Raspberry Pi's ARM processor means
that it’s capable of running other operating systems beyond
Raspbian. Stil keeping with Linux, you can instead install
‘Ubuntu MATE, Pidora (a Fedora-based distribution), Lakka,
iPlay (@retro emulation distribution) and Arch Linux ARM.
‘There are also systems based loosely on the Linux kernel, such
{as Android, Minibian, and Chromium OS,
There's Windows 10 loT Core, FreeBSD, RISC 0S PI, Plan 9 and,
‘remarkably, AROS an Amiga OS clone. Needless to say, that
‘once you've Finished experimenting with one version of Linux,
justas you would with a desktop version of Linux, you can hop
to another on the Raspberry Pi and see how that one works,
wn dmpublcationscom
4
Pix Linux = The Perfect Combination
available. Overall, it’s probably best to start experimenting
‘with the Pi using the PI3 Model B+, then moving on to one
ofthe other models as you develop your skills and Focus on a
particular project, such as the need to use one of the Pi Zero
models, with a smaller Footprint and WiFi enabled connectivity.
PI, LINUX AND CODING
‘As previously mentioned, the Raspberry Plis an excellent code
base, and with Linux as the backbone you're able to start learning
how to code in a multitude of different programming languages.
Bash scripting works perfectly, since Raspbian is Linux, and
Debian-based, and you can easily expand your scripts to
‘encompass much of the P's functionality, Aside from creating
backup scripts, you can also create scripts that can access the
GGPIO pins on the Pi, and in so be able to control LEDs, and even
‘more complex HATS.
Pythonis by Far the most popular choice For beginners, and.
Raspbian comes pre-installed with everything you will need to
‘get the most from your Python experience, There are countless
preloaded modules, as well as the most recent stable release of
the language.
‘C#+is one of the most powerful programming languages
to lean. t's used for games, apps, and even entire operating
systems. The Raspberry
Picomes witha great C++
‘editor that’s easy to use
‘and canhelp you develop
‘amazing content. Whichever
‘way you decide to take your
‘coding and Linux adventure,
the Raspberry Piis an
‘excellent platform from
‘which to begin on,
anaestion
Black og Tech Seriesof Using the Terminal.)
Command Line
Quick Reference
TOP 10 COMMANDS
‘These may not be the most common commands used by everyone but they will certainly Feature Frequently for many users of
Linux and the command line.
‘The ed command is one of the commands you
will use the most at the command line in Linux. t
allows you to change your working directory. You
seit to move around within the hierarchy of your
filesystem. You can also use chair.
The 1s command shows you the files in your
current directory, Used with certain options it ets
you ee file sizes, when Files where created and file
permissions. For example, 1s ~shows you the files
that ae in your home directory,
The cp commandis used to make copies of files
and directories. For example, cp file sub makes
an exact copy of the file whose name you entered
and names the copy sub but the ist ile wil tl
exist with ts orginal name.
The pad command prints the Full pathname of
the current working directory (pwd stands For
“print working directory’). Note thatthe GNOME
terminal also displays this information in the ttle
bar ofits window.
‘The clear command clears your screen if this
's possible. t looks the environment forthe
terminal type and then in the terminfo database
to figure out how to clear the screen. This is
equivalent to typing Control when using the
bash shell
‘Themy command moves a file toa different
location or renames file. For example my file
sub renames the original fle to sub. mv sub
~/Desktop moves the file'sub' to your desktop
directory but does not rename it. You must specify
‘anew filename to rename afi.
‘The chown command changes the user and/
‘or group ownership of each given file. IFonly an
‘owner (auser name or numeric user IO) s given,
that users made the owner of each given file, and
the files’ group isnot changed.
The chmod command changes the permissions on
the files sted, Permissions are based on a fairly
simple model. You can set permissions For user,
‘group and world and you can set whether each can
read, write and or execute thet
‘The rm command removes (deletes) files or
directories. The removal process unlink aflename
ina filesystem from data on the storage device
‘and marks that space as usable by Future writes n
‘other words, removing files increases the amount
of available space on your disk
Short for ‘make directory”, mkdir is used to
‘reate directories ona ile system, ifthe specified
directory does not already exist. For example,
mnkdirr work creates a work directory. More than
‘one directory may be specified when calling mkUSEFUL HELP/INFO COMMANDS
The following commands are useful for when,
yyou are trying to learn more about the system or
program you are working with in Linux. You might.
not need them every day, but when you do, they
willbe invaluable
‘The Free command displays the total amount
‘of free and used physical and swap memory in
the system. For example, free -mgives the
information using megabytes.
free
The dt command dspays filesystem disk space
«usage forall partitions. The command df-h
GF isprobably the most useful the-h means
human-readable).
The top program provides a dynamic realtime
view oF a cunning system, te can display
system summary information, as well asa list
of processes
top
‘The uname command with the -o option prints
allsystem information, Including machine name,
kernel name, version and a few other details.
unmame-a
The ps command allows you to view all the
[processes running on the machine, Every
Ps ‘operating system's version of ps is slightly
different butaall do the same thing
‘The grep command allows you to search inside a
‘number of files for a particular search pattern and
grep
then print matching ines. An example would be:
grep blah file
wn bmpublcationscom
Command Line Quick Reference (/¥
‘The sed command opens stream editor.
‘A stream editors vsed to perform text
transformations on an input stream: afile or input
From a pipeline.
sed
The adduser command adds a new user to the
system, Similarly, the addgroup command adds a
new group tothe system,
adduser
‘The deLuser command removes a user from
the system. To remove the user's files and
home directory, you need to add the -renove
deluser
home option.
The del group command removes a group From
the system. You cannot remove a group thats the
delgroup
primary group of any users
Theman man command brings up the manual
man man. entry forthe man command, whichis 2 great place
tostart when using it
‘Theman intro command is especially useful.
I-displaythe introduction to User Commands,
man intro
‘which isa well written, fairly brief introduction to
the Linux command line.
flackOog Tech Series-2nastion (87of Using the Terminal)
A-Z of Linux Commands
A
‘adduser
arch
nk
B
be
GC
cat
chdir
charp
chroot
ccksum
@
crontab
csplit
cut
D
date
de
‘Add anew user
Print machine architecture
Find and replace text
within Files)
‘An arbitrary precision
calculator language
Concatenate files and print
con the standard output
‘Change working directory
‘change the group
ownership of files
Change root directory
Print CRC checksum and
byte counts
Compare two files
Compare two sorted files
tne by tine
Copy one or more files to
another location
‘Schedule a command to
runatalater time
‘Split afile into context.
determined pieces
Divide a fieinto
several parts
Display or change the
date & time
Desk calculator
da
diff
dirname
du
E
echo
ed
earep
env
expand
expr
F
factor
fdisk
farep
find
fit
fold
format
fsck
Data Dump, convert and
copyatile
Display the differences
between two files
Convert a full path name
tojusta path
Estimate file space usage
Display message on screen
Aline oriented text editor
(edn)
Search file(s forlines
that match an
extended expression
Display, set orremove
environment variables
Convert tabs to spaces
Evaluate expressions
Print prime Factors
Partition table
‘manipulator for Linux
Search ile) for lines that
match fixed string
Search for files that meet
adesired citeria
Reformat paragraph text
Wrap text to fita
specified width
Format disks or tapes
Filesystem consistency
check and repair
gawk
arep
‘groups
gzip
head
hostname
id
info
install
J
join
K
kilt
EE
less.
in
Locate
Find and Replace text
within Files)
Searchles for tines that
‘match a given pattern
Print group names a user
Compress or decompress
framed file(s)
Cutputthe First part
of Files)
Print or set system name
Print user and group ids
Help info
Copy files and
set attributes
Jointines ona
‘common field
Stop a process
from running
Display output one screen
atatime
‘Make links between files
Find filesA-Z of Linux Commands é YY
ognane Print currentloginname rep Copy files between U
two machines
ipe Line printer
control program rm Remove files ee aie Unni 8 cevice
ipr Offline print rmdir Remove Folders) ener ioe
Iprm Removejobs fromthe rpm Remote Package manager. UNA Uotaoiy Me
print queue ata RB aecay units Convert units rom ane
(synchronise file trees) sce nano
M tinghar’ "Unpack shel archive scripts
oa tigre S useradd Greate ew user account
mkdir Create new folder(s) screen Terminal window manager _ ¥S®! Macy usar aocaunt
nikffo —“MalerrOs(necpnes) aiff Mersetuofiesnacey USES SL UrScurenty
iknod ‘Make biockorcharacter” Select Accept keyboard input
pores seq Brntoumeriseavences J
more Dispay output one screen Se
atatime EAE SOSA gece Verbosely ist directory
end routines sleep Delay fora specified time contents (151-0)
sort Sot tet ies
N split Spit fle into WwW
Fiedsie pieces
watch Execute or display a
nies Settheptontyofs Subsite wserideniy program peridialy
= ee sun Brine achecisum fora file | we Print byte, word, and
write files symlink Make @ new name for ee
afie whereis Report all knovin
nh” funacommandimmne ner Aen Ao
eohanguns syne Sinchronze data on disk
wth memory which Locate a program fein
the user's path
P T who Print all usernames:
passwd Modify user password currently logged in
iste” ergelnes cffes” #8 Sencatenateandwike ea” inthe ae ti
and name
pathchk Chedktienomeporabity Gai aca aca
pr Convert textes of fle
frog i Tes oar X
printcap Prntercapablity database 4 aaa xargs Execute utility, passing
printenv Print environment variables multiple fites Spnstricted sapene ei.
printf Formatandprintdata test Eialuatea
condtionatexpresion
tine ‘Measure Program yes Print sting
Resource Use nélinterrupted
quota Display disk usage touch Change fie timestamps
aie ‘top List processes running on
‘@iitacheck Scan filesystem for the system
diskusage
traceroute Trace Route to Host
quotacti “set disk quotas
vmnbdnetoncam suaoesiteseier-insesin GENtees
rere)
creer)
NASA Linuxpowered
eer
a Bngubcab0%S comPY ndex )
=~
= Guido van Rossum (Developer of the Python
programming language) —
’
BlackDop MTech eres ~2nd Eatonwn dmpublcationscom
Python isa fantastic programming
language, combining ease of use with
a generous helping of power to allow
the user to create both minor utilities or
performance-heavy computational tasks.
However, there’s more to Python than
simply being another programming
language. thas vibrant and lively
community behind it that shares
knowledge, code and project ideas, as
wellas bug Fixes For Future releases.
We've used a Raspberry Pi for this section
of the book, as it’s Linux based and one of
the best coding platforms available. The
Pi's Features and Functions make it the
perfect Python programming partner, so
let's get started.
88 WhyPython?
90 How to Set Up Python in Linux
92 Starting Python for the First Time
94 Your First Code
96 Saving and Executing Your Code
98 Executing Code fromthe Terminal
100 Did You Know...Space Invaders
102 Numbers and Expressions
104 Using Comments
106 Working with Variables
108 User Input
110 Creating Functions
112 Conditions and Loops
114 Python Modules
116 Did YouKnow...Debugging
Y
=Why Python?
There are many different programming languages available for the modern computer,
Pause oR Cacrhhaiseduticterescutadae sd chet
are designed For scientific work, others For mobile platforms and such. So why choose
farereuketaeieltees
PYTHON POWER
Ever since the earliest home computers were available, enthusiasts, users and professionals have toiled away until the wee
hours, slaving over an overheating heap of circuitry to create something al
‘These pioneers of programming carved their way into a new
Frontier, Forging small routines that enabled the letter’ to scroll
‘across the screen It may not sound terribly exciting to a generation
{that’s used to ultra high-definition graphics and open world, mut
player online gaming, However, Forty-something years ago it was
biindinaly brillant.
[Naturally these bedroom coders helped form the Foundations for,
‘every piece of digital technology we use today. Some went on to
become chief developers for top software companies, whereas
‘others pushed the available hardware to its imits and Founded the
billion pound gaming empire that continually amazes us.
to magi
Regardless of whether you use an Android device, iOS device, PC,
Mac, Linux, Smart TV, games console, MP3 player, GPS device builtin
to car, settop box ora thousand other connected and smart’
appliances, behind them alis programming.
‘Allthose aforementioned distal devices need instructionsto tell.
them what to do, and allow them to be interacted with, These
instructions form the programming core ofthe device and that core
‘canbe built using a variety of programming languages.
‘The languages in use today differ depending an the situation, the
platform, the device's use and how the device wil interact with ts
The [per Wax winder
(i i Ham Roms OAS Gen tot te
Xe [ot = [wenaoeey] @|S/G Hse # > 7@
Sxtcursor(p-y)z
Sareea
vod arraycert::chitdLostrocu()
sf eurgor a= 0)
repost cureor
cxrtirehstalastfocus(}!
Finca” [Ghaterwnae || void _arrayctrt::peinttorave w) ¢
Stoner Sms ‘cintnet Paine
fSuweiee — Siavso cersize()
fSecsace | omcimacan a
Eanes Gaetano
Ssnanace ew
Freres Bern
Siewraes | Strce
wen | Srance se
JS rrclops & e
Rewoun. Grr vertgrid's {je = colum.cetcoune() - 1)) > 0)
Eicon mes
Seencs Camas
Stamens piace )
[Sowa ran Exton fe = elend(scoloraisabled, Scoloreapa
Soca,” (raat Eat
Sse Brew Mast catcaunt()) (
Same Brews Titop Sestciner) = sb
eset Agee Lites staecey) reeks
gemece, [Smeans {bottom = ep ntingoyi:
a sera |8 ose Ties coumamcneds i) (
a0 eee by header cetvabindth(3)3
ecarmich | |Gchewrne nen = columi5 is nergis ui
Hf reves brie A et = header Tab )) .cethargin);
Greene hoa 6G sizeren) bresey ern
Scone se te
Bierioen Grasse EIRhCSL + ox = vetorid 6 (1 a eolum.catcauntt) = 12
ET) 2: ocean ationenvironment or users. Operating systems, such as Windows, macOS
{and such are usually a combination of C++, C#, assembly and some
Form of visual-based language. Games generally use C++ whilst web
pages can use a plethora of avalable languages such as HTML, Java,
Python and so on,
‘More general-purpose programming is used to create programs,
apps, software or whatever else you want to cll them. They/re
widely used across all hardware platforms and sult virtually every
conceivable application. Some operate faster than others and some
are easier to lear and use than others. Python is one such general
purpose language.
Python is what's known as a High-Level Language, in that it ‘talks’
to the hardware and operating system using a variety of arrays,
variables, objects, arthmetic, subroutines loops and countless
‘more interactions. Whilst i's not as streamlined asa Low-Level
Language, which can deal directly with memory addresses, cal
stacks and registers, its benefits that it's universally accessible
{and easy to learn,
/FiTe? val
[spore java. lang. reFlect.*;
Jiass rnvoke {
mae ete void main( string [] args ) {
lass c = Class. forvane( args(0] ):
fathog'n =‘Cigethechodt argSil), tex class
TC} 5
Sbjeck hit = minyokeC null, mull >;
Systen.out.princinc
Sejvoked)stacte method: * + argsL]
oof class: © + args(Ol
3 with no args\nresules: " + ret);
catch ¢ ClassnotFoundexception e ) {
77 Class: fornane(.-) can‘e. find the class
Caxeh’ C wosuchwethodexception e2") {
77 that method doesn't exist,
Gaveh ( Tllepalaccesstxception 3 ) {
77-we don't have permission to invoke that
inethod
} Catch C tnvocationtargetexception e4 ) {
77'an exception ocurred while invoking that
inethod bi
System.out.princin
yeeStethod threw an: " + ef
getTargetexception( ")");
Javaisa powerful
language that's used in
‘web pages, settop boxes,
‘TWsand even cas.
wn bdmpublcationscom
-
(why Python? GH
Python was created over twenty six yeas ago and has evolved to
become an ideal beginner's language for learning how to programa
‘computer. Is perfect for the hobbyist, enthusiast, student, teacher
‘and those who simply need to create their own unique interaction
between either themselves or a piece of external hardware and the
‘computeritself,
Python i free to download, install and use and i avallable or Linux,
‘windows, macOS, MS:DOS, 05/2, 80S, IBM iseries machines, and
‘even RISCOS. Ithas been vated one of the tap five programming
languages in the warld andis continually evolving ahead of the
hardware and Internet development curve.
‘So to answer the question: why python? Simply put, it's Free, easy to
lear, exceptionally powerful, universally accepted, effective and a|
superb learning and educational tool.
BASIC was once the starter language that early
‘&-bit home computer users learned.
Python isa more modern take on BASIC, i's easy to learn
and makes for an ideal beginner's programming language.
duck one ndn









