Raspberry Pi_Eng_00.2 Table Of Contents



Published Book on Amazon


All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 1
All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 2

출판된 한글판 도서


최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (상)
최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (하)

Original Book Contents



Table of Contents

 

Preface            1

1.      Up to the Point of Writing This Book. 2

2.      Overall Composition of This Book. 4

3.      What This Book Covers 5

4.      Level of Content Covered in This Book. 7

5.      Conventions Used in This Book. 8

Chapter 1    Overview of Raspberry Pi 29

1.1    Overview.. 30

1.1.1   Birth of the Raspberry Pi 30

1.1.2   Development History of the Raspberry Pi 32

1.2    Features of the Raspberry Pi 33

Chapter 2    Hardware of Raspberry Pi 36

2.1    Hardware Configuration of Raspberry Pi 37

2.1.1   Basic configuration of Raspberry Pi 37

2.1.2   Characteristics Comparison of Raspberry Pi Model 39

2.2    SoC, CPU and Memory. 41

2.3    SD Card Slot 43

2.4    Power Supply. 44

2.4.1   Micro USB Power Supply Port 44

2.4.2   Current Consumption by Device. 45

2.5    Video and Audio Devices 46

2.5.1   HDMI Video Port 46

2.5.2   CSI Camera Interface. 46

2.5.3   DSI Display Port 47

2.5.4   3.5mm Audio Jack and Composite Video. 47

2.6    USB port 48

2.6.1   USB Port by Model 48

2.6.2   Power Constraints of USB Port 48

2.7    Network Device. 49

2.7.1   Ethernet Port 49

2.7.2   Wi-Fi Device. 49

2.7.3   Bluetooth Device. 50

2.8    GPIO.. 51

Chapter 3    Buying & Installing Device/Part 52

3.1    Selection of Raspberry Pi Model 53

3.2    Body Case. 55

3.3    Heat Sink. 56

3.4    Storage Device. 57

3.4.1   SD Card. 57

3.4.2   External Mass Storage Device. 58

3.5    Power Adapter and Power Supply Cable. 59

3.6    Network Device. 60

3.6.1   WAN Connection Device, LAN Hub and Router 60

3.6.2   LAN Cable. 61

3.6.3   WI-FI Adapter 62

3.6.4   Bluetooth Adapter 63

3.7    Input Device. 64

3.7.1   Keyboard. 64

3.7.2   Mouse. 65

3.8    Video Output 66

3.8.1   HDMI Cable and HDMI Supporting Monitor 66

3.8.2   TFT-LCD.. 69

3.9    Camera. 70

3.9.1   USB Camera. 70

3.9.2   Camera Supporting CSI Port 72

3.9.3   Raspberry Pi Dedicated Camera. 72

3.9.3.1   Visible-Light Camera. 72

3.9.3.2   Infrared Camera. 73

3.9.3.3   Installing Raspberry Pi Dedicated Camera H/W... 74

3.10   External Interface. 76

Chapter 4    Installing Operating System.. 78

4.1    Types of Operating System.. 79

4.1.1   List for Installable Operating Systems. 79

4.1.2   Reviewing Major Operating Systems. 80

4.1.2.1   Linux Related Operation Systems. 80

4.1.2.2   Other Operating Systems. 84

4.2    Overview of Installing Operating System.. 85

4.2.1   Installation Method of Operating System... 85

4.2.2   About Installing Multiple Operating Systems. 86

4.3    Preparing an SD Card. 88

4.3.1   Formatting the SD Card. 88

4.3.2   <NOOBS> Utility and Formatting SD Card. 90

4.4    Downloading and Preparing the Installation File. 92

4.4.1   Downloading from Raspberry Pi Homepage. 92

4.4.2   Downloading from Other Soruces. 93

4.5    Installation Using <NOOBS> Utility. 94

4.5.1   Overview of <NOOBS> Utility. 94

4.5.2   Downloading and Preparing <NOOBS> Utility Program... 95

4.5.2.1   Downloading <NOOBS> Utility Program... 95

4.5.2.2   Copying the <NOOBS> Utility File on SD Card. 95

4.5.2.3   Preparing Hardware System and Internet Access. 96

4.5.3   Function of <NOOBS> Utility. 97

4.5.3.1   Starting <NOOBS> Utility. 97

4.5.3.2   Rainbow Color Screen of <NOOBS> Utility. 97

4.5.3.3   Booting Screen of <NOOBS> Utility. 97

4.5.3.4   Installation Screen of <NOOBS> Utility. 98

4.5.3.5   Function of Button on <NOOBS> Utility Screen. 99

4.5.3.6   What If <NOOBS> Utility Screen is invisible. 100

4.5.4   Installing OS Using <NOOBS>Utility. 102

4.5.4.1   Selection of Operating System and Progress. 102

4.5.4.2   Installing Multiple OS Using <NOOBS> Utility. 104

4.5.5   Utilizing <NOOBS> Utility after Installing OS. 105

4.5.5.1   <NOOBS> Utility Booting Screen. 105

4.5.5.2   Booting Operation System Installed. 106

4.5.5.3   Recovery Mode of <NOOBS> Utility. 106

4.6    Installation Using Operating System Image. 109

4.6.1   Downloading and Preparing Operation System Image File. 109

4.6.2   Copying Image File to SD Card. 110

4.6.3   Operating Operating System Installed. 112

Chapter 5    System Startup and Shutdown. 113

5.1    System Booting. 114

5.1.1   Meaning of Booting. 114

5.1.2   Selection of Booting Operation System... 114

5.1.3   Booting Procedure. 116

5.1.4   What If Screen is Invisible at Booting. 118

5.2    System Logon. 119

5.2.1   Meaning of Logon. 119

5.2.2   Default User Account "pi" 119

5.2.3   Logon Processing. 120

5.3    Sysetm Logout 121

5.3.1   Meaning of Logout 121

5.3.2   Logout Processing. 122

5.4    System Termination. 123

5.4.1   How to Terminate the System... 123

5.4.2   "shutdown" Command. 124

5.4.3   "halt" Command. 125

5.4.4   "reboot" Command. 126

Chapter 6    System Connection & Termination. 127

6.1    Overview of System Connection. 128

6.1.1   Basic Diagram of Sysem Configuration. 128

6.1.2   Overview of System Connection. 130

