100% found this document useful (1 vote)
42 views25 pages

Practical Linux With Raspberry Pi OS: Quick Start 1st Edition Ashwin Pajankar All Chapter Instant Download

ebook

Uploaded by

fjorelfaloye
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
42 views25 pages

Practical Linux With Raspberry Pi OS: Quick Start 1st Edition Ashwin Pajankar All Chapter Instant Download

ebook

Uploaded by

fjorelfaloye
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Full download ebooks at https://ebookmeta.

com

Practical Linux with Raspberry Pi OS: Quick


Start 1st Edition Ashwin Pajankar

For dowload this book click link below


https://ebookmeta.com/product/practical-linux-with-
raspberry-pi-os-quick-start-1st-edition-ashwin-pajankar/

OR CLICK BUTTON

DOWLOAD NOW
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

Instant Raspberry Pi The Beginner s Guide to Raspberry


Pi setup 1st Edition Ashwin Pajankar

https://ebookmeta.com/product/instant-raspberry-pi-the-beginner-
s-guide-to-raspberry-pi-setup-1st-edition-ashwin-pajankar/

Raspberry Pi Image Processing Programming: With NumPy,


SciPy, Matplotlib and OpenCV, 2nd Edition Ashwin
Pajankar

https://ebookmeta.com/product/raspberry-pi-image-processing-
programming-with-numpy-scipy-matplotlib-and-opencv-2nd-edition-
ashwin-pajankar-2/

Raspberry Pi Image Processing Programming: With NumPy,


SciPy, Matplotlib, and OpenCV 2nd Edition Ashwin
Pajankar

https://ebookmeta.com/product/raspberry-pi-image-processing-
programming-with-numpy-scipy-matplotlib-and-opencv-2nd-edition-
ashwin-pajankar/

Raspberry Pi Image Processing Programming: Develop


Real-Life Examples with Python, Pillow, and SciPy 1st
Edition Ashwin Pajankar

https://ebookmeta.com/product/raspberry-pi-image-processing-
programming-develop-real-life-examples-with-python-pillow-and-
scipy-1st-edition-ashwin-pajankar/
Raspberry Pi OS System Administration with systemd A
Practical Approach 1st Edition Robert M. Koretsky

https://ebookmeta.com/product/raspberry-pi-os-system-
administration-with-systemd-a-practical-approach-1st-edition-
robert-m-koretsky/

Running ESXi on a Raspberry Pi Installing VMware ESXi


on Raspberry Pi 4 to run Linux virtual machines Thomas
Fenton

https://ebookmeta.com/product/running-esxi-on-a-raspberry-pi-
installing-vmware-esxi-on-raspberry-pi-4-to-run-linux-virtual-
machines-thomas-fenton/

Running ESXi on a Raspberry Pi: Installing VMware ESXi


on Raspberry Pi 4 to run Linux virtual machines 1st
Edition Thomas Fenton

https://ebookmeta.com/product/running-esxi-on-a-raspberry-pi-
installing-vmware-esxi-on-raspberry-pi-4-to-run-linux-virtual-
machines-1st-edition-thomas-fenton/

Hands-on Matplotlib: Learn Plotting and Visualizations


with Python 3 Ashwin Pajankar

https://ebookmeta.com/product/hands-on-matplotlib-learn-plotting-
and-visualizations-with-python-3-ashwin-pajankar/

Retro Gaming with Raspberry Pi 2nd Edition

https://ebookmeta.com/product/retro-gaming-with-raspberry-pi-2nd-
edition/
Ashwin Pajankar

Practical Linux with Raspberry Pi OS


Quick Start
1st ed.
Ashwin Pajankar
Nashik, Maharashtra, India

Any source code or other supplementary material referenced by the


author in this book is available to readers on GitHub via the book’s
product page, located at www.​apress.​com/​978-1-4842-6509-3. For
more detailed information, please visit http://​www.​apress.​com/​
source-code.

ISBN 978-1-4842-6509-3 e-ISBN 978-1-4842-6510-9


https://doi.org/10.1007/978-1-4842-6510-9

Apress Standard
© Ashwin Pajankar 2021

This work is subject to copyright. All rights are solely and exclusively
licensed by the Publisher, whether the whole or part of the material is
concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in
any other physical way, and transmission or information storage and
retrieval, electronic adaptation, computer software, or by similar or
dissimilar methodology now known or hereafter developed.

The use of general descriptive names, registered names, trademarks,


service marks, etc. in this publication does not imply, even in the
absence of a specific statement, that such names are exempt from the
relevant protective laws and regulations and therefore free for general
use.