6.1.2.1   Console and Terminal Concept 130

6.1.2.2   Terminal Connection and Desktop GUI connection. 132

6.1.2.3   Local Connection and Remote Connection. 133

6.2    Local Connection. 134

6.2.1   Progress Flow of Terminal at Console. 134

6.2.2   Setting for Local Connection Method. 136

6.2.3   Local Terminal Connection. 137

6.2.3.1   Starting Local Terminal Connection. 137

6.2.3.2   Logging on Terminal and Starting Shell Program... 139

6.2.3.3   Starting Desktop Window from Shell Terminal 141

6.2.4   Local Desktop GUI connection. 144

6.2.4.1   Local Desktop GUI connection and Logon. 144

6.2.4.2   Using Terminal Shell in Desktop Window.. 146

6.3    System Connection and Termination. 147

6.3.1   How to Terminate. 147

6.3.2   System Termination in Terminal 148

6.3.2.1   "shutdown" Command. 148

6.3.2.2   "halt" Command. 150

6.3.2.3   "poweroff" Command. 152

6.3.2.4   "reboot" Command. 154

6.3.2.5   "logout" Command. 156

6.3.3   System Termination on Window.. 157

6.3.3.1   [shutdown] Menu. 159

6.3.3.2   [reboot] Menu. 160

6.3.3.3   [logout] Menu. 161

Chapter 7    Overview of Desktop Window.. 163

7.1    Window Features of Raspbian OS. 164

7.1.1   Why Use Window?. 164

7.1.2   X Windows and LXDE. 166

7.1.3   Differences from Windows of Other Operating System... 167

7.2    Basic structure of Window.. 169

7.2.1   Start Screen of Window.. 169

7.2.2   Configuration of Panel Area. 171

7.2.3   Configuration of Desktop Area. 173

7.3    Detail Structure of Panel (Menu and Taskbar) 175

7.3.1   Configuring Panel 175

7.3.2   Menu (Start Menu) 178

7.3.2.1   Execution of Menu. 178

7.3.2.2   Program List 179

7.3.2.3   Creating an Execution Icon of Program on Desktop. 182

7.3.2.4   Confirming Properties for Program... 184

7.3.3   Application Launch Bar (Start Task) 186

7.3.4   Task Bar (Task Display) 188

7.3.5   Tool 190

7.4    Detail Structure of Desktop Area. 192

7.4.1   Features of Desktop. 192

7.4.2   Setting Desktop Properties. 195

7.4.2.1   Setting Desktop Preference. 195

7.4.2.2   Setting Icon Alignment 197

7.4.3   Creation of Folder and File. 198

7.5    Overview of Key Execution Program.. 200

7.5.1   Accessories. 200

7.5.1.1   File Manager (PCManFm) 200

7.5.1.2   Task Manager (Lxtask) 211

7.5.1.3   Terminal LXTerminal 213

7.5.1.4   Text Editor (Leafpad) 214

7.5.1.5   Archiver (XArchiver) 215

7.5.1.6   Image Viewer (GPicView) 216

7.5.1.7   Calculator (Galculator) 217

7.5.1.8   PDF Viewer (XPDF) 219

7.5.2   Programming Tool 220

7.5.2.1   Mathematica & Wolfram Language. 220

7.5.2.2   Sonic Pi 222

7.5.2.3   Scratch. 223

7.5.2.4   Python. 225

7.5.3   Internet Web Browser (EpicHany) 227

7.5.4   Game. 228

7.5.4.1   Minecraft PI 228

7.5.4.2   Python Games. 230

7.6    Help. 232

7.6.1   Debian Reference. 232

7.6.2   Raspberry Pi Help. 235

7.7    Preference. 236

7.7.1   Mouse and Keyboard Settings. 236

7.7.2   Theme and Appearance Settings. 237

7.7.3   Main Menu Editor 239

7.8    Run. 241

7.9    Shutdown. 244

Chapter 8    Terminal and Shell Program.. 246

8.1    Terminal program.. 247

8.1.1   How to Start Terminal Program... 247

8.1.2   Configuration of Terminal Screen. 250

8.1.3   Working on Terminal Screen. 252

8.2    Shell Program.. 254

8.2.1   Shell and BASH (Bourne Again Shell) 254

8.2.2   Specifying Default Shell Program... 255

Chapter 9    Configuring Raspberry Pi System.. 257

9.1    Overview of System configuration. 258

9.1.1   Meaning of System Configuration. 258

9.1.2   Target items for System setting. 258

9.2    How to Configure the System.. 260

9.2.1   How to Configure Using "raspi-config" Command. 260

9.2.2   How to Configure Using Desktop Window.. 262

9.3    Setting File System Expansion. 264

9.3.1   Meaning. 264

9.3.2   Confiuration Procedure. 264

9.4    Changing Password for Default User "pi". 266

9.4.1   Meaning of Default User Account "pi" 266

9.4.2   Procedure of Changing Password. 266

9.5    Setting Boot Startup Screen. 268

9.5.1   Types of Boot Startup Screen. 268

9.5.2   Configuration Method. 270

9.6    Setting Internationaliation Options 272

9.6.1   Common Menu for Setting Internationalization Options. 272

9.6.2   Setting Locale. 274

9.6.3   Setting Time Zone. 276

9.6.4   Setting Keyboard. 278

9.7    Setting Performance Items 282

9.7.1   Setting Overclock. 283

9.7.2   Adjusting GPU Memory. 285

9.8    Setting Camera and Audio Device. 287

9.8.1   Enabling Raspberry Pi Camera. 288

9.8.2   Adjusting Audio Output 290

9.9    Network Related Setting. 292

9.9.1   Enabling SSH.. 293

9.9.2   Setting Hostname. 295

9.10   Setting Peripherals Interface Device. 297

9.10.1  Setting SPI (Serial Peripheral Interface) 298

9.10.2  Setting I2C (Inter-Integrated Circuit) 300

Chapter 10  Understanding Shell Command. 302

10.1   Command Overview.. 303

10.1.1  Standard Input and Output 303

10.1.2  Special Key of Shell 303

10.1.3  Quoting Rule. 304

10.1.3.1 Overview of Quoting Rule. 304

10.1.3.2 \Escape Sequence. 305

10.1.4  Utilizing Command Execution History. 306

10.1.4.1 Retrieving History by Arrow Keys. 306

10.1.4.2 "history" Command. 308

10.2   Shell Environment 309

10.2.1  Variable. 309

10.2.1.1 What is Variable?. 309

10.2.1.2 Types of Variables. 309

10.2.1.3 Declaring Data Types of Variable. 312

10.2.1.4 "unset" Command - Delete Variable Definition. 313

10.2.1.5 "set" Command - Set Shell Call Parameter 314

10.2.2  Environment Variable. 315

10.2.2.1 "env" Command – Confirm Environment Variable. 315

10.2.2.2 "export" Command – Define Environment Variable. 318

10.2.2.3 Fixing Value of Environment Variable Permanently. 319

10.3   Shell and Profile. 320

10.3.1  Type of Profile. 320

10.3.2  Applied Priority of Profile. 322

10.4   Basic Command. 323

10.4.1  "clear" Command - Clear Screen. 323

10.4.2  "echo" Command. 325

10.4.3  "man" Command - Get Help on Commands. 326

10.4.4  "alias" Command. 328

10.5   Commands Related to Operation. 330

10.5.1  "expr" Command Arithmetic Operation. 330

10.5.2  "test" Command Logical Operation. 332

10.6   Commands Related to Selective Execution. 335

10.6.1  "&&" Command - Execute Command by "and" Method. 335

10.6.2  "||" Command - Execute Command by "or" Method. 336

10.7   Commands Related to Program Execution. 337

10.7.1  "which" Command - Check Path Name of Executable File. 337

10.7.2  ";" Command - Execute Multiple Commands Successively. 339

10.7.3  Executing Program on Background/Foreground. 341

10.7.3.1 "&" Command - Execute on Background. 341

10.7.3.2 "jobs" Command – Check Current Background Job. 343

10.7.3.3 Moving Foreground Job to Background. 344

10.7.3.4 "fg" Command – Switch Back Job to Foreground. 345

10.7.3.5 "bg" Command – Resume Paused Background Job. 347

10.7.3.6 Changing Background Job into Pausing State. 347

10.7.3.7 "kill" Command – Terminate Job. 348

10.7.4  "exit" Command – Terminate Process. 349

10.8   Commands to Adjust Input and Output 353

10.8.1  "xargs" Command. 353

10.8.2  Redirection Command – Change Input and Output Device. 357

10.8.3  | (pipe) Command. 361

10.9   Commands Related to Data Manipulation. 365

10.9.1  "awk" Command. 365

10.9.2  "wc" Command. 371

10.9.3  "sort" Command. 373

10.9.4  "uniq" Command. 375

10.10 Commands Related to System Information. 378

10.10.1                 "date" Command- Confirm & Change Time Information. 378

10.10.2                                         "cal" Command and "ncal" Command. 380

Chapter 11  Network Management 382

11.1   Network Overview.. 383

11.1.1  Network Connection and IP Address. 383

11.1.2  "ifconfig" Command - Verify Network Status & IP Address. 383

11.2   Information for Network Setting. 386

11.2.1  Information for Network Setting. 386

11.2.2  Setting Assignment Method of IP Address. 387

11.3   Using Host Name. 388

11.3.1  Setting Host Name. 388

11.3.2  Communication with Host Name. 390

11.4   Wired Network Connection. 391

11.5   Wireless Connection. 393

11.5.1  Setting Wi-Fi with Panel Menu. 393

11.5.2  Setting Wireless Connection with Configuration File. 397

11.6   Setting Static IP Address 398

11.6.1  How to Specify Static IP Address on DHCP Server 398

11.6.2  How to Set up Static IP Address in Raspberry Pi 400

11.7   Activation and Stop of Network. 401

11.7.1  Network Activation/Stop by "ifup" and "ifdwon" Command. 401

11.7.2  Activation and Stop with "ifconfig" Command. 405

11.8   Configuration and Connection of Bluetooth. 406

11.8.1  Publishing Raspberry Pi to an External Bluetooth Device. 407

11.8.2  Registering & Releasing Bluetooth Devices to Raspberry Pi 408

Chapter 12  User and User Group. 411

12.1   Types of User 412

12.1.1  System Default Users and Additional Created Users. 412

12.1.1.1 System Default User 412

12.1.1.2 Additional Created User 413

12.1.2  System Administrator and Normal User 414

12.1.2.1 System Administrator 414

12.1.2.2 Normal User 415

12.1.3  Super User and Normal User 416

12.1.3.1 Super User 416

12.1.3.2 Commands Requiring Super User 417

12.1.3.3 Working as the Super User by "sudo" Command. 418

12.1.3.4 Working as the Super User by "su" Command. 420

12.1.3.5 "visudo" Command - Control Super User Privilege. 421

12.2   Logon User and Working user 427

12.2.1  Logon User 427

12.2.1.1 Meaning of Logon User 427

12.2.1.2 Confirming Logon User in Desktop Window.. 427

12.2.1.3 Confirming Logon User in Terminal Screen. 428

12.2.2  Working user 429

12.2.2.1 Meaning or Working user 429

12.2.2.2 Confirming Working user by Terminal Information. 430

12.2.2.3 Confirming Working user by "whoami" Command. 431

12.2.2.4 Changing Working user with "su" Command. 432

12.3   Managing User Account in the System.. 434

12.4   Creating User 435

12.4.1  Necessity for Creating User 435

12.4.2  Necessary Considerations for Creating User 436

12.4.3  "adduser" Command – Create User 437

12.5   "deluser" Command - Delete User 440

12.6   User Change. 443

12.6.1  "usermod" Command – Change User 443

12.6.2  Changing User Password. 446

12.6.2.1 Overview of Changing User Password. 446

12.6.2.2 "passwd" Command. 446

12.6.2.3 Changing Password for System Default User "pi" 449

12.7   User Group. 450

12.7.1  What is User Group?. 450

12.7.2  Relationship between User and User Group. 451

12.7.3  Managing User Group. 452

12.7.4  Managing Relationship between User and User Group. 453

12.7.5  "addgroup" Command – Create User Group. 455

12.7.6  "delgroup" Command – Delete User Group. 457

12.7.7  Assignment of User Account to User Group. 460

12.7.7.1 Review of Processing Method. 460

12.7.7.2 Assigning User Group with "adduser" Command. 460

Chapter 13  Control of File Permission. 463