The publisher, the authors and the editors are safe to assume that the
advice and information in this book are believed to be true and accurate
at the date of publication. Neither the publisher nor the authors or the
editors give a warranty, expressed or implied, with respect to the
material contained herein or for any errors or omissions that may have
been made. The publisher remains neutral with regard to jurisdictional
claims in published maps and institutional affiliations.

Distributed to the book trade worldwide by Springer Science+Business


Media New York, 1 NY Plaza, New York, NY 10014. Phone 1-800-
SPRINGER, fax (201) 348-4505, e-mail [email protected],
or visit www.springeronline.com. Apress Media, LLC is a California LLC
and the sole member (owner) is Springer Science + Business Media
Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware
corporation.
I dedicate this book to Subrahmanyan Chandrasekhar, a great Indian-
American astrophysicist.
Introduction
I have been working with Raspberry Pi since 2014. I was introduced to
it while volunteering as an organizer at a hackathon at my former
workplace. And as I have mentioned in my author biography, I have
decent experience with assembly programming, microcontrollers, and
digital electronics since my time as an undergraduate student of
computer science. Raspberry Pi and Arduino are great choices for
someone who wants the best of both of the worlds of computer science
and electronics. Additionally, if you wish to use Linux, C, Python, and
shell programming to drive your motors, LEDs, and other peripherals,
then Raspberry Pi and similar single-board computers are the best fit
for your applications.
While this is an introductory book for beginners who are new to the
world of SBCs and hardware hacking, once you follow the book in
detail, you will be very much comfortable exploring the world of SBCs
and Raspberry Pi on your own.
This entire book is based on the challenges and struggles I faced
while working the very first time with Raspberry Pi (abbreviated as RPi
hereafter). I have listed all the tips and tricks I learned while exploring
the RPi in the first few months. At that time, I really wished that I could
get a book that would make my journey easier and so decided to write
one myself. So, when the opportunity presented itself, I compiled all my
experiences in this book so that anyone looking for help to get started
with Raspberry Pi can benefit from this.
While this book primarily covers the RPi OS flavor of Linux, I have
made sure that I also introduce the readers to other important topics,
such as programming with high-level languages like C, C++, and Python.
I also introduce readers to GPIO (General-Purpose Input/Output)
programming and various buses. Finally, I cover installation of a few
popular Linux desktop environments such as XFCE, LXDE, and KDE
Plasma. The appendix covers a few additional tips and tricks.
I hope that the book serves the readers well and they will enjoy the
book as much as I enjoyed writing it.
Acknowledgments
I am thankful to Mr. Massimo Nardone, the technical reviewer of the
book. I want to express my gratitude toward him for helping me make
this book better. I would also like to express my gratitude to the Apress
team. Aaron Black helped with the coordination of the entire book
process, and Jessica Vakili guided the editorial process. James Markham
helped me with the editorial review. I am also thankful to Celestin
Suresh and Aditee Mirashi for giving me an opportunity to write this
book.
Table of Contents
Chapter 1:​Introduction to Raspberry Pi
Single-Board Computers
Raspberry Pi
Linux and Distributions
Raspberry Pi OS
Raspberry Pi OS Setup
Preparing the SD Card Manually
Booting Up the Pi Board for the First Time
Configuring the RPi Board
Connecting Various RPi Board Models to the Internet
Summary
Chapter 2:​Getting Ready
Operating System Shell
Raspberry Pi OS GUI
The Command Prompt
Updating the RPi OS
Linux Filesystem
Remotely Accessing the RPi
Summary
Chapter 3:​Directory Commands and Text Editors
Absolute and Relative Paths
Commands:​pwd, tree, and cd
Command:​ls
Command:​touch
Various Text Editors
Create and Delete Directories
Case-Sensitive Names of Directories and Files
Summary
Chapter 4:​More Commands
Configuring the RPi Board
What Is sudo?​
Getting Help on Commands
Network-Related Commands
Commands:​File Operations
Printing a String
Control Operators
Filename Globbing
Command:​History
Pipes
Summary
Chapter 5:​Useful Unix Commands and Tools
Shell and Environment Variables
Useful Linux Commands
Useful Unix Tools
Summary
Chapter 6:​Shell Scripting
Unix File Permissions
Command:​nohup
Beginning Shell Scripting
User Input
Expressions in the Shell
If Statement
Switch Case
Length of a Shell Variable
Command-Line Arguments
Function
Loops in the Shell
Comparing Strings
File Operations
Summary
Chapter 7:​I/​O Redirection and Cron
I/​O Redirection
stdin
stdout
Stderr
Crontab
Summary
Chapter 8:​Introduction to High-Level Programming Languages
C and C++ Programming
Python Programming Language
History of the Python Programming Language
Python Enhancement Proposals
Applications of Python
Python 3 on Debian Derivatives
Python Modes
Interactive Mode
Script Mode
Summary
Chapter 9:​Programming with RPi GPIO
General-Purpose Input/​Output Pins
Programming with GPIO
Summary
Chapter 10:​Explore the RPi OS GUI
GUI Utilities on the RPi OS
Other Desktop Environments
XFCE
KDE Plasma
Summary
Appendix:​Additional Tools
Raspberry Pi Imager
Additional Utilities
Manjaro Linux
FreeBSD
Additional OSs
Index
About the Author
Ashwin Pajankar
holds a Master of Technology from IIIT Hyderabad. He started
programming and tinkering with electronics at the tender age of 7.
BASIC (Beginners’ All-Purpose Symbolic Instruction Code) was the first
programming language he worked with. He was gradually exposed to C
programming, 8085, and x86 assembly programming during his higher
secondary schooling. He is proficient in x86 assembly, C, C++, Java,
Python, and Linux shell programming. He is also proficient with
Raspberry Pi, Arduino, BBC Micro Bit, and other single-board
computers (SBCs) and microcontrollers. Ashwin is passionate about
training and mentoring. He has trained more than 100,000 trainees and
professionals through live training sessions and online training courses.
He has published more than a dozen books with both international and
Indian publishers. He has also reviewed numerous books and
educational video courses. This is his sixth book with Apress, and he is
working on more books. He regularly conducts programming boot
camps and hands-on training for software companies in Nashik, India.
He is also an avid YouTuber with more than 10,000 subscribers to
his channel. You can find him on LinkedIn.
About the Technical Reviewer
Massimo Nardone
has more than 22 years of experiences in security, web/mobile
development, the cloud, and IT architecture. His true IT passions are
security and Android.
He has been programming and teaching how to program with
Android, Perl, PHP, Java, VB, Python, C/C++, and MySQL for more than
20 years.
He holds a Master of Science in Computing Science from the
University of Salerno, Italy.
He has worked as a project manager, software engineer, research
engineer, chief security architect, information security manager,
PCI/SCADA auditor, and senior lead IT security/cloud/SCADA architect
for many years.
© Ashwin Pajankar 2021
A. Pajankar, Practical Linux with Raspberry Pi OS
https://doi.org/10.1007/978-1-4842-6510-9_1