13.1   Understanding Scheme of File Permissions 464

13.1.1  Confirming Permission Information on File. 464

13.1.2  Confirming Permission Information on Window Screen. 467

13.1.3  Framework for Owner User and Owner Group of File. 469

13.1.4  Permission System on File. 470

13.2   Changing Permission on File. 472

13.2.1  Changing Owner User and Owner Group of File. 472

13.2.1.1 "chown" Command – Change Owner User of File. 472

13.2.1.2 "chgrp" Command - Change Owner Group of File. 474

13.2.2  Changing Permissions on File. 475

13.2.2.1 Changing Permission with "chmod" Command. 475

13.2.2.2 Changing Permission by Symbol Representation. 476

13.2.2.3 Changing Permission by Number Representation. 479

Chapter 14  Understanding Device. 481

14.1   Device Overview.. 482

14.1.1  Device Type and "/dev" Directory. 482

14.1.2  Character Device. 483

14.1.2.1 Charateristics. 483

14.1.2.2 Naming Rules for Device. 484

14.1.3  Block Device. 485

14.1.3.1 Block Device Characteristics. 485

14.1.3.2 Block Device Type. 486

14.1.3.3 Naming Rules for Disk Device. 487

14.1.3.4 "blkid" Command - Check Block Device Data. 489

14.1.4  Network Device. 491

14.1.4.1 Characteristics of Network Device. 491

14.1.4.2 Device Type and Naming Rules of Network. 492

14.2   USB Device. 493

14.2.1  "lsusb" Command – Confirm USB Device. 493

14.2.2  USB Device and Device File. 495

14.2.2.1 USB Device and "/dev" File. 495

14.2.2.2 Relationship between USB Device and Others. 495

Chapter 15  Storage Device and Filesystem.. 497

15.1   Management of Logical Storage Device. 498

15.1.1  Partition Management 498

15.1.1.1 "fdisk" Command – Manage Partition. 498

15.1.1.2 "cfdisk" Command - Menu-Based Disk Operation. 501

15.1.2  Formatting Disk. 503

15.1.2.1 What Is Formatting Disk?. 503

15.1.2.2 "mkfs" Command – Format Disk. 503

15.1.3  Mounting Device. 505

15.1.3.1 Meaning of Mount 505

15.1.3.2 Creating Directory for Mount 505

15.1.3.3 Adjusting Permissions on the Mount Directory. 506

15.1.3.4 "mount" Command - Specify Directory for Device. 507

15.1.3.5 Setting Automatic Mount 510

15.1.3.6 "umount" Command - Release Device's Directory. 513

15.1.4  Review of Special Device. 515

15.1.4.1 Booting SD Card. 515

15.1.4.2 USB Storage Device and Mount 516

15.2   Structure of File System.. 519

Chapter 16  File Management 525

16.1   Basic Structure of Directory and File. 526

16.1.1  Concept of Directory and File. 526

16.1.1.1 Folder or Directory. 526

16.1.1.2 File. 527

16.1.2  Naming Rules for Directory and File. 528

16.1.3  Specifying Paths for Directory and File. 529

16.1.3.1 Absolute Path. 529

16.1.3.2 Relative Path. 530

16.1.4  Special Directory and Special File. 532

16.1.4.1 Hidden File. 532

16.1.4.2 Link File. 533

16.1.4.3 "ln" Command. 534

16.2   Management of Directory and File. 536

16.2.1  Creating Directory. 536

16.2.1.1 "mkdir" Command – Create Directory. 536

16.2.1.2 Processing in Desktop Window.. 537

16.2.2  Renaming Directory and File. 538

16.2.2.1 "mv" Command - Rename File. 538

16.2.2.2 Processing in Desktop Window.. 540

16.2.3  Creating Text File. 542

16.2.3.1 File Creation Using "touch" Command. 542

16.2.3.2 File Creation Using "echo" and ">" Command. 544

16.2.3.3 File Creation Using Text Editor Program... 545

16.2.3.4 Processing in Desktop Window.. 548

16.2.4  Moving Directory and File. 549

16.2.4.1 "mv" Commmand – Move Directory and File. 549

16.2.4.2 Processing in Desktop Window.. 551

16.2.5  Copying Directory and File. 555

16.2.5.1 "cp" Command – Copy Directory and File. 555

16.2.5.2 Processing in Desktop Window.. 558

16.2.6  Deleting Directory and File. 562

16.2.6.1 "rmdir" Command - Delete Directory. 562

16.2.6.2 "rm" Command – Delete Directory and File. 564

16.2.6.3 Processing in Desktop Window.. 566

16.2.7  Management and Recovery of Data in [Trash Can] 569

16.2.7.1 Viewing the Data in [Trash Can] 569

16.2.7.2 Completing Clearing of Data in [Trash Can] 571

16.2.7.3 Recovery of Data in [Trash Can] 573

16.3   Using Directory and File. 575

16.3.1  "cd" Command - Move Current File Path. 575

16.3.2  "pwd" Command - Check Current File Path. 577

16.3.3  Searching for File Name. 579

16.3.3.1 "find" Command - Retrieve File Name. 579

16.3.3.2 Processing in Desktop Window.. 584

16.3.4  Searching for Files by File Content 586

16.3.4.1 "grep" Command - Retrieve Files by File Content 586

16.3.4.2 Processing in Desktop Window.. 589

16.3.5  Checking Used Space of Directory/File. 591

16.3.5.1 "du" Command - Check Used Space of Directory/File. 591

16.3.5.2 Processing in Desktop Window.. 593

16.3.6  Determining Type of File. 594

16.3.6.1 "file" Command - Determine Type of File. 594

16.3.6.2 Processing in Desktop Window.. 596

16.3.7  Checking Contents of Directory. 599

16.3.7.1 "ls" Command - Check Content of Directory. 599

16.3.7.2 How to Check Contents of Folder in Desktop Window.. 602

16.3.8  Checking Contents of Text File. 604

16.3.8.1 Checking File Contents Using "cat" Command. 604

16.3.8.2 Checking File Contents Using "more" Command. 606

16.3.8.3 Checking File Contents Using "less" Command. 609

16.3.8.4 Checking File Contents Using Text Editor Program... 612

16.3.8.5 How to Check File Contents in Desktop Window.. 613

16.4   Managing Text File. 615