1. Introduction to Raspberry Pi
Ashwin Pajankar1
(1) Nashik, Maharashtra, India

I hope you have gone through the Table of Contents and Introduction. If
not, I highly recommend you go through them. This is the very first
chapter of the book, and I welcome you all to the exciting journey of
learning Linux with the Raspberry Pi Operating System.
In this chapter, we will learn the details about the most popular
platform and single-board computer family of our times, the Raspberry Pi.
Then we will learn a bit about Linux and the distribution of Linux that is
popularly used with the Raspberry Pi family (hereafter, I will use the
abbreviation RPi), the Raspberry Pi Operating System. We will learn how
to install it on a RPi board. The following is the list of the topics that we
will learn in this chapter:
Single-board computers
Raspberry Pi
Linux and distributions
Raspberry Pi OS setup
Configuring the RPi board
Connecting various RPi board models to the Internet
After completing this chapter, we will be comfortable with the
installation and the basic usage of the RPi board and the RPi OS.

Single-Board Computers
Single-board computers (also known as SBCs) have all the components of
a fully functioning computer like the processor, GPU, RAM, and I/O on a
single printed circuit board. This is in contrast with desktop or laptop
computers that have a motherboard which has various slots for RAM, the
processor, and the graphics card. Desktop or laptop computers can be
upgraded by replacing processors and graphics cards. We can also add
more RAM chips in the RAM slots. However, SBCs cannot be upgraded like
that. This is one of the major differences between traditional
desktops/laptops that are totally modular and SBCs. The key benefit of
the lack of modularity of SBCs is that the size of an entire computer is
very small. Most of the SBCs are a little bigger than a regular credit/debit
card, and they are very compact.
SBCs are used as technology demonstrators (prototypes), educational
computers, and embedded systems. There is a recent surge in the
popularity of SBCs due to advances in the fabrication process and
manufacturing technologies. We are living in an era where a new SBC or a
new version of an existing one is announced almost on a monthly basis.
The market is full of various SBCs and SBC families. A few prominent SBC
families are Raspberry Pi, Banana Pro, BeagleBoards, and Orange Pi.
Raspberry Pi is the most popular family of single-board computers
available in the market, and it is one of the best-selling computers in the
world. In the next section, we will have an overview of the Raspberry Pi
family of computers.