16.4.1  Concept of Text File. 615

16.4.2  [Nano] Text Editor 616

16.4.3  [Vim] Text Editor 622

16.4.4  [Leafpad] Text Editor 630

Chapter 17  Program Installation & Upgrade. 637

17.1   Package Manager System.. 638

17.1.1  Package. 638

17.1.2  Package Repository. 639

17.1.3  Package Manager System... 640

17.1.4  Source List of Package Repository. 641

17.1.5  Naming Rules for Package. 643

17.2   Package Management Tool 645

17.2.1  Overview of the Package Management Tool 645

17.2.2  Package Management Tool – dpkg. 647

17.2.3  Package Management Tool - APT. 651

17.2.3.1 Overview  of APT Tool 651

17.2.3.2 "apt-get" Command. 652

17.2.3.3 "apt-cache" Command. 654

17.2.4  Package Management Tool – aptitude. 656

17.3   Checking Program Package List and Status 658

17.4   Obtaining Installer Program Source. 660

17.4.1  How to Use Program Registered in Package Repository. 660

17.4.2  How to Download from Internet with "wget" Command. 661

17.4.3  How to Download from Internet Using GitHub. 664

17.5   Installing and Reinstalling Program.. 667

17.5.1  Comparison of Installation by Source Distribution Method. 667

17.5.2  Installing Programs Distributed in Package Repository. 669

17.5.3  Installing Programs Distributed in Package Format 672

17.5.4  Installing Programs Distributed in the General File Format 674

17.6   Uninstalling Programs and Cleaning Files 677

17.6.1  Uninstalling Programs. 677

17.6.1.1 "apt-get remove" Command. 677

17.6.1.2 "apt-get purge" Command. 679

17.6.1.3 "apt-get autoremove" Command. 680

17.6.2  Cleaning Program Package File. 681

17.6.2.1 "apt-get clean" Command. 681

17.6.2.2 "apt-get autoclean" Command. 682

17.7   Update and Upgrade of Program.. 683

17.7.1  Upgarde of Program... 683

17.7.2  "apt-get update" command - Update Local Package DB. 684

17.7.3  "apt-get upgrade" Command- Reflect Updated Program... 686

17.8   Upgrade of System Kernel and Firmware. 688

Chapter 18  Remote Connection. 26

18.1   Overview of Remote Connection. 27

18.1.1  Remote System Connection. 27

18.1.2  Remote Drive Connection. 27

18.2   Remote Terminal Connection. 28

18.2.1  Features of SSH.. 28

18.2.2  Configuring SSH Server 28

18.2.3  SSH Connection on Unix/Linux Series, and Apple Mac. 29

18.2.4  SSH Connection with <PuTTy> Program in MS Windows. 31

18.3   Remote Desktop GUI connection. 33

18.3.1  Remote Desktop Connection Using <XRDP> Program... 33

18.3.2  Desktop GUI connection Using VNC Program... 36

18.3.2.1   Installing <TightVNC> Server 37

18.3.2.2   Automatic Startup of <TightVNC> Server 39

18.3.2.3   Connecting Using VNC client 42

18.4   Remote Drive Connection. 44

18.4.1  Remote Drive Connection Using <Samba> Program... 44

18.4.1.1   Installing <Samba> Server Program... 44

18.4.1.2   Connecting from <Samba> Client 54

18.4.2  Remote Drive Connection Using SCP Program... 60

18.4.2.1   Installing/Enabling SSH server Program... 60

18.4.2.2   Connecting from SCP Client 60

Chapter 19  System Monitoring. 66

19.1   CPU, Memory and Task. 67

19.1.1  Checking System Status. 67

19.1.1.1   "top" Command - Check Main System Information. 67

19.1.1.2   "free" Command – Check Memory Status. 72

19.1.1.3   "ps" Command – Check Process Snapshot 73

19.1.1.4   System Monitoring with Desktop Window.. 76

19.1.2  Killing Process. 78

19.1.2.1   "kill" Command – Terminate Process Using PID.. 78

19.1.2.2   "killall" Command – Terminate Process with Name. 81

19.1.2.3   Terminating Process Using Desktop Window.. 83

19.2   Storage Device Monitoring. 84

19.2.1  Checking Storage Device. 84

19.2.1.1   "df" Command – Check File System Disk Space. 84

19.2.1.2   "du" Command - Check Disk Usage by Directory. 86

19.2.1.3   Checking Disk Usage by Using Desktop Window.. 88

19.3   "/proc" Folder and Process Information. 90

19.3.1  Types of Information in "/proc" Folder 90

19.3.2  Checking System Information in "/proc" Folder 92

19.3.2.1   Information about CPU and Memory. 92

19.3.2.2   Information about File System... 94

19.3.3  Checking Each Process Information in "/proc/<PID>/" 96

Chapter 20  Batch Run and Automatic Run. 98

20.1   How to Run Command. 99

20.1.1  Individual Run and Batch Run. 99

20.1.2  Manual Run and Automatic Run. 101

20.2   Batch Run of Commands via Script 103

20.2.1  Shell and script 103

20.2.1.1   What is Script?. 103

20.2.1.2   Commands Available in Script 104

20.2.1.3   Features of Script 104

20.2.2  How Shell Runs Commands. 105

20.2.2.1   Types of Kernel's System Calls. 105

20.2.2.2   How Shell Runs According to Command Type. 106

20.2.2.3   Bash's Working Procedure. 107

20.2.3  Basics of Script Syntax. 108

20.2.3.1   Definition of Script 108

20.2.3.2   Comment 109

20.2.4  Operations in Script 110

20.2.4.1   Assignment Operation. 110

20.2.4.2   Reference Operation. 111

20.2.4.3   Arithmetic Operation of Integer Number Type. 112

20.2.4.4   Arithmetic Operation of Real Number Type. 115

20.2.4.5   Logical Operation. 116

20.2.5  Execution Control of Script 119

20.2.5.1   Optional Processing according to Conditions. 119

20.2.5.2   Repetitive Processing. 123

20.2.6  Running Script 128

20.2.6.1   Preparing to Run Script File. 128

20.2.6.2   Running Script File. 129

20.3   Automatic Run with Init Script 131

20.3.1  Run Level 131

20.3.1.1   Definition of Run Level 131

20.3.1.2   "runlevel" Command – Check Run Level 133

20.3.1.3   "telinit" Command – Change Run Level 134

20.3.2  Booting Sequence. 135

20.3.2.1   Booting Framework. 135

20.3.2.2   "pstree" Command – Check Booting Process Tree. 138

20.3.3  Creating Init Script 140

20.3.3.1   Meaning of Init Script 140

20.3.3.2   How to Create Init Script by Run Level 141

20.3.3.3   Creating Init Script to Run Application Daemon. 144

20.3.4  Automatic Execution by Run Level at Booting. 147

20.3.4.1   Principles of Registering Init Script 147

20.3.4.2   "update-rc.d" Command – Automatic Registering. 148

20.3.4.3   Starting and Stopping Init Script 150

20.3.5  Automatic Run regardless of Run Level at Booting. 151

20.4   Automatic Run by Schedule. 152

20.4.1  <Cron> Application. 152

20.4.2  "crontab" Command - Manage Crontab. 153

Chapter 21  Office and Utility Program.. 158

21.1   Open Office - Office Software. 159

21.1.1  Available Office Programs. 159

21.1.2  <Libre Office> Program... 160

21.1.2.1   Summary of <Libre Office>.. 160

21.1.2.2   Installing <Libre Office> Program... 161

21.1.2.3   Running and Using <Libre Office> Program... 162

21.2   <Gimp> Program – Edit Image File. 164

21.2.1  Installing <Gimp> Program... 164

21.2.2  Running <Gimp> Program... 165

21.3   <Scrot> Program - Capture Screen. 166

21.3.1  Installing <Scrot> Program... 166

21.3.2  Screen Capture Using <Scrot> Program... 167

21.3.2.1   Overview of Program Execution. 167

21.3.2.2   Capturing Full Screen. 168

21.3.2.3   Capturing Partial Screen. 169

21.4   <CUPS> Program - Network Printing. 170

21.4.1  Printer Status just before Program Installation. 170

21.4.2  Installing <CUPS> Program... 172

21.4.3  Setting up Printer Server Using <CUPS> Program... 173

21.4.4  Verifying Printer Installation and Printing. 177

21.5   Web Browser Alternatives 178

21.5.1  Chromium browser 178

21.5.2  Iceweasel browser 178

Chapter 22  Utilizing Multimedia. 180

22.1   Using Raspberry Pi camera. 181

22.1.1  Basics of Camera. 181

22.1.1.1   Installing Raspberry Pi Dedicated Camera. 181

22.1.1.2   Setup of Raspberry Pi Camera and GPU Memory. 181

22.1.2  Processing API for Raspberry Pi Camera. 182

22.1.2.1   MMAL (Multi-Media Abstraction Layer) 182

22.1.2.2   V4L2 (Video For Linux2) 183

22.1.3  Taking Picture and Video Using Pi Camera. 186

22.1.3.1   Overview of Shooting Command for Pi Camera. 186

22.1.3.2   Taking Pictures with "raspistill" Command. 187

22.1.3.3   Recording Video Using "raspivid" Command. 191

22.1.4  Playing Video Contents. 194

22.1.4.1   Playing Video Using <OMXplayer> Program... 194

22.1.4.2   Playing Video Using <Mplayer> Program... 196

22.1.5  Converting Video Format Using <FFMPEG> Program... 199

22.1.6  Viewing Video on an External Computer 203

22.1.6.1   Basic framework to Transmit/Receive Video Data. 203

22.1.6.2   <Netcat> Program – Transmit/Receive Video via Network. 204

22.1.6.3   Sending Video Data Using "raspivid" Command. 206

22.1.6.4   Receiving/Playing a Video on Linux. 207

22.1.6.5   Receiving/Playing Video on MS Window.. 209

22.1.6.6   Receiving/Playing Video on Mac. 210

22.1.7  Broadcasting Video over Internet 211

22.1.7.1   Framework to Transmit Video over Web. 211

22.1.7.2   <VLC> server – Transmit Video from Raspberry Pi 212

22.1.7.3   <VLC> client – Playing Video on MS Windows. 215

22.1.8  Motion Detecting Web Camera - <Motion> Program... 217

22.1.8.1   Framework to Access Camera via Web. 217

22.1.8.2   Capturing Motion Detection in Raspberry Pi System... 218

22.2   Using E-mail 222

22.2.1  <SSMTP> Program - Mail Transfer Agent 222

22.2.2  <MUTT> Program - Mail Transmitting Auxiliary Tool 228

Chapter 23  Writing Program.. 234

23.1   Overview of Program Basics 235

23.1.1  Significance of Program... 235

23.1.2  What We Can Do with Program... 235

23.1.3  Available Major Languages and Tools. 236

23.2   Mathematica or Wolfram language. 237

23.2.1  Features. 237

23.2.2  Getting Started. 239

23.2.2.1   Starting in Desktop GUI Environment 239

23.2.2.2   Working in Terminal Environment 241

23.2.3  How to use Mathematica. 242

23.2.3.1   How to Write Program in Mathematica. 242

23.2.3.2   Saving and Reusing Program... 248

23.3   Sonic Pi 250

23.3.1  Features. 250

23.3.2  Getting Started. 251

23.3.3  How to Use Sonic Pi 253

23.3.3.1   Step 1 - First Sounds with Sonic Pi 253

23.3.3.2   Step 2 - Loop a Tune. 255

23.3.3.3   Step 3 - MIDI Note and Music Note. 257

23.3.3.4   Change Sound Using Synthesizer 258

23.3.3.5   Step 5 - Use Samples. 260

23.3.3.6   Step 6 - Playing Two Tunes at the Same Time. 261

23.3.3.7   Step 7 - Live Code! 262

23.4   Scratch Language. 263

23.4.1  Features. 263

23.4.2  Starting Program... 264

23.4.3  Scratch Overview.. 265

23.4.4  Basics of Using Program... 267

23.4.4.1   Concept of Sprite. 267

23.4.4.2   Start and Stop of Program... 267

23.4.4.3   Palette and Block. 268

23.4.4.4   Specifying the Detail Characteristics of the Block. 268

23.4.4.5   Connection with Other Commands. 269

23.4.4.6   Completing Connection with Other Commands. 270

23.4.4.7   Processing Sequence between Blocks. 270

23.4.4.8   Repetitive Processing. 271

23.4.5  Explaining How to Write Program Using Example. 272