Raspberry Pi
Raspberry Pi is a family of SBCs developed by the Raspberry Pi
Foundation (www.raspberrypi.org/). It consists of many board
models, and all the current models under production are listed on the
foundation’s products page (www.raspberrypi.org/products/).
Throughout the book, I will be using a Raspberry Pi 4 Model B (the latest
board model in the family) with 4 GB RAM.
Table 1-1 lists the specifications of the Raspberry Pi 4 Model B.
Table 1-1 Technical Specifications of Raspberry Pi 4 B

Component Specification
Processor Broadcom BCM2711, quad-core Cortex-A72 (ARM v8) 64-bit
SoC at 1.5 GHz
RAM LPDDR4-3200 SDRAM (2 GB or 4 GB or 8 GB)
Another random document with
no related content on Scribd:
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project Gutenberg™


electronic work or group of works on different terms than are set
forth in this agreement, you must obtain permission in writing from
the Project Gutenberg Literary Archive Foundation, the manager of
the Project Gutenberg™ trademark. Contact the Foundation as set
forth in Section 3 below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on, transcribe
and proofread works not protected by U.S. copyright law in creating
the Project Gutenberg™ collection. Despite these efforts, Project
Gutenberg™ electronic works, and the medium on which they may
be stored, may contain “Defects,” such as, but not limited to,
incomplete, inaccurate or corrupt data, transcription errors, a
copyright or other intellectual property infringement, a defective or
damaged disk or other medium, a computer virus, or computer
codes that damage or cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for


the “Right of Replacement or Refund” described in paragraph 1.F.3,
the Project Gutenberg Literary Archive Foundation, the owner of the
Project Gutenberg™ trademark, and any other party distributing a
Project Gutenberg™ electronic work under this agreement, disclaim
all liability to you for damages, costs and expenses, including legal
fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR
NEGLIGENCE, STRICT LIABILITY, BREACH OF WARRANTY OR
BREACH OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE TRADEMARK
OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL
NOT BE LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE OR INCIDENTAL DAMAGES EVEN IF
YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of receiving
it, you can receive a refund of the money (if any) you paid for it by
sending a written explanation to the person you received the work
from. If you received the work on a physical medium, you must
return the medium with your written explanation. The person or
entity that provided you with the defective work may elect to provide
a replacement copy in lieu of a refund. If you received the work
electronically, the person or entity providing it to you may choose to
give you a second opportunity to receive the work electronically in
lieu of a refund. If the second copy is also defective, you may
demand a refund in writing without further opportunities to fix the
problem.

1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted
by the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation,


the trademark owner, any agent or employee of the Foundation,
anyone providing copies of Project Gutenberg™ electronic works in
accordance with this agreement, and any volunteers associated with
the production, promotion and distribution of Project Gutenberg™
electronic works, harmless from all liability, costs and expenses,
including legal fees, that arise directly or indirectly from any of the
following which you do or cause to occur: (a) distribution of this or
any Project Gutenberg™ work, (b) alteration, modification, or
additions or deletions to any Project Gutenberg™ work, and (c) any
Defect you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new computers.
It exists because of the efforts of hundreds of volunteers and
donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project Gutenberg™’s
goals and ensuring that the Project Gutenberg™ collection will
remain freely available for generations to come. In 2001, the Project
Gutenberg Literary Archive Foundation was created to provide a
secure and permanent future for Project Gutenberg™ and future
generations. To learn more about the Project Gutenberg Literary
Archive Foundation and how your efforts and donations can help,
see Sections 3 and 4 and the Foundation information page at
www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation’s EIN or federal tax identification
number is 64-6221541. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state’s laws.

The Foundation’s business office is located at 809 North 1500 West,


Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up
to date contact information can be found at the Foundation’s website
and official page at www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can
be freely distributed in machine-readable form accessible by the
widest array of equipment including outdated equipment. Many
small donations ($1 to $5,000) are particularly important to
maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws regulating


charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and
keep up with these requirements. We do not solicit donations in
locations where we have not received written confirmation of
compliance. To SEND DONATIONS or determine the status of
compliance for any particular state visit www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states where


we have not met the solicitation requirements, we know of no
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot make


any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.

Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.
Project Gutenberg™ eBooks are often created from several printed
editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.

You might also like