23.4.5.1   Moving [Cat] Sprite. 272

23.4.5.2   Changing the Appearance of [Cat] Sprite. 273

23.4.5.3   Adding Sprite. 274

23.4.6  Robotics and Sensors. 275

23.4.6.1   Sensing with PicoBoard. 275

23.4.6.2   Implementing Robotics with LEGO.. 276

23.5   Python language. 277

23.5.1  Python Overview.. 277

23.5.1.1   What is Python?. 277

23.5.1.2   Python 2 and Python 3. 278

23.5.1.3   IDLE Tool of Python. 279

23.5.2  Gettting Started. 280

23.5.2.1   Starting in the Desktop GUI environment 280

23.5.2.2   Working in Terminal Environment 282

23.5.3  Python Syntax. 283

23.5.3.1   Starting Statement of Python. 283

23.5.3.2   Simple Printing. 284

23.5.3.3   Indentation of Program... 284

23.5.3.4   Using Variable. 287

23.5.3.5   Comments. 287

23.5.3.6   List 288

23.5.3.7   Iteration Processing. 288

23.5.3.8   "range" Statement 290

23.5.3.9   "len" Statement 291

23.5.3.10  "if" Statement 291

23.5.3.11  Loop processing. 292

23.5.4  Running Python Program... 293

23.5.4.1   Creating Python Program file in IDLE. 293

23.5.4.2   Running Python program File in Shell 293

23.5.4.3   Using Executable Python Program File. 294

23.5.5  Learning Python through Game. 295

23.5.5.1   Python Games. 295

23.5.5.2   Minecraft PI 298

23.5.6  Learning Python Using Simple Example. 314

23.6   C language. 316

23.6.1  Overview.. 316

23.6.2  Writing Program... 317

23.6.3  Saving, Compiling and Running Program... 318

23.7   Java language. 320

23.7.1  Overview.. 320

23.7.2  Checking the Current version. 321

23.7.3  Writing and Running Program... 322

23.7.3.1   Writing Program Source Code. 322

23.7.3.2   Compiling and Running Program... 323

Chapter 24  Utilizing Database and Web. 326

24.1   LAMP Overview.. 327

24.1.1  Needs for Database and Web. 327

24.1.2  LAMP. 328

24.2   MySQL Database. 329

24.2.1  Relational Database and SQL. 329

24.2.1.1   Relational database. 329

24.2.1.2   Introduction and Features of MySQL. 329

24.2.2  Installing <MySQL Server>.. 330

24.2.2.1   Installing <MySQL Server>.. 330

24.2.2.2   Configuring <MySQL Server>.. 331

24.2.3  MySQL Management Tool 333

24.2.3.1   <MySQL Administrator> – mysqladmin command. 333

24.2.3.2   <MySQL Shell> – "mysql" command. 336

24.2.3.3   <MySQL Backup> – "mysqldump" command. 337

24.2.3.4   <MySQL Import> – "mysqlimport" command. 339

24.2.4  Using <MySQL Shell> – "mysql" command. 341

24.2.4.1   Basic Framework of <MySQL Shell>.. 341

24.2.4.2   Starting <MySQL Shell> Program... 343

24.2.4.3   Using MySQL Shell Command. 344

24.2.5  Database SQL. 349

24.2.5.1   Introduction of Database SQL. 349

24.2.5.2   Querying Database Information – "SHOW" SQL. 350

24.2.5.3   Creating Database – "CREATE DATABASE" SQL. 351

24.2.5.4   Deleting Database – "DROP DATABASE" SQL. 352

24.2.5.5   Creating DB User–"CREATE USER"/"DROP USER" SQL. 353

24.2.5.6   Managing User Privilege – "GRANT"/"REVOKE" SQL. 355

24.2.5.7   Creating Table – "CREATE TABLE" SQL. 358

24.2.5.8   Deleting Table – "DROP TABLE" SQL. 360

24.2.5.9   Querying Table Information – "EXPLAIN"/"DESCRIBE" SQL. 361

24.2.5.10  Inserting Table Data – "INSERT" SQL. 362

24.2.5.11  Quering Table Data – "SELECT" SQL. 363

24.2.5.12  Changing Table Data – "UPDATE" SQL. 367

24.2.5.13  Deleting Table Data – "DELETE" SQL. 369

24.3   Apache web server 370

24.3.1  Web server and Apache. 370

24.3.1.1   Web server 370

24.3.1.2   Introduction and Features of Apache. 370

24.3.2  Installing <Apache Web Server>.. 371

24.3.2.1   Installing <Apache Web Server>.. 371

24.3.2.2   Configuring Apache Server 374

24.3.3  Summary of HTML Syntax. 380

24.3.3.1   HTML Overview.. 380

24.3.3.2   HTML Structure. 381

24.3.3.3   major HTML Tag. 381

24.3.4  Simple HTML Web Page. 383

24.3.4.1   Using Link to Other URL. 383

24.3.4.2   Using Table. 384

24.3.4.3   Using Frame. 386

24.3.4.4   Using Style. 388

24.3.4.5   Entering Data Using Form... 391

24.4   PHP Web Script Language. 393

24.4.1  HTML and PHP. 393

24.4.1.1   Needs for PHP. 393

24.4.1.2   Overview and Features of PHP. 394

24.4.2  Installing PHP and Connection Tool to MySQL. 395

24.4.3  Summary of PHP Syntax. 397

24.4.3.1   Basic Structure of PHP. 397

24.4.3.2   Rule of PHP Statement 399

24.4.3.3   Variable. 403

24.4.3.4   Constant 407

24.4.3.5   Data Type. 409

24.4.4  Operation. 414

24.4.4.1   Arithmetic Operator 414

24.4.4.2   Assignment Operator 415

24.4.4.3   Comparison Operator 416

24.4.4.4   Incremental/Decremental Operator 417

24.4.4.5   Logical Operator 418

24.4.4.6   String Operator 419

24.4.4.7   Array Operator 420

24.4.5  Output 421

24.4.5.1   "echo" Command. 421

24.4.5.2   "print" Command. 422

24.4.6  Execution Control 423

24.4.6.1   Conditional Control 423

24.4.6.2   Loop Processing. 426

24.4.6.3   Stopping and Continuing Loop Processing. 432

24.4.7  Stop and Return of Processing. 436

24.4.7.1   "exit" Statement and "die" Statement 436

24.4.7.2   "return" Statement 437

24.4.8  Function. 439

24.4.8.1   Definition of Function. 439

24.4.8.2   Using Function. 440

24.4.9  Including PHP Script File. 443

24.4.9.1   "include" Statement  and "require" Statement 443

24.4.9.2   "include_once" statement and "require_once" statement 447

24.4.10                         Transmission Methods of PHP and Key Global Variable. 448

24.4.10.1  POST/GET Method of HTTP and PHP Processing. 448

24.4.10.2  Global Variable of PHP. 451

24.4.11                                                               PHP and MySQL database. 454

24.4.11.1  PHP MySQL extension. 454

24.4.11.2  Interface Method of the <mysqli>.. 456

24.4.11.3  Details of <mysqli> Object-Oriented Interface. 458

24.4.11.4  Usage of <mysqli> Object-Oriented Interface. 465

24.4.12                                                                    Simple PHP Web Page. 467

24.4.12.1  Preparing Main Document 467

24.4.12.2  Preparing Works for Database and Table. 469

24.4.12.3  Connecting and Disconnecting Database. 470

24.4.12.4  Writing script to Query Data in Database Table. 472

24.4.12.5  Writing Scrit to Update Database Table Data. 478

24.4.12.6  Flow of Managing Screen for Table "employee" 485

Chapter 25  External Interface. 486

25.1   Raspberry Pi and External Interface. 487

25.1.1  Meaning of External Interface. 487

25.1.2  GPIO of the Raspberry Pi 487

25.2   GPIO Details 488

25.2.1  GPIO Device. 488

25.2.1.1   GPIO Pin Layout 488

25.2.1.2   List and Function of GPIO Pin. 489

25.2.2  GPIO Port Details. 493

25.2.2.1   GPIO Basics. 493

25.2.2.2   Special Purpose GPIO.. 495

25.2.3  Precautions and Features in Using GPIO.. 497

25.3   Basics of Electricity/Electronics 498

25.3.1  Current, Resistance, and Voltage. 498

25.3.1.1   Current 498

25.3.1.2   Voltage and Electric Potential 500

25.3.1.3   Resistance. 501

25.3.1.4   Ohm's Law.. 503

25.4   Basics of Electronic Circuit 504

25.4.1  Short and Resistance. 504

25.4.2  Series and Parallel of Resistance. 506

25.4.2.1   Series Connection of Resistance. 506

25.4.2.2   Parallel Connection of Resistance. 508

25.4.2.3   Why to Use Resistance. 510

25.4.3  Series and Parallel of Power 512

25.4.3.1   Series Connection. 512

25.4.3.2   Parallel Connection. 512

25.4.3.3   Series and Parallel Connection. 513

25.4.4  Kirchhoff’s Laws. 514

25.4.4.1   First Law - The Law of Current 514

25.4.4.2   Second Law – The Law of Voltage. 515

25.4.5  Pull-up Resistor and Pull-down Resistor 516

25.4.5.1   Floating State. 516

25.4.5.2   Why to Use Resistor in Pull-up/Pull-down State. 518

25.4.5.3   Pull-up Resistor 520

25.4.5.4   Pull-down Resistor 522

25.4.5.5   Resistance Value of Pull-up Resistor 524

25.4.6  Direct Current Power 525

25.5   Preparations and Usages for Interface. 526

25.5.1  GPIO Extension Board. 526

25.5.2  Breadboard. 528

25.5.2.1   Structure of Breadboard. 528

25.5.2.2   How to Use Breadboard. 530

25.5.3  Jumper Wire. 531

25.5.4  Resistor 533

25.5.4.1   Meaning of Resistor 533

25.5.4.2   Reading Resistor Value. 535

25.5.5  Push Button. 537

25.5.6  LED Light 539

25.5.7  Sensor 542

25.6   GPIO Library. 544

25.6.1  Meaning of GPIO Library. 544

25.6.2  <WiringPi> library. 545

25.6.2.1   Overview of <WiringPi> Library. 545

25.6.2.2   Pin Map of <WiringPi> library. 546

25.6.2.3   Installing <WiringPi> Library. 548

25.6.2.4   "gpio" Command. 550

25.6.2.5   Basic usage of <WiringPi> Library. 553

25.6.3  <RPi.GPIO> library. 555

25.6.3.1   Overview of <RPi.GPIO> Library. 555

25.6.3.2   Installing <RPi.GPIO> library. 556

25.6.3.3   Usage of <RPi.GPIO> Library. 557

25.7   Digital Input/Output 560

25.7.1  Digital Output – LED On/Off 560

25.7.1.1   Installing LED.. 560

25.7.1.2   Example of Using <WiringPi> Library. 561

25.7.1.3   Example of <RPi.GPIO> Library. 563

25.7.2  Digital Input – Button Input 565

25.7.2.1   Input Method of <RPi.GPIO> library. 565

25.7.2.2   Push Button Connection and Circuit Description. 568

25.7.2.3   Processing Button Input with Falling Method. 570

25.7.2.4   Processing Button Input with Interrupt Method. 572

25.8   Sensor 575

25.8.1  Sensor Overview.. 575

25.8.2  Measuring Temperature with Digital Sensor DS18b20. 576

25.8.2.1   Features of DS18B20 Sensor 576

25.8.2.2   Connection between Raspberry Pi and Sensor 579

25.8.2.3   Enabling 1-Wire Bus Protocol 580

25.8.2.4   Interface File for Measuring Value of DS18B20. 581

25.8.2.5   Writing Program to Process Temperature Value. 582

25.8.3  Utilizing Digital DHT11 Humidity/Temperature Sensor 584

25.8.3.1   Feature of the Sensor 584

25.8.3.2   Writing Program with <WiringPi> Library. 588

25.8.3.3   Writing Program with <RPi.GPIO> Library. 592

25.8.3.4   Raspberry Pi and Real Time Processing. 596

25.9   Action. 597

25.9.1  Relay. 597

25.9.2  Actuator 597

25.10 Special GPIO Pin. 597

25.10.1                                                   I2C (Inter-Integrated Circuit) device. 597

25.10.2                                                         SPI (Serial Peripheral Interface) 597

25.10.3                            UART (Universal Asynchronous Receiver/Transmitter) 597