Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (1 vote)
9 views

The MagPi Essentials Conquer the commandline the Raspberry terminal guide Second Edition Raspberry download

The document is a promotional overview of the second edition of 'Conquer the Command Line', a guide for using the command line interface on Raspberry Pi. It emphasizes the importance of mastering the command line for efficient computing, especially for complex tasks, and provides links to various Raspberry Pi-related ebooks. The guide aims to make users comfortable with the terminal and enhance their ability to navigate and manipulate files and commands effectively.

Uploaded by

mariowbochum
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
9 views

The MagPi Essentials Conquer the commandline the Raspberry terminal guide Second Edition Raspberry download

The document is a promotional overview of the second edition of 'Conquer the Command Line', a guide for using the command line interface on Raspberry Pi. It emphasizes the importance of mastering the command line for efficient computing, especially for complex tasks, and provides links to various Raspberry Pi-related ebooks. The guide aims to make users comfortable with the terminal and enhance their ability to navigate and manipulate files and commands effectively.

Uploaded by

mariowbochum
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 83

The MagPi Essentials Conquer the commandline the

Raspberry terminal guide Second Edition


Raspberry pdf download

https://ebookgate.com/product/the-magpi-essentials-conquer-the-
commandline-the-raspberry-terminal-guide-second-edition-
raspberry/

Get Instant Ebook Downloads – Browse at https://ebookgate.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Raspberry Pi Networking Cookbook Second Edition Golden

https://ebookgate.com/product/raspberry-pi-networking-cookbook-second-
edition-golden/

ebookgate.com

Programming the Raspberry Pi Second Edition Getting


Started with Python Simon Monk

https://ebookgate.com/product/programming-the-raspberry-pi-second-
edition-getting-started-with-python-simon-monk/

ebookgate.com

Raspberry Pi user guide Fourth Edition / Halfacree

https://ebookgate.com/product/raspberry-pi-user-guide-fourth-edition-
halfacree/

ebookgate.com

Raspberry Pi Projects for Kids Second Edition Bates

https://ebookgate.com/product/raspberry-pi-projects-for-kids-second-
edition-bates/

ebookgate.com
Raspberry Pi User Guide 2nd revised edition Edition Upton

https://ebookgate.com/product/raspberry-pi-user-guide-2nd-revised-
edition-edition-upton/

ebookgate.com

Experiment with the Sense HAT 1st edition Edition


Raspberry Pi

https://ebookgate.com/product/experiment-with-the-sense-hat-1st-
edition-edition-raspberry-pi/

ebookgate.com

Raspberry Pi 5 for Radio Amateurs program and Build


Raspberry Pi 5 Based Ham Station Utilities with the RTL
SDR 1st Edition Dogan Ibrahim
https://ebookgate.com/product/raspberry-pi-5-for-radio-amateurs-
program-and-build-raspberry-pi-5-based-ham-station-utilities-with-the-
rtl-sdr-1st-edition-dogan-ibrahim/
ebookgate.com

Halfacre G Official Raspberry Pi Beginner s Guide 3rd


Edition Gareth Halfacree

https://ebookgate.com/product/halfacre-g-official-raspberry-pi-
beginner-s-guide-3rd-edition-gareth-halfacree/

ebookgate.com

Raspberry Pi Robotic Projects 3rd Edition Richard Grimmett

https://ebookgate.com/product/raspberry-pi-robotic-projects-3rd-
edition-richard-grimmett/

ebookgate.com
2nd
EDITION

ESSENTIALS

CONQUER
COMMAND
TH

LINE
E

The Raspberry Pi
TERMINAL GUIDE
9!
01
Written by Richard Smedley
2 RS
R TE
FOAP
T ED CH
DA EW
P N
U +4
ESSENTIALS
LEARN | CODE | MAKE
AVAILABLE NOW:

> CONQUER THE COMMAND LINE


> EXPERIMENT WITH SENSE HAT
> MAKE GAMES WITH PYTHON
> CODE MUSIC WITH SONIC PI
> LEARN TO CODE WITH SCRATCH
> HACK & MAKE IN MINECRAFT
> ELECTRONICS WITH GPIO ZERO
> LEARN TO CODE WITH C
> THE CAMERA MODULE GUIDE
> AIY PROJECTS

From the makers of the


official Raspberry Pi magazine
ESSENTIALS
OUT NOW
IN PRINT
ONLY £3.99
store.rpipress.cc

GET THEM
DIGITALLY:
WELCOME TO
CONQUER THE
COMMAND LINE
ometimes only words will do. Graphic user
S interfaces (GUIs) were a great advance,
creating an easy route into computer use
for many non-technical users. For complex tasks,
though, the interface can become a limitation:
blocking off choices, and leaving a circuitous route
even for only moderately complicated jobs.
(Re-)Enter the command line: the blinking cursor
that many thought had faded away in the 1990s. For
getting instructions from user to computer – in a
clear, quick, and unambiguous form – the command
line is often the best way. It never disappeared on
UNIX systems, and now, thanks to Raspbian on the
Raspberry Pi, a new generation is discovering the
power of the command line to simplify complex
tasks, or instantly carry out simple ones.
If you’re not comfortable when faced with the $
prompt, then don’t panic! In this fully updated book,
we’ll quickly make you feel at home, and able to
find your way around the terminal on the Pi, or any
other GNU/Linux computer: getting things done, and
unlocking the power of the command line.

FIND US ONLINE raspberrypi.org/magpi GET IN TOUCH magpi@raspberrypi.org

PUBLISHING
Publishing Director: Russell Barnes
Director of Communications: Liz Upton
CEO: Eben Upton

EDITORIAL
DESIGN Editor: Phil King
Critical Media: criticalmedia.co.uk Writer: Richard Smedley
Head of Design: Lee Allen Contributors: Lucy Hattersley,
Designer: Mike Kay Simon Long

In print, this product is made using paper This book is published by Raspberry Pi (Trading) Ltd., Maurice Wilkes Building, St. John's Innovation Park,
sourced from sustainable forests and Cowley Road, Cambridge, CB4 0DS. The publisher, editor and contributors accept no responsibility in respect
the printer operates an environmental of any omissions or errors relating to goods, products or services referred to or advertised in this product.
4 [ management
Chapter One ] which has been
system Except where otherwise noted, content in this book is licensed under a Creative Commons Attribution-
assessed as conforming to ISO 14001. NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0). ISBN: 978-1-912047-66-6
[ CONQUER THE COMMAND LINE ]

ESSENTIALS

CONTENTS
06 [ CHAPTER ONE ] 31 [ CHAPTER SIX ]
DON’T PANIC CONNECTING DISKS [ RICHARD
Take a look around Tackle the management SMEDLEY ]
and discover things of removable storage

11 [ CHAPTER TWO ] 36 [ CHAPTER SEVEN ]


READ/WRITE TEXT PREDICTABLE NETWORKING
Get working on files Give the Pi a permanent network
address of its own
16 [ CHAPTER THREE ]
PERMISSION TO INSTALL 41 [ CHAPTER EIGHT ]
Raspbian’s system for installing STOPPING A PROCESS Since soldering
and updating No need to turn it off and on again: together his first
just kill the process! computer – a ZX81
21 [ CHAPTER FOUR ] kit – and gaining

MANIPULATING TEXT 46 [ CHAPTER NINE ] an amateur


radio licence as
Connect together multiple REMOTE PI GW6PCB, Richard
simple commands Access the Pi with Secure Shell has fallen in
and out of love
26 [ CHAPTER FIVE ] 51 [ CHAPTER TEN ] with technology.
CUSTOMISE DOWNLOADING & INSTALLING Swapping the
THE COMMAND LINE Add software and write to SD cards ZX81 for a guitar,
and dropping ham
Make Raspbian more personal
56 [ CHAPTER ELEVEN ] radio for organic
START AND STOP AT horticulture,
he eventually
YOUR COMMAND returned to the
Manage startup and shutdown command line,
beginning with a
64 [ CHAPTER TWELVE ] computer to run
SAVE IT NOW! his own business,
Protect your data with backups and progressing
to running all the
74 [ CHAPTER THIRTEEN ] computers of
an international
EASY COMPILATION
sustainability
Build software from source code institution. Now
he writes about
82 [ CHAPTER FOURTEEN ] Free Software and
COMMANDING THE INTERNET teaches edible
Get online from the command line landscaping.

[ Don’t
[ Contents
Panic ] 5
ESSENTIALS

ESSENTIALS

ONE ]
[ CHAPTER
DON’T PANIC In the first chapter, we take a look around and discover
that things aren’t as strange as they might appear…

6 [ Chapter One ]
[ CONQUER THE COMMAND LINE ]

t’s not a throwback to the past, but a quick and powerful way
I of getting your Raspberry Pi to do what you want, without
all that RSI-inducing menu chasing and icon clicking. The
command-line interface was a great step up from manually toggling
in your instructions in octal (base-8), using switches on the front of
the machine! Graphical user interfaces (GUIs) brought friendly visual
metaphor to the computer, losing some power and expressiveness.
With the Raspberry Pi, you can get the best of both worlds by knowing
[ READ THE both: after reading through this guide, you’ll soon be as comfortable
MANUAL ] at the command prompt as you are at your desktop.
Unlike some earlier versions of Raspbian, Stretch boots you straight
Help is included,
with man(ual) to a GUI, although you can change this behaviour in the settings. The
pages, but they command-line environment is still there: hold down the ALT+CTRL
can be a little
keys and press F1 (the first function key on the keyboard), and you’ll
overwhelming.
Use them to arrive at a ‘virtual console’. Press ALT+F2 through to F6 and you’ll
check out some find five further consoles waiting for you to log in.
extra options
You can drop into these any time you like, but for now press
beyond the
switches like ALT+F7 and you’ll be back in mouse and menu land. The command
-a we use here. line is also available through a program called a terminal emulator
To read the ls
(often referred to as a term or xterm). You’ll also find people referring
man page, type
man ls. to the shell, or Bash. Don’t worry about that for now; just click on the
icon at the top of the screen that looks like a black television screen,

The command
line is only a click
away: it is called
Terminal and you
can find it under
Accessories in
the menu

Commands are
terse, but, once
learned, they’re
a quick way of
navigating and
reading your files
and folders

[ Don’t Panic ] 7
ESSENTIALS

Fig 1 Switches
modify behaviour
in commands; ls
-a shows (dot) files
in your listing that
are usually hidden
from view

or go to Accessories>Terminal in the menu: the terminal now awaits


[ PRESS your commands.
RETURN ]
To save Look around
repeating it in the If you’re used to looking at files and folders in a file manager, try
text, we’ll confirm
here that each to clear your mind of the icons and concentrate on the names. Type
time you type ls and press RETURN (see ‘Press Return’ box). On a fresh Raspbian
in a command, Stretch with Recommended Software install, you’ll just see a few
you need to hit
the RETURN or directories, including MagPi. Type ls MagPi (see ‘Lazy Completion’
ENTER key at the box) and you’ll see a listing of what’s in it.
end, to tell the Commands like ls are not cryptic (at least not intentionally) but they
Pi you’ve issued
Bash with a are terse, dating back to a time when the connection to the computer
command. was over a 110 baud serial line, from an ASR 33 teletype terminal. If
you think it’s strange to be defined by 50-year-old technology, just
remember that your QWERTY keyboard layout was reputedly designed
both to stop mechanical typewriter keys jamming, and to enable
salespeople to quickly type ‘typewriter’ using the top row!

File path
You can list files and folders anywhere in your system (or other
connected systems) by providing the path as an argument to your

8 [ Chapter One ]
[ [CONQUER
CONQUERTHE
THECOMMAND
COMMANDLINE
LINE] ]

command. The path is the folder hierarchy: on a Windows computer,


in a graphical file browser, it starts with ‘My Computer’; on your Pi it
starts at /, pronounced ‘root’ when used on its own as the root of your
file system. Try entering ls / – again we get terseness, and names
like ‘bin’, which is short for binary, and is the directory where many
programs are kept (enter ls /bin to see the details). ls /dev shows
hardware devices in the Pi. Try ls /home – see that ‘pi’? That’s you:
you are logged in as user pi. If you’ve changed your login name, or if
you have created extra users, they’ll all be listed there too: every user
gets their own home directory; yours is the /home/pi folder in which
we found ourselves in earlier. Before, with MagPi, we used the relative
path (the absolute path would be /home/pi/MagPi) because we’re
already home. If you need to check your location, type pwd (present
working directory).

Commands are not cryptic (at least


not intentionally), but they are terse
There’s no place like ~
For any logged-in user, their home directory is abbreviated as ~ (the
tilde character). Type ls ~ and you’ll see. There’s apparently not much
in your home directory yet, but Raspbian keeps a lot hidden from the
[ LAZY
COMPLETION ]
casual glance: files and folders beginning with a dot, known as ‘dot files’,
contain configuration information for your system and its programs. You don’t need
to type all of
You don’t need to see these files normally, but when you do, just ask ls ls MagPi (for
to show you all files with a command switch. You can do this with either example) – after
the full switch --all, or the abbreviation -a like so: ls -a ~. Traversing ls M, hit the TAB
key and it will
the pathways of the directory hierarchy can be easier from the command auto-complete.
line than clicking up and down a directory tree, particularly with all If you’ve more
the shortcuts given. Your ls -a showed you . and .. as the first two than one file
beginning with
directories; these shortcuts represent the current and the parent directory M, they’ll all be
respectively. Try listing the parent directory – from /home/pi, entering listed and you
ls ../../ will show you two layers up. If you want to list the hidden can type more
letters and hit
files without the . and .. appearing (after all, they’re present in every TAB again.
directory, so you don’t need to be told), then the switch to use is -A.

[ Don’t Panic ] 9
ESSENTIALS

Before we move on to other commands, let’s look briefly at chaining


switches together: ls -lh ~
-l gives you more information about the files and folders, and -h
changes the units from bytes to kB, MB, or GB as appropriate. We’ll
look at some of the extras the -l listing shows you in more detail later,
particularly in chapters two and three.

Time for change


That’s enough looking: let’s start moving. cd is short for change
directory, and moves you to anywhere you want in the file system:
try cd /var/log and have a look (ls, remember). Files here are logs,
or messages on the state of your system that are saved for analysis
later. It’s not something you’ll often need to think about: Raspbian
is a version of an operating system that also runs across data centres
and supercomputers, where problem monitoring is very important.
It is, however, useful to know, particularly if you have a problem and
someone on a forum advises you to check your logs.
cd ~ will take you where you expect it. Try it, then pwd to check.
Now try cd - (that’s a hyphen), the ‘-’ is a shortcut for ‘wherever I
was before I came here’. Now we’ve looked around, we can move on to
beginning to do things to our files.

Right Who needs


icons when you
can fit a listing
of 78 files into a
small window?
Coloured fonts
indicate file types

10 [ Chapter One ]
ESSENTIALS

TWO ]
[ CHAPTER
READ/WRITE
TEXT
In this chapter, we get working on files

[ Read/Write
[ Don’t Panic
Text ] 11
ESSENTIALS

The command line


offers tools to get
text from different
parts of a file, like
skipping to the
conclusion

Create and name


files and directories
with keystrokes,
rather than
mouse-clicks and
keystrokes

ow that we can navigate folders and list files, it’s time to learn
[ MORE
INFO ]
N how to create, view, and alter both files and folders. Once
more, it’s not that the task is difficult, rather that the forms
Many utilities of the commands (particularly when editing) are unfamiliar, coming
have info pages,
giving far more from an era before Common User Access (CUA) standards were created
information to ease switching between applications and operating systems.
than their man Stick with it: with just the first two chapters of this book under your
page. If you’re
feeling brave, try belt, you’ll be able to do plenty of work at the command line, and start
info nano for a getting comfortable there.
comprehensive
guide to nano.
Creating a directory
We’re going to dive straight into working with files and folders by
creating a new directory. Assuming you already have a terminal open
(see ‘Instant applications’ box), and you’re in your home directory
(pwd to check, cd ~ to get back there if necessary), type mkdir
tempfolder and have a look with ls.
mkdir, as you’ve probably guessed, creates a new directory or folder.
Let’s use it to experiment with altering one of the included Python
games. Don’t worry: we’re not going to be programming Python, just
making a small change by way of illustration. cd tempfolder (use
tab completion: cd t then hit the TAB key). In the following example,
we’ll be copying some files to this directory.

12 [ Chapter Two ]
[ [CONQUER
CONQUERTHE
THECOMMAND
COMMANDLINE
LINE] ]

First, make sure Python Games is installed – if not, click the


top-left Raspberry Pi icon on the desktop, select Preferences,
then Recommended Software, tick the box next to Python
Games in the list, and then click Apply to install it.
We’ll copy over the files from the python_games directory:

cp /usr/share/python_games/fourinarow.py .
cp /usr/share/python_games/4row_* .
[ INSTANT
APPLICATIONS ]
Wildcard Although you
can open
The . (dot) at the end of the commands refers to ‘just here’, which the terminal
is where we want the files copied. Also, 4row_* is read by the Pi as emulator from
the menu –
‘every file beginning 4row_’ – the * is known as a wildcard, and this Accessories >
one represents any number of characters (including none); there are Terminal – for
other wildcards, including ?, which means any single character. this, and any
other app, just
Try python fourinarow.py and you’ll see you can run the hit ALT+F2
local copy of the game. To change the game, we need an editor – and type its
sidestepping the UNIX debate about which one is best, we’ll use the command name:
lxterminal.
Pi’s built-in editor: nano. Unless you’ve previously used the Pico

We’re going to dive straight into


working with files and folders
by creating a new directory
editor, which accompanied the Pine email client on many university
terminals in the 1980s and 1990s, it will seem a little odd (Fig 1,
overleaf). That’s because its conventions predate the CTRL+C for copy
type standards found in most modern programs. Bear with us.

Editing and paging


nano fourinarow.py will open the game for editing; use the arrow
keys to go down nine lines, and along to the BOARDHEIGHT value of
6. Change it to 10 (both the BACKSPACE and DELETE keys will work
in nano). The last two lines of the screen show some shortcuts, with

[ Read/Write Text ] 13
ESSENTIALS

^ (the caret symbol) representing the CTRL key: CTRL+O, followed


[ SWITCHING by RETURN will ‘write out’ (save) the file; then use CTRL+X to exit.
HELP ] Now, python fourinarow.py will open an oversize board, giving
You don’t need
you more time to beat the computer, should you need it. However,
to wade through
the man page there’s now no room to drag the token over the top of the board:
to see what go back and change the BOARDHEIGHT value to 9, with nano.
switches are
If you want to take a look through the fourinarow.py listing
available: type
--help after without entering the strange environment of nano, you can see
the command the entire text of any file using cat: e.g., cat fourinarow.py.
to be shown
Unfortunately, a big file quickly scrolls off the screen; to look through
your options, e.g.
rm --help a page at a time, you need a ‘pager’ program. less fourinarow.py
will let you scroll up and down through the text with the PAGE UP and
PAGE DOWN keys. Other keys will do the same job, but we’ll leave
you to discover these yourself. To exit less, hit Q (this also works
from man and info pages, which use a pager to display text).

Cats, heads & tails


If editor wars are a UNIX tradition we can safely ignore, there’s
Fig 1 The default no getting away from another tradition: bad puns. less is an
editor, nano, has
improvement over more, a simple pager; the respective man pages
unusual command
shortcuts, but will show you the differences. One advantage the relatively primitive
they’re worth
learning, as you’ll
more has is that at the end of a file it exits automatically, saving you
find nano installed reaching for the Q button. Admittedly, this is not a huge advantage,
on virtually all Linux
and you can always use cat.
boxes, such as your
web host Fortunately, cat is not a feline-based pun, but simply short for
‘concatenate’: use it with more
than one file and it concatenates
them together. Used with
no argument – type cat – it
echoes back what you type
after each ENTER. Hit CTRL+C
to get out of this when you’ve
finished typing in silly words
to try it. And remember that
CTRL+C shortcut: it closes most
command-line programs, in the
same way that ALT+F4 closes
most windowed programs.

14 [ Chapter Two ]
[ CONQUER THE COMMAND LINE ]

You can peek at the first or


last few lines of a text file with
head and tail commands. head
fourinarow.py will show you
the first ten lines of the file.
head -n 5 fourinarow.py
shows just five lines, as does
tail -n 5 fourinarow.py
with the last five lines. On the Pi,
head -5 fourinarow.py will
also work.

Remove with care


nano afile.txt will create a
new file if afile.txt does not already exist: try it, and see if it works Fig 2 rm is a
powerful removal
when you exit the file before writing and saving anything. We’ve tool: use with
done a lot already (at least, nano makes it feel like a lot), but it’s great care!
never too early to learn how to clean up after ourselves. We’ll
remove the files we’ve created with rm. The remove tool should
always be used with care: it has some built-in safeguards, but even
these are easy to override (Fig 2). In particular, never let anyone
persuade you to type rm -rf / – this will delete the entire
contents of your Pi, all the programs, everything, with little to no
chance of recovery.
Have a look at what files we have: if you’re still in the
tempfolder you made, then ls will show you the Four-in-a-Row
files you copied here. Remove the program, then the .png files
with careful use of the * wildcard.

rm fourinarow.py
rm 4row_*.png

cd .. to get back to /home/pi and rm -r tempfolder


will remove the now empty folder. The -r (recursive) option
is necessary for directories, and will also remove the contents
if any remain.
In the next chapter, we’ll delve into file permissions and updating
your Pi’s software from the command line.

[ Read/Write Text ] 15
ESSENTIALS

[ CHAPTER THREE ]
PERMISSION
TO INSTALL We look at Raspbian’s efficient system for installing
and updating software, among other things

16 [ Chapter Three ]
[ CONQUER THE COMMAND LINE ]

nstalling software should be easy, but behind every piece of


I software is an evolving set of dependencies that also need
installing and updating. Keeping them separate reduces
unnecessary bloat and duplication, but adds the potential for bugs,
missing files, and even totally unresolvable clashes.
Fortunately, Debian GNU/Linux cracked the problem back in
[ SHARED the 1990s with the Debian Package Management system and the
RESPONSIBILITY ]
Advanced Package Tool (APT) – and Debian-based systems, like
If you share Ubuntu and the Pi’s Raspbian, inherit all of the benefits. Here we’ll
your Pi, read up show you the basics you need to know to install new software and
on sudo and
the visudo keep your system up to date from the command line, and then look at
command to the not entirely unrelated field of file ownership and permissions.
find how to Using the apt command to update your system’s list of installable
give limited but
useful admin software should be as simple as issuing the command like so:
privileges to the apt‑get update. Try this logged in as user pi, though, and you’ll
other users. just get error messages. The reason for this is that changing system
software on a GNU/Linux (or any type of UNIX) system is a task
restricted to those with administrative permissions: the godlike
superuser, or admin, also known as root.

Raspbian’s software
repository contains many
thousands of freely
installable apps, just a
command away from use

Every file, folder,


and even hardware
component should have
just enough permission
for you to use it – but not
be over-accessible at
the risk of security

[ Permission to Install ] 17
ESSENTIALS

Fig 1 Raspbian
updates its listing
of thousands of
available apps,
providing you give it
admin permissions

Pseudo root, su do
We’ll get onto permissions properly a bit later, but for now you’ll be
pleased to know that you can fake it, using the sudo command. sudo
potentially offers a fine-grained choice of permissions for users and
groups to access portions of the admin user’s powers. However, on
the Pi, Raspbian assumes, quite rightly, that the default user will be
someone just wanting to get on with things, and sudo in front of a
command will pretty much let you do anything. You have been warned!
The following two commands will update Raspbian’s installed
software (Fig 1):

sudo apt-get update


sudo apt-get upgrade

You can wait for one to finish, check everything is OK, then issue the
other command, or you can save waiting and enter both together with:

sudo apt-get update && sudo apt-get upgrade

The && is a Boolean (logical) AND, so if the first command doesn’t


run properly, the second one will not run at all. This is because for a
logical AND to be true, both of its conditions must be true.
It’s always worth running the update command before installing
new software, too – minor updates are made even in stable
distributions such as Raspbian, to address any issues. We’ve just

18 [ Chapter Three ]
[ CONQUER THE COMMAND LINE ]

run an update, so no need to repeat that for now. Sticking with


a command‑line theme, we’re going to install an old suite of
terminal games:

sudo apt-get install bsdgames

Searchable list
It is possible to find particular apps with apt-cache search:
apt‑cache search games. You can also examine individual
packages with apt-cache show: apt-cache show bsdgames.
APT is actually a front end to the lower-level dpkg, which you can
call to see what you have installed on the system: dpkg -l. Even
on a fresh system, that’s a large listing: we’ll show you how to get
useful information from such listings another time.
Downloaded packages hang around in /var/cache/apt and if you
find yourself short on disk space, issuing sudo apt-get clean will
clear out the archive, without affecting the installed software.
Now, remember the extra details that ls -lh showed us in
chapter 1? Try ls -lh /etc/apt.
That -rw-rw-r-- at the beginning of the listing for sources.list
comprises file attributes, telling you who may use the file. Other
entries in the listing have a d at the beginning, indicating they are
directories. You’ll also see hardware devices have a c here, for character
device – ls -l on /dev/input, for example. On Linux, everything is a
file, even your mouse! A dash (-) at the start tells us this is just a regular [ FREE TO USE ]
file; it’s the remaining nine characters that cover permissions.
Software in
Every file has an owner and a group membership. Files in your home the Raspbian
directory belong to you. If you’re logged in as user pi and ls ~ -l, you’ll repository is
see pi pi in each listing, telling you the owner and the group. Note that not just free to
use, but freely
we put the switch at the end this time: that’s a bad habit under certain modifiable and
circumstances, but we’re just showing you what’s possible. Owner and redistributable.
group aren’t always the same, as ls -l /dev will show you. Free software,
like Raspbian’s
Debian base, is
File attributes built on sharing:
The file attributes, after the file type, are three groups of three for education
and for building
characters (rwx) telling you which users may read, write or execute the community.
file or directory for, respectively, the user who owns the file, the group

[ Permission to Install ] 19
ESSENTIALS

owner, and everyone else (‘others’). Execute permissions are needed


[ PROBLEMS? ] to run a file if it’s a program – such as launcher.sh which runs the
Python games in your usr/share/python_games folder, and thus it has
Fine-grained
permissions the x – and for directories, so that you may cd into them.
make for greater cd into usr/share/python_games and then enter the command
security, but
can trip you up.
sudo chmod a-x launcher.sh – the a stands for all (user, group and
Typing sudo others), use u, g, or o to just change one. Try opening Python Games
in front of a from the main menu and it won’t work. We could restore normal
command that
running with sudo chmod a+x launcher.sh, but instead we’ll use:
doesn’t work is
both a diagnosis sudo chmod 755 launcher.sh.
and a quick
workaround of
a permissions
Octal version
problem. Those numbers are an octal representation of user, group, and
others’ permissions: in each case, read is represented by 4, write
by 2, and execute by 1, all added together. So here we have 7s for
read+write+execute for user, and 5 for read+execute for group and all
other users. ls -l and you’ll see we’re back to -rwxr-xr-x.
You can use chown to change who owns a file and chgrp to change
which group it belongs to. Make a new text file and sudo chown
root myfile.txt – now try editing it and you’ll find that while you
can read the file, you can no longer write to it. You can also make a
file that you can write to and run, but not read!
In the next chapter, we’ll be doing useful things with the output of
our commands; before moving on, though, why not try your hand at
robots from the bsdgames package we installed?

The id command
shows what
group access
you have, for
permission to
use and alter
files and devices

20 [ Chapter Three ]
ESSENTIALS

[ CHAPTER FOUR ]
MANIPULATING
TEXT
Discover pipes and learn how to connect multiple simple
commands together for more powerful text processing

[ Manipulating Text ] 21
ESSENTIALS

Building on simple
commands. The arrows
connect to streams and
files (input or output)
while pipes chain the
output of one program
to the input of another

If you know there’s more


than one item the same
and you don’t want to
see it, or need a new list
without duplicates, uniq
will get rid of the spares

he UNIX family of operating systems, which includes other


[ ABSOLUTE
PATH ]
T flavours of GNU/Linux and also Apple’s macOS, deals with
data from commands as streams of text. This means that
We’re using ~/ commands can be chained together in countless useful ways. For now,
mylisting4.txt though, we’ll focus on giving you a firm foundation to building your
with ~ short for
/home/pi. If you own custom commands.
cd to ~ then you
can simply use
the file name
Getting our feet wet
without the ~/ When a command is called at the terminal, it is given three streams,
known as standard input (stdin), standard output (stdout), and
standard error (stderr). These streams are plain text, and treated by
the Pi as special files. As we noted in chapter 3, ‘everything is a file’:
this is what gives the Pi and other UNIX family systems the ability to
put together simple commands and programs to build complex but
reliable systems.
Normally, stdin is what you enter into the terminal, while stdout
(command output) and stderr (any error messages) appear together.
The reason the last two have a separate existence is that you may want
to redirect one of them – error messages, for example – somewhere
away from the regular output your commands produce. We’ll look
at separate error messages later, but first we need to know how to
redirect and connect our output to other commands or files.
Connecting commands together are pipes, the ‘|’ symbol found
above the backslash on both GB and US keyboards (although the two

22 [ Chapter Four ]
[ [CONQUER
CONQUERTHE
THECOMMAND
COMMANDLINE
LINE] ]

keyboards for English speakers place the \ respectively to the left


of Z, and at the far right of the home row). When you type a command
such as ls -l, the output is sent by Raspbian to the stdout stream,
which by default is shown in your terminal. Adding a pipe connects that
output to the input (stdin stream) of the next command you type. So…

ls -l /usr/bin | wc -l

…will pass the long listing of the /usr/bin directory to the wordcount
(wc) program which, called with the -l (line) option, will tell you how
many lines of output ls has. In other words, it’s a way of counting how
many files and folders are in a particular directory.

Search with grep


One of the most useful commands to pass output to is grep, which
searches for words (or ‘regular expressions’, which are powerful
search patterns understood by a number of commands and
languages), like so:

grep if /usr/share/python_games/catanimation.py

This displays every line in the catanimation.py file containing the


character sequence ‘if’ (Fig 1, overleaf) – in other words not just the
word ‘if’, but words like ‘elif’ (Python’s else if), and words like ‘gift’
if they were present. You can use regular expressions to just find lines
with ‘if’, or lines beginning with ‘if’, for example.
Piping search results and listings to grep is the way we find a needle
[ REGEXP ]
in one of Pi’s haystacks. Remember dpkg from the last chapter, to see
what was installed? Try… Regular
expressions
(regexp)
dpkg -l | grep -i game are special
characters used
in text searches,
…to remind yourself which games you’ve installed (or are already such as [a-z]
installed). The -i switch makes the search case insensitive, as the to match any
program may be a ‘Game’ or ‘game’ in the description column. letter (but not
numbers), and
A simple dpkg -l | more lets you see output a page at a time. ^ to match to
sort will, as the name suggests, sort a listing into order, with various the beginning of
tweaks available such as -f to bring upper and lower case together. a line.

[ Manipulating Text ] 23
ESSENTIALS

Fig 1 No matter
how long the
[ FILING file, grep will
HOMEWORK ] dig out the
lines you need.
There are many It’s also handy
more commands for finding the
beyond grep, results you want
from a multi-
sort and
page output
uniq that can
be chained One way to collect unsorted data is to combine lists. sort will put the
together. Take
a look at cut if combined listing back in alphabetical order:
you’re feeling
adventurous. ls ~ /usr/share/python_games | sort -f

Suppose you copied one of the games to your home directory to


modify: you know it’s there, but you don’t want to see the same name
twice in the listings. uniq will omit the duplicated lines or, with the -d
switch, show only those duplicates.

ls ~ /usr/share/python_games | sort -f | uniq

File it away
Pipes are not the only form of redirection. > (the ‘greater than’ symbol)
sends the output of a program into a text file, either creating that text
file in the process, or writing over the contents of an existing one.

ls /usr/bin > ~/mylisting4.txt

Now look in mylisting4.txt and you’ll see the output of ls


/usr/bin. Note that each item is on a separate line (Fig 2). Your
terminal displays multiple listings per line for space efficiency;
however, for easy compatibility between commands, one listing
per line is used. Most commands operate on lines of text; e.g., grep
showed you in which lines it found ‘if’. Note that some commands
need a dash as a placeholder for the stdin stream being piped to them:

echo "zzzz is not a real program here" | cat mylisting4.txt -




24 [ Chapter Four ]
[ CONQUER THE COMMAND LINE ]

Appending
If you want to add something to the end of a file without overwriting
the contents, you need >>.

echo "& one more for luck!" >> ~/mylisting4.txt

echo simply displays whatever is in the quote marks to stdout; the -e


switch lets you add in special characters, like \n for newline (see below).
You can look at the last few lines of a file with tail ~/mylisting4.txt.
< will link a program’s input stream to the contents of a file or stream.
Make an unsorted list to work on, and sort it:

echo -e "aardvark\nplatypus\njellyfish\naardvark" >


list1
sort < list1

You can also combine < and >:

head -n 2 < list1 > list2

…will read from list1, passing it to head to take the first two lines,
then putting these in a file called list2. Add in a pipe:

sort < list1 | uniq > list3

Lastly, let’s separate that stderr stream: it has file descriptor 2 (don’t
worry too much about this), and 2> sends the error messages to any file
you choose:

cat list1 list2 list3


list42 2>errors.txt

The screen will display the ‘list’


files you do have, and the ‘No such
file or directory’ message(s) will end
up in errors.txt – 2>> will append
Fig 2 With redirection, you can get all of the output from
the messages to the file without
a command saved straight into a text file. Save your error
overwriting previous contents. messages to ask about them on the forums!

[ Manipulating text ] 25
ESSENTIALS

[ CHAPTER FIVE ]
CUSTOMISE THE
COMMAND LINE We make Raspbian a little more personal as we get it
to behave and look just the way we want it to

26 [ Chapter Five
One ]
[ CONQUER THE COMMAND LINE ]

Share your Pi:


make new user
accounts and
others can log
in or switch
users from a
command-line
session

The command- ake a look at that blinking cursor on your terminal, and at
line environment
is personal to
each user. You
T what’s behind it: pi@raspberrypi ~ $
The $ is known as the ‘dollar prompt’, awaiting your
can change your
identity with or command; before it you see the ~ (tilde), shorthand for ‘home’ – which
without a change is /home/pi in this case. Before that is [user name]@[computer name],
of environment,
depending upon in the form pi@raspberrypi. Not only is this informative (at least if
what you need to you’ve forgotten who and where you are), but it’s also something you
do in another role
can change and personalise.

New user
Let’s start with that user name: pi. If more than one person in your
family uses the Pi, you may want to keep the pi user for shared
projects, but set up individual login accounts for family members,
including yourself. Creating a new user in Raspbian is easy: sudo
adduser jo will create a new user account named jo. You will be
prompted for a password (pick a good one) and lots of irrelevant info
(dating back to shared university computers of the 1970s) that you can
safely ignore by just pressing ENTER at each prompt. Now we have
a user account for jo, have a look at /home/jo. Does it look empty?
Use ls -A. Jo has never logged into the computer, so you will see the
absence of most of the contents of /home/pi for now, but there is a
.bashrc and a couple of other config files.

[ Customise the Command Line ] 27


ESSENTIALS

Not every user has a home


directory and logs in: enter
cat /etc/passwd and you’ll see
a lot of users listed that aren’t
people. This is because files and
programs running on a UNIX-
Above Bash stores type system have to belong to a user (and a group – take a look at
information, from
/etc/group), as we saw back in chapter 1 when we did ls -l. The
your previous
‘present working user passwords are fortunately not listed in the /etc/passwd file in
directory’ to
plain text, so if you want to change a password you’ll need to use the
who you are, in
environment passwd command: sudo passwd jo will change the password for
variables like
user jo. If you’re logged in as user pi, then simply calling passwd will
OLDPWD and USER.
See individual prompt you to change pi’s password.
variables with e.g.
Transformations in the virtual world are always easier than those
echo $USER,
or view them all in nature, and this is the case with switching from being ‘pi’ to ‘jo’: we
with env
use the change (or substitute) user command, su, like so: su jo. After
typing this, you should see the prompt change to jo@raspberry; you
can also confirm who you are logged in as with whoami.

[ HOME RUN ] Changing identity


If you’re logged su - jo (note the dash) is usually preferred, as you’ll gain all of jo’s
in as user pi, then specific environment settings, including placing you in /home/jo.
~ is a shortcut to
/home/pi Note that on many other Linux systems, su on its own will enable you
– but ls ~jo to become the root or superuser, with absolute powers (permissions
can be used as to run, edit, or delete anything). Raspbian (and some other popular
a shortcut to
list /home/jo, GNU/Linux systems like Ubuntu) prefer sudo to run individual
substituting any programs with root permissions. Root’s godlike powers may be
other user name temporarily attained with sudo -s – try it (as user pi) and note how
as desired, with
tab completion the prompt changes (enter exit to exit) – but it’s generally a bad
working after ~j idea to run with more permissions than you need! For any user, you
is typed. can customise elements of their command-line use most simply by

28 [ Chapter Five ]
[ CONQUER THE COMMAND LINE ]

editing ~/.bashrc. Take a look through that configuration file now


(as user jo): more ~/.bashrc. Note a number of variables in all capital
letters, such as HISTSIZE and PS1. The last of these controls the
prompt you see, currently jo@raspberry ~ $. To change it (for
the duration of your current terminal session), try something like:
export PS1="tutorial@magpi > ".
This is a temporary change: type exit and you’ve left the su value
of jo, so you’ll see pi@raspberry ~ $ once more. If you su back to jo,
the magpi prompt will still be gone. To make your change permanent,
you need to put the PS1 value you want into ~/.bashrc. A search around
the web will bring up many fancy options for better customising the
Bash prompt.
The ~/.bashrc file is read upon each login to a Bash session, or in
other words, every time you log into a console or open a terminal.
That’s unless you change Raspbian’s default shell away from Bash,

Transformations in the
virtual world are always
easier than those in nature
something you may have reason to do in the future – there are
interesting alternatives available for extra features or for smaller
memory footprint – but let’s not worry about that for now. You can [ BASIC
put all sorts of commands in there to personalise your environment: ACCOUNT ]
command aliases are great for regularly used combinations. adduser creates
a new user, then
Alias takes care of
all of the extra
As user pi, see what’s there with: grep alias ~/.bashrc. There are details like
a few aliases already in there, particularly for the ls command. One making a home
directory. If all
entry is: # alias ll='ls -l'. This sounds quite useful, although the
you want is a
# indicates that it is ‘commented out’, which means that it will not be user created
read by Bash. Open .bashrc in your text editor (double-click the file in with no extra
frills, then the
File Manager after pressing CTRL+H to show hidden files) – the simple
command you
Text Editor will do for now as although we’ve touched on using nano want is useradd.
for editing text from the command line, we aren’t going to go into this

[ Customise the Command Line ] 29


ESSENTIALS

in detail until the next chapter. Removing the # will mean that now
[ WHO AM I? ] when you type ll, you’ll get the action of running ls -l. Handy,
but we could make it better. Change it to: alias ll='ls -lAhF' and
From a virtual
console (CTRL+
you’ll get an output in kB or MB, rather than bytes, along with trailing
ALT+F1 to F6), su slashes on directory names and the omission of the ever present .
and that’s who and .. (current and parent) directories. Changes take effect after you
you’re logged
in as. From
next start a Bash session, but then you can just run that alias as a
an xterm, you command (Fig 1). To disable an alias for a session, use: unalias ll.
can change to
someone else,
but start another
Key point
app from the We’ll end with the very first thing many users need to change:
menu and you’ll the keyboard map. The system-wide setting is found in
be back to your
original login.
/etc/default/keyboard, but often you need to change it just for
individual users. If £ signs and letters without accents are not
sufficient for them, log in as the user who wants a different
keyboard, or add sudo and the correct path to the commands below.
For example, for a Greek keyboard:

touch ~/.xsessionrc
echo "setxkbmap el" > ~/.xsessionrc

Replace el with pt, us, or whatever language you desire. Note that
the config file we created – .xsessionrc – holds settings that are read
when we log in to the GUI, so the keyboard setting will cover not just
the terminal, but every app used in the session.

Fig 1 Those
terse, two- or
three-letter
commands are
not set in stone:
make your own
shortcuts to
keep, or just
for use over a
specific session

30 [ Chapter Five ]
ESSENTIALS

[ CHAPTER SIX ]
CONNECTING
DISKS
For chapter six, we’re tackling the
management of removable storage

[ Connecting
[ Don’t Panic
Disks ] 31
ESSENTIALS

Raspbian, while
presenting a simple
surface, also lets
you dig deep for
information when you
need to change default
behaviour. That’s real
user-friendliness!

Even simple
lthough Raspbian will, when booted as far as the GUI,
A
utilities have
multiple uses: df, automatically mount any disk-type device (USB flash key,
by showing space
available, reminds camera, etc.) plugged into the USB port and offer to open it
the user which disks for you (Fig 1, overleaf), you may wish to get more direct control of the
are mounted and
can be accessed process. Or, as is more often the case, you may want to mount a disk
by the Pi when the Raspberry Pi is running a project that doesn’t involve booting
as far as the GUI, as it’s not necessary for most sensor projects.

Connected or mounted?
Plugging a drive or flash memory device into your Pi (connecting it to
[ IN DEPTH ] your computer) is not the same as making it available for the Pi to
If you want to interact with (mounting it) so that Raspbian knows what’s on it and
delve deeper into can read, write, and alter files there. It’s an odd concept to accept: the
what goes on
inside Raspbian
computer knows there’s a disk plugged in, but its contents remain
and other GNU/ invisible until the Pi is told to mount it. It’s a bit like seeing a book on
Linux systems, your shelf, but not being allowed to open or read it.
try Brian Ward’s
excellent
Disks and disk-like devices are mounted by Raspbian on a virtual file
book, How system, and you’ll rarely need to worry about what goes on beneath
LinuxWorks that layer of abstraction, but to see some of it, type mount. The
(magpi.cc/
ZEhaBF).
information displayed is of the form device on mount point, file-system
type, options. You’ll see lots of device ‘none’ for parts of the virtual

32 [ Chapter Six ]
[ CONQUER THE COMMAND LINE ]

system that you don’t need to worry about; the devices that concern us
[ DISK &
start with /dev/ and have names like /dev/mmcblk0p1 for partitions DISK SPACE ]
of the Pi’s SD card, and /dev/sda1 for plugged-in USB drives.
Plug in a USB drive (a flash drive should work fine, but some hard The df
command shows
drives may require a separate power supply). Like most computer you space on
desktops, Raspbian automatically mounts the disks, so (unless mounted drives:
you boot to a virtual console) you’ll need to unmount it. mount will just type df and
you’ll also get a
show an entry beginning something like /dev/sda1 on /media/pi/ list of connected
UNTITLED… and you can unmount with sudo umount /dev/sda1 drives. It’s more
(yes, that is umount without an ‘n’). An error will result if the device readable than
mount -l, though
is in use, so change directory and/or close apps using files from the lacking file type
device. Now we can mount it just the way we want. info. It’s also
quicker to type!

Finding the disk


The /dev/sda1 refers to the first, or only, partition (a section of the hard
drive that is separated from other segments) on /dev/sda. The next
device plugged in will be /dev/sdb1. You can see what’s being assigned
by running tail -f /var/log/messages, then plugging in the USB
device. On other Linux systems, if /var/log/messages draws a blank,

An error will result if the device is in use,


so change directory and/or close apps
try /var/log/syslog. Stop the tail with CTRL+C. Another way of seeing
connected devices that aren’t necessarily mounted is fdisk, a low-level
tool used to divide disks up into partitions, before creating file systems
on those disks (see the ‘Format’ box on page 35). Called with the list
option, sudo fdisk -l, it performs no partitioning, but simply lists
partitions on those disks connected to your Pi. It also gives file-system
information, which you need in order to mount the disk. Lastly, you
need a mount point (somewhere to place the device on the file-system
hierarchy) with appropriate permissions. Create one with:

sudo mkdir /media/usb


sudo chmod 775 /media/usb

[ Connecting Disks ] 33
ESSENTIALS

Fig 1 Raspbian
wants to mount
plugged-in disks,
and take care of
the details for
you – note that
the GUI tells you
it’s ‘Windows
software’ – while
the command
line beneath has
information for
you to take control
when you need
the job done in
a particular way,
telling you it’s an
NTFS file system

Mount the disk with sudo mount -t vfat /dev/sda1 /media/usb,


where vfat (or NTFS or ext2) is the file-system type.

File-system table
Raspbian knows which disks to mount at boot time by reading the
file-system table (/etc/fstab), and we could put our /dev/sda1 in
there, but if we start up with two drives plugged in, the wrong one
may be selected. Fortunately, disks (or rather, disk partitions) have
unique labels known as UUIDs randomly allocated when the partition
is created. Find them with sudo blkid, which also helpfully tells you
the label, if any, that often contains the make and model of external
drives, or look in /dev/disk/by-uuid.
For an NTFS-formatted drive, we called sudo nano /etc/fstab and
added the following line to the end of the file:

/dev/disk/by-uuid/E4EE32B4EE327EBC /media/usb
ntfs defaults 0 0

This gives the device name (yours will be different, of course),


mount point, file-system type, options, and two numeric fields: the
first of these should be zero (it relates to the unused dump backup
program), while the second is the order of check and repair at boot:
1 for the root file system, 2 for other permanently mounted disks for
data, and 0 (no check) for all others. man mount will tell you about
possible options.

34 [ Chapter Six ]
[ CONQUER THE COMMAND LINE ]

Editing with nano


We touched briefly on nano in
chapter 2. Looking in a little more
depth, the first thing to be aware
of is the dozen shortcuts listed
across the bottom two lines of the
terminal: each is the CTRL key
(represented by the caret ^) held
at the same time as a single letter
key. For example, ^R for ReadFile
(i.e. open), ^O for WriteOut (in
other words, save), and ^X for
Exit. Remember those last two for
now, and you’ll be able to manage nano. However, if you learn more of Fig 2 Once we’ve
put our removable
them, you will really race through your editing tasks. disk in the file-
While nano lacks the power features of Emacs and Vim, its two system table
(/etc/fstab),
main command-line code editor rivals, it has useful features such mount -a will read
as a powerful Justify (^J), which will reassemble a paragraph of line- the config from
there to mount
break strewn text into an unbroken paragraph, or apply line breaks at your disks, saving
a fixed character length. This is a legacy of its development for email you from having
to remember
composition. ^K cuts the line of text the cursor is on, but it isn’t just the details
a delete function: each cut is added to a clipboard. ^U will paste the
entire clipboard at the cursor position: it’s great for gathering together
useful snippets from a longer text.
Hit ^O to save fstab, and the shortcut listing changes, with many
[ FORMAT ]
now beginning M instead of ^ – this is short for Meta, which means
the ALT key on your keyboard (once upon a time, some computers had Copying a disk
image negates
several modifier keys, such as Super and Hyper). One ‘hidden’ shortcut the need to
after ^O is that at this point, ^T now opens a file manager to search for format the disk.
the file/directory where you want to save. Should you
need to format
After saving, exit nano; now sudo mount -a will mount the external a new partition,
drive at the desired mount point (Fig 2), regardless of what else is or convert a disk
plugged in. If you have other new entries in /etc/fstab, then sudo to ext4 format,
read the manual:
mount /media/usb1t (or whatever entry you put in fstab) will mount man mkfs and
just that chosen device if you don’t want to mount any of the others. for individual
Having got inside connected disks, the next chapter will see us file-system types
such as man
accessing all of the Pi, but remotely, from anywhere on the planet with mkfs.ext4
an internet connection.

[ Connecting Disks ] 35
ESSENTIALS

ESSENTIALS

[ CHAPTER SEVEN ]
PREDICTABLE
NETWORKING
In this chapter, we give the Raspberry Pi a permanent
network address of its own

36 [ Chapter Seven
One ] ]
[ CONQUER THE COMMAND LINE ]

aspbian takes care of automatically connecting in most


R situations, but sometimes you need to override automatic
configurations to ensure a consistent network setting for your
Raspberry Pi project: Raspbian has the tools, and we’ll show you the
essentials you need to stay connected.
Plug an Ethernet cable from your ADSL router / modem to your
Raspberry Pi (or connect via wireless LAN) and, automatically,
Raspbian knows where it is on the network, and can talk to the
outside world.
All of this is thanks to DHCP – Dynamic Host Configuration Protocol
– which provides network configuration for every device connected
into a network. Typically, this comes in the form of an IPv4 (Internet
Protocol version 4) address, a pair of four numbers separated by a
period. For example: 192.168.0.37
The first two sets of numbers, 192.168, mark the start of a private
range. These are the numbers for all devices in your house, ranging
from 192.168.0.0 to 192.168.255.255.
Check your Raspberry Pi’s current connection with the ifconfig
command. This should show, amongst others, a line like inet
192.168.0.37 (with your own numbers). This will be below the eth0

The IP address is likely


to be a private address
in the range beginning
192.168.0.0. Here we
can see it beneath eth0
(because our Raspberry
Pi is connected via an
Ethernet cable). Our
address is 192.168.0.37

The ifconfig
command tells
you information
about your
Raspberry Pi’s
network address

[ Predictable Networking ] 37
ESSENTIALS

section if you are connected via Ethernet, or under the wlan0 section if
you’re connected wire wireless LAN.
A faster way to get your IP address is to enter hostname -I on the
command line.

How to set up up your Raspberry Pi to have a static


IP address
Usually when you connect a Raspberry Pi to a local area network (LAN),
it is automatically assigned an IP address. Typically, this address will
change each time you connect.

You might want your Pi to boot up


with the same IP address each time
Sometimes, however, you might want your Pi to boot up with the
same IP address each time. This can be useful if you are making a small
self-contained network, or building a standalone project such as a robot.
Here’s how to do it.
Edit the file /etc/dhcpcd.conf as follows (Fig 1):
Type sudo nano /etc/dhcpcd.conf at the command prompt. Scroll
to the bottom of the script, and add the following lines:

Fig 1 Edit the


/etc/dhcpcd.conf
file to determine
which static IP
address to
use with a
Raspberry Pi

38 [ Chapter Seven ]
[ [CONQUER
CONQUERTHE
THECOMMAND
COMMANDLINE
LINE] ]

Fig 2 Use ping


interface eth0 from another
static ip_address=192.168.0.2/24 computer to detect
if your Raspberry
static routers=192.168.0.1 Pi is responding to
static domain_name_servers=192.168.0.1 8.8.8.8 network requests

interface wlan0
static ip_address=192.168.0.2/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1 8.8.8.8

Save the file with CTRL+O and then exit nano with CTRL+X.

Your Raspberry Pi will now boot up with the IP address 192.168.0.2


every time; we didn’t use 192.168.0.1 as this is reserved for the router.
You can of course use any address you like, but in the configuration
above, the range must be between 192.168.0.2 and 192.168.0.255.
Reboot with sudo shutdown -r now. Log in and type hostname
-I. You should then see the IP address you set in the eth0 or wlan0
entry (192.168.0.2).

[ Predictable Networking ] 39
ESSENTIALS

Normally you don’t want your computer set to use a static IP address.
You can change the network configuration back by editing dhcpcd.conf
again using sudo nano /etc/dhcpcd.conf. Remove all the lines you
added in the previous step, then save the file again.

Ping!
Ping is the most basic tool in the network testing armoury, but one
which is often called upon. It sends an ICMP (Internet Control Message
[ DOMAIN NAME
SERVERS ] Protocol) ECHO_REQUEST to a device on the network. ICMP is built into
every connected device and used for diagnostics and error messages:
We added a ping will produce a reply from the pinged machine, which tells you
192.168.0.1
8.8.8.8 to
it is on, and connected, and that the network is working between you
our domain_ and it. Information about packets lost, and time taken, also helps with
name_servers fault diagnosis.
line in /etc/
dhcpcd.conf.
A successful ping localhost from the Raspberry Pi tells you not just
This is for the that the local loopback interface is working, but that localhost resolves
Google public to 127.0.0.1, the local loopback address. Name resolution is the cause of
domain name
server (DNS). The
many computing problems – see ‘Domain Name Servers’ box. Now ping
DNS maps public the Pi from another machine on your local network: ping 192.168.0.2
IP addresses like (Fig 2) – you’ll need to use the static IPv4 address you set, rather than ours,
raspberrypi.org
to IP addresses
of course. If you’re doing this from a Windows machine, ping defaults to
(in this case five attempts; from another UNIX machine (another Pi, a Mac, or Ubuntu
93.93.128.230). or other GNU/Linux), it will carry on until you stop it with CTRL+C, unless
You’ll need
to add a DNS
you set a number of ECHO_REQUEST sends with -c like so:
reference to
access websites ping -c 5 raspberrypi.org
in a browser.

IPv6
The four-digit IP address style we use (such as 192.168.0.2) is IPv4.
A newer standard, IPv6, is becoming more common. These are
longer 128-bit addresses represented in hexadecimal (for example,
fd51:42f8:caae:d92e::1). Look at the example code in dhcpcd.conf for
setting up a static address with IPv6.

Free / public DNS


As well as dynamic DNS providers, some of those listed at FreeDNS.com
offer public DNS servers. For a wider listing of alternatives to Google’s DNS
servers, have a search on Google itself.

40 [ Chapter Seven ]
ESSENTIALS

[ CHAPTER EIGHT ]
STOPPING A
PROCESS
As close to perfect as Raspbian is, things can go wrong . In this chapter,
we learn that there’s no need to turn the Raspberry Pi off and on again:
just kill the process!

[ Stopping
[ Don’t Panic ]
A Process 41
ESSENTIALS

Programs running in
the terminal can be put
to sleep by sending to
the background – from
where they can easily be
brought back with fg
Keep an eye on your
processes, and you’ll also
be able to see what’s
hogging the Pi’s CPU and
memory resources

ver lost the ‘off switch’ for a program? Sometimes a piece of


E software you’re running seems to have no inclination to stop:
either you cannot find how to quit, or the app has a problem,
and won’t respond to your Q, CTRL+C, or whatever command should
close it down.
There’s no need to panic, and certainly no need to reboot: just
identify the process and quietly kill it. We’ll show you how, and look at
what else can be done with knowledge of processes.

Processes
Find the many processes running on your Pi with the ps command. As
a minimum, on Raspbian, it’s usually called with the a and x switches –
which together give all processes, rather than just those belonging to a
user, and attached to a tty – and with u to see processes by user; w adds
wider output, and ww will wrap over the line end to display information
without truncating.
Type ps auxww to see, then try with just a or other combinations.
You will notice that these options work without the leading dash
seen for other commands. Both the lack of dashes, and the particular
letters, a and x, date back to the original UNIX ps of the early 1970s,
maintained through various revisions by one of UNIX’s two family

42 [ Chapter Eight ]
[ CONQUER THE COMMAND LINE ]

branches, BSD, and baked into the first GNU/Linux ps. UNIX’s other
branch, System V, had extended and changed ps with new options and [ KEEP ON TOP ]
new abbreviations for command switches, so for ps ax you may see When using a
elsewhere ps -e (or -ef or -ely to show in long format). virtual console,
The ps aux listing has various headers, including the USER which it can be worth
keeping htop
owns the process, and the PID, or Process IDentification number. This running so that
starts with 1 for init, the parent process of everything that happens in if there are any
userspace after the Linux kernel starts up when you switch the Pi on. problems, you
can CTRL+ALT-
Knowing the PID makes it easy to kill a process, should that be FN there for a
the easiest way of shutting it down. For example, to kill a program quick look for any
with a PID of 3012, simply enter kill 3012, and to quickly find the problems – even
if the GUI freezes.
process in the first place, use grep on the ps list. For example, locating
vi processes:

ps aux | grep -i vi

The -i (ignore case) isn’t usually necessary, but occasionally a


program may break convention and contain upper-case letters in
its file name. You can also use killall to kill by program name:
killall firefox

Piping commands
Naturally, you can pipe ps’s output to select the PID and feed directly
to the kill command:

kill $(ps aux | grep '[f]irefox' | awk '{print $2}')

We don’t have space for an in-depth look at awk (we’re using it here
to print the second field of grep’s output: the PID), but the [f] trick
at the beginning of Firefox (or whatever named process you want to
kill) prevents the grep process itself being listed in the results; in the
vi example above, grep found the grep process itself as well as vi (and
anything with the letter sequence vi in its name).
The output of ps also shows you useful information like percentage
of memory and CPU time used, but it’s more useful to see these
changing in real time. For this, use top, which also shows total CPU
and memory use in the header lines, the latter in the format that you
can also find by issuing the command free. For an improved top:

[ Stopping A Process ] 43
ESSENTIALS

[ QUICKER BOOT ]
sudo apt-get install htop
The start up
process of
htop is scrollable, both horizontally and vertically, and allows you
Raspbian
Wheezy is to issue commands (such as k for kill) to highlighted processes. When
controlled by the you’ve finished, both top and htop are exited with Q, although in htop
traditional SysV
you may care to practise by highlighting the htop process and killing it
init. Raspbian
Jessie, like other from there (see Fig 1). htop also shows load over the separate cores of
GNU/Linux the processor if you have a Pi 2 or 3.
distributions,
has moved to
the faster (but Background job
monolithic) Placing an ampersand (&) after a command in the shell, places the
SystemD – we
program in the background – try with: man top & and you’ll get an
touch on some of
the differences in output like: [1] 12768.
chapter 11. The first number is a job number, assigned by the shell, and the
second the PID we’ve been working with above. man top is now running
in the background, and you can use the job control number to work with
the process in the shell. Start some other processes in the background
if you wish (by appending &), then bring the first – man top – to the
foreground with fg 1. Now you should see man running again.
Fig 1 htop tells you
You can place a running shell program in the background by
what’s running, ‘suspending’ it with CTRL+Z. fg will always bring back the most
what resources
recently suspended or backgrounded job, unless a job number is
it’s using, and lets
you interact with specified. Note that these job numbers apply only within the shell
the process, even
where the process started. Type jobs to see background processes;
killing htop from
within htop jobs -l adds in process IDs (PID) to the listing.

Signals
When we send a kill signal from
htop, we are given a choice
of signal to send. The most
important are SIGTERM, SIGINT,
and SIGKILL.
The first is also the signal kill
will send from the command line
if not called with a modifier: it
tells a process to stop, and most
programs will respond by catching

44 [ Chapter Eight ]
[ CONQUER THE COMMAND LINE ]

the signal, and first saving any data


they need to save and releasing system
resources before quitting.
kill -2 sends SIGINT, which is
equivalent to stopping a program from
the terminal with CTRL+C: you could
lose data. Most drastic is kill -9 to
send SIGKILL, telling the kernel to let
the process go with no warning. Save
this one for when nothing else works.
Mildest of all is the Hang Up (HUP)
signal, called with kill -1, which many daemons are programmed to Fig 2 Everything
running has a
treat as a call to simply re-read their configuration files and carry on process ID (PID)
running. It’s certainly the safest signal to send on a critical machine. that can be used
to control that
program; find them
Staying on all with ps aux
nohup will run a program which will continue after the terminal
from which it is started has closed, ignoring the consequent SIGHUP
[ KEEP ON
(hangup) signal. As the process is detached from the terminal, error RUNNING ]
messages and output are sent to the file nohup.out in whichever
directory you were in when you started the process. You can redirect nohup is useful
for a program
it – as we did in chapter 4 – with 1> for stdout and 2> for stderr; &> is a that will be
special case for redirecting both stdout and stderr: running for
some time in the
background –
nohup myprog &>backgroundoutput.txt & perhaps a sensor
project you are
One use of nohup is to be able to set something in motion from a working on – until
you feel happy
SSH session, which will continue after an interruption. For example, enough to add
restarting the network connection to which you are connected: it to Raspbian’s
startup
processes.
sudo nohup sh -c "ifconfig wlan0 down && ifconfig
wlan0 up"

Note that the nohup.out log file created here will need sudo
privileges to read – or reassign with:

sudo chown pi:pi nohup.out

[ Stopping A Process ] 45
Another Random Document on
Scribd Without Any Related Topics
therefore referred it to me to give your Highness an account of what
was upon their hearts;—which was that if there was not a restraint
upon them, they had cause to fear they would put all into blood and
confusion, their party giving out they would down with the Major-
Generals, and Decimators, and the new militia, so that they do
apprehend it good for your Highness to consider beforehand what is
fit to be done. And therefore they think it necessary to appoint some
persons that shall have commissions dormant to some gentlemen,
that the honest party may know to whom to repair, and to that end,
at their next meeting, shall present you with names accordingly.
They think a recognition, as it may be penned, may keep some that
are most dangerous out, and better that they be kept out at first,
than afterwards your Highness be forced to turn them out. They
think it will be your wisdom not to suffer them to meddle with the
instrument of Government, but all that go into the House be
engaged to own it as it is, and not to meddle with altering any part
of it, without your Highness's consent. As also not to meddle with
what hath been done out of necessity by your Highness and Council,
in order to the peace and safety of the nation. Their hearts are with
your Highness to stand by you with their lives and fortunes, they
finding such a perverseness in the spirits of those that are chosen,
that, without resolution of spirit in your Highness and Council to
maintain the interests of God's people (which is to be preferred
before a thousand Parliaments) against all opposition whatsoever,
we shall return again to our Egyptian taskmasters. And therefore do
earnestly beg that the Lord would direct your heart what to do in
this juncture of affairs. And if Parliaments will not do it, then to take
such to your assistance as will stand by you in that work, which God
hath begun, and will yet undoubtedly own and carry on, maugre all
His enemies; and we judge it better to persist in the work of the
Lord than now we have put our hands to the plough to look back.
And although the murmurings and discontents of God's people,
together with all our unsuitable walkings under those precious
enjoyments we have from the Lord, may provoke Him to leave us to
be overcome by our enemies, and cause us to hang our harps upon
the willows, and cause the enemy to call for one of the songs of Sion
in a strange land; yet, if the Lord shall take pleasure in us, He will
cause His face to shine upon us, and carry us well through the seas
of blood that are threatened against us, and the waste howling
wilderness of our straits and difficulties, and at length bring us to
that blessed haven of reformation, endeavoured by us, and cause all
our troubles and disquiet to end in a happy rest and peace—when all
His people shall be one, and His name one in all your dominions,
which is and shall be the daily prayers of, my Lord, your Highness's
most humble and obedient servant to his power,
"Thos. Kelsey.
"Chatham, 26th August, 1656."
This advice was adopted, and between one and
two hundred of the persons returned were refused 1656, September.
their seats because of their disaffection to the
Protectorate Government.
The second Protectorate Parliament met on the
17th of September, 1656. Sir Harry Vane, now a Cromwell's
Speech.
prisoner, had been proposed in three places, but
had been elected in none. Haselrig had succeeded in securing his
return, but for a time he did not take his seat. After Dr. Owen had
preached at Westminster Abbey from the words in Isaiah xiv. 32
—"What shall one then answer the messengers of the nation? That
the Lord hath founded Zion, and the poor of his people shall trust in
it,"—adjourning to the Painted Chamber, Cromwell stood up, took off
his hat, and discoursed characteristically upon the Spaniards and
Papists, and the Cavaliers—upon the late rising—the levellers and
the Fifth Monarchy men—and also upon the Major-Generals. Then
he turned to the subject of religion. His practice since the last
Parliament, he said, had been to grant liberty to all who continued
quiet and peaceable. He was against such liberty of conscience as
might be repugnant to this. Let Baptists, Independents, and
Presbyterians be countenanced as long as they were thankful to
God, and made use of their liberty—not to interfere with others, but
"to enjoy their own consciences." Men who believed in free
justification by the blood of Jesus, and lived upon the grace of God,
claimed freedom as a debt due to God and to Christ; and God would
require it, if such Christians did not enjoy what they claimed. But his
Highness declared he would not suffer one Christian to trample on
the heels of another, or to revile, reproach, or provoke him. He
prayed that God would give hearts and spirits to keep things equal,
for striving after which he had "some boxes on the ear." Even
Presbyterians, at last, were beginning to see the justice of his
course, and petitions from them in certain counties shewed how
they did but desire liberty, and would "not strain themselves beyond
their own line." The Protector touched on another topic. For his own
part, he should think himself very treacherous if he took away tithes
till he could see the legislative power settle the maintenance of
ministers in another way. To destroy tithes was to cut ministers'
throats. Tithes, or some other public maintenance, formed "the root
of visible profession." He had also a word of favour for his
Commission of Triers and "Expurgators." They had a great esteem
for learning; but "neither Mr. Parson, nor Doctor in the University,
hath been reckoned stamp enough by those that made these
approbations." Grace must go with and sanctify learning. He
believed, he said, that God had "a very great seed" in the youth then
in the Universities, who, instead of studying books only, studied their
own hearts. "It was never so upon the thriving hand" as at that day.
Touching upon religion generally, the speaker added that the
Cavalier interest had been one of disorder and wickedness; that
fifteen or seventeen years before it had been a shame to be a
Christian. A badge then was put upon the holy profession. But a
blessed change had come, and now—since people esteemed it a
shame to be bold in sin and profaneness—God would bless them.
[127]

The second Protectorate Parliament walked in the steps of the


first, as it regarded the suppression of error and of fanaticism by
legal penalties. The month of December saw the new senators at
Westminster plunging into discussions upon the case of James
Naylor.
Lord President Laurence[128] and a few others
were disposed to interpret the views of this Case of James
Naylor.
notorious person as merely the extravagances of a
mystical temperament; but most of the members, horror-stricken at
his conduct, pronounced it utterly intolerable, and declared that it
deserved the severest chastisement from the magistrate. Mr. Samuel
Bedford[129] expressed his joy at finding that so many had adopted
such an opinion; for the nation's eyes were fixed upon them to see
what they would do for the cause of God; and he would not have
them lay down the business unfinished, but sit day and night until it
was perfected. Lord Lambert[130]—after alluding to the unhappy
man as having been unblameable in life, and a member of "a very
sweet society of an Independent Church"—intimated his own
readiness to punish the accused, should he be proved guilty of
blasphemy; only, not being hurried away by passion, like some
honourable members, he wished the subject to be referred to a
committee, that nothing might be done irregularly and in haste.
Major Edward Desborough,[131] though he did not speak with a view
of mitigating Naylor's offence, pointed out the fact that the people
who encouraged him and paid him homage were, in one sense,
worse than he. Some members would immediately have sent this
delinquent to the gallows; and at length the poor man actually was
doomed to be repeatedly whipped, set in the pillory, branded with
red-hot irons, and kept in prison with hard labour during the
pleasure of Parliament.[132] Even the Lord Protector said he would
not tolerate such offenders in his dominions.
At the time when this debate was carried on—
touching as it did the question whether 1656, December.
Government has a right to take cognizance of
purely religious offences—the Protector wrote two very significant
letters, which are here introduced in further illustration of his
religious policy. One was addressed to the municipal authorities of
Newcastle-upon-Tyne, with reference to some fears which the
Independents, who were the predominant party in the town, had
expressed, in consequence of his Highness's encouragement of the
Presbyterians in that neighbourhood. After an explanation of the
circumstance, he proceeds:—
"I, or rather the Lord, require of you that you
walk in all peaceableness and gentleness, Cromwell's
Letters.
inoffensiveness, truth, and love towards them, as
becomes the servants and Churches of Christ—knowing well that
Jesus Christ, of whose diocese both they and you are, expects it;
who, when He comes to gather His people and to make Himself 'a
name and praise amongst all the people of the earth,' He 'will save
her that halteth, and gather her that was driven out, and will get
them praise and fame in every land where they have been put to
shame.' And such 'lame ones' and 'driven-out ones' were not the
Independents only, and Presbyterians, a few years since, by the
Popish and prelatical party in these nations; but such are and have
been the Protestants in all lands, persecuted and faring alike with
you, in all the reformed Churches. And therefore, knowing your
charity to be as large as all the flock of Christ who are of the same
hope and faith of the Gospel with you, I thought fit to commend
these few words to you, being well assured it is written in your
heart, so to do with this, that I shall stand by you in the maintaining
of all your just privileges to the uttermost."[133] The Christian spirit
which breathes through this epistle commands our sympathy and
admiration. Every line testifies to that gentle love for all the true
disciples of Jesus Christ—which grew like a tender flower, which
gushed like a limpid stream, for the refreshment of his friends, out
of the depths of a strong and rugged nature such as made Cromwell
a terror to his enemies.
The other noticeable letter despatched from his Highness's
Cabinet about the same time, was intended for no other hands than
those of the renowned Cardinal Mazarin, the prime minister of
France—in answer to his Eminence's request for the toleration of
Catholics in England.
"The obligations, and many instances of
affection," says Cromwell, "which I have received 1656, December.
from your Eminency, do engage me to make
returns suitable to your merits. But although I have this set home
upon my spirit, I may not (shall I tell you I cannot?) at this juncture
of time, and as the face of my affairs now stands, answer to your
call for toleration (of Catholics here). I say I cannot, as to a public
declaration of my sense in that point; although I believe that under
my Government your Eminency, in the behalf of Catholics, has less
reason for complaint as to rigour upon men's consciences than
under the Parliament. For I have of some, and those very many, had
compassion, making a difference. Truly I have (and I may speak it
with cheerfulness in the presence of God, who is a witness within
me to the truth of what I affirm) made a difference; and, as Jude
speaks, 'plucked many out of the fire'—the raging fire of
persecution, which did tyrannize over their consciences, and
encroached by an arbitrariness of power upon their estates. And
herein it is my purpose, as soon as I can remove impediments, and
some weights that press me down, to make a farther progress, and
discharge my promise to your Eminency in relation to that."[134]
Cromwell did what many rulers do. Without having an intolerant law
repealed, he relaxed its execution. The time was not ripe for perfect
religious liberty. Cromwell understood its broad principles better than
Mazarin; but it was not given to the Protector, as it has been to his
posterity, to see the entire breadth of their practical application. The
letter shews some respect for the consciences of Catholics; but it
indicates, in the way of conceding liberty to that class of religionists,
difficulties over which at the time the writer had no control.
Evidently he was prepared to advance rather than recede in his
liberal treatment of a class of persons who, by the common consent
of almost all Protestants, were excluded from the enjoyment of the
political privileges of citizenship.
In those days of tardy intercourse with the
Continent, this last letter had scarcely reached its Extempore
Preaching.
destination when the gossips of London were all
astir with reports relative to Cromwell's escape from a great personal
danger. A story gained circulation, to the effect, that a hole had been
cut in the backdoor of Whitehall chapel, and that a basket of pitch,
tar, and gunpowder had been placed there, with a lighted match
hung over it, in order to blow up both the palace and the Protector.
A resolution of the Parliament to keep a day of thanksgiving followed
the discovery of this design—known in history as Sindercombe's plot
—whereupon a curious debate ensued upon the question, as to who
should preach the sermon for improving the event. Alderman Foot,
member for the city of London, proposed that Dr. Reynolds should
perform the office; when exceptions were taken to the "low voice" of
that eminent Presbyterian Divine. The same complaint was urged
with regard to Mr. Caryl, the Independent. "It is strange we should
not hear as well now as we did fourteen years ago," observed Lord
Strickland—one of his Highness's Council, and member for
Newcastle-upon-Tyne—to which Mr. Robinson, who represented
Yorkshire, added the remark—"Ministers tell us our faults. It is fit we
should tell them theirs. Their reading of sermons makes their voice
lower. I doubt we are going to the episcopal way of reading prayers,
too." Another member moved that Mr. Matthew Mead, minister of
Stepney, might be selected as one of the preachers: and he
expressed an earnest hope that charity might be more manifest on
the occasion than it had been when a fast was last observed by the
Houses, for then "nothing was given at the door to the poor." From
observations advanced in the course of this amusing debate, it
appears that reading discourses had begun to be somewhat
fashionable amongst the English pulpit orators of the Puritan period;
it was, however, otherwise in Scotland, memoriter delivery being the
practice there; and hence, Lord Cochrane of Dundonald, who sat for
Aire and Renfrew, suggested his fellow-countryman, Mr. Galaspy, of
the Scotch kirk, as a minister peculiarly fitted to edify the House by
his ministrations, because he was not accustomed to read his
discourses. The honourable member raised a laugh by saying
"something of an evil man who read his sermons."[135]
In the month of March, there were debates in
the House respecting the new Magna Charta of 1657, March.
The New
England, contained in the document first called, Constitution.
"The humble Address and Remonstrance of the
Knights, Citizens, and Burgesses now assembled in Parliament;" but
afterwards still more modestly entitled, "The humble Petition and
Advice."[136] A blank had been left for the name of the chief
magistrate. Was it to be the title of King or Protector? Major-General
Ludlow called this new programme of the Commonwealth a shoe
fitted to the foot of a monarch; yet it might be worn, he said, and
walked in, by one bearing a less pretentious appellation. For weeks
there were, on this weighty question, discussions in St. Stephen's,
with conferences and speeches at Whitehall, ending, as every one
knows, in Cromwell's refusal of the English Crown.[137] That unique
episode in our national history does not come within the scope of
our narrative, but the Petition and Advice, in which the proposal of
kingship appeared, requires consideration under its ecclesiastical and
religious aspects. The framers of the new Charter had their eye upon
the Instrument of December, 1653. Like the Constitution it was to
supersede, it disqualified Papists for political rule, and for all exercise
of the franchise. Members of Parliament and of the Council of State
were still required to be men of integrity, fearing God. All acts and
orders for the abolition of Bishops, Deans, and Chapters, and for the
sale of cathedral property, were distinctly confirmed in both schemes
of government; and, as a fundamental principle in each, it was laid
down that the Christian religion, as contained in the Scriptures,
should be held forth as the public profession of the country. But, on
comparing the long Article, number xi., in the Humble Petition, with
the corresponding Articles of 1653, numbered xxxv., xxxvi., and
xxxvii.,[138] we discover some not altogether unimportant
differences. The Article xxxv. of the first Instrument speaks of a
contemplated provision for ministerial maintenance, less subject to
scruple and contention, and more certain than the present—meaning
tithes. Not a word appears on this subject in No. xi. of the Petition. A
Confession of Faith to be agreed upon by his Highness and the
Parliament is desired in the Petition and Advice, but nothing of the
kind had been mentioned in the Articles. Moreover, in the Petition
and Advice it is distinctly said:—"That none may be suffered or
permitted by opprobrious words, or writing maliciously or
contemptuously to revile or reproach the Confession of Faith to be
agreed upon as aforesaid"—a provision to which nothing similar can
be found in the Articles. Also, in the earlier case, liberty was
conceded to all persons who professed faith in God by Jesus Christ,
so that they did not abuse their freedom to the injury of others; but
in the later scheme of government, an enumeration is attempted of
primary articles of belief necessary to be held as a condition of
toleration. Freedom is limited to those who "profess faith in God the
Father, and in Jesus Christ, His eternal Son, the true God, and in the
Holy Spirit, God, co-equal with the Father and the Son, one God
blessed for ever; and do acknowledge the holy Scriptures of the Old
and New Testament to be the revealed will and word of God; and
shall in other things differ in doctrine, worship, or discipline from the
public profession held forth." The determination to draw a broad and
distinct line between clergy and laity—which was expressed in the
resolutions of the first Protectorate Parliament, when the Articles of
1653 came under discussion—is decidedly taken up by this second
Parliament, and incorporated in their Advice.
This comparison of the two Charters indicates a
revived spirit of ecclesiastical conservatism at the 1657, May.
Cromwell's
period when the second of them was prepared, Speech.
and seems to point to a strong Presbyterian
element in this second Protectorate Parliament. The exclusion of
members with republican predilections from seats in St. Stephen's
left the Presbyterians more at liberty to carry out their own plan of
religious policy; and it is a fact, that at the same time, they derived
encouragement from the conciliatory conduct then, and for some
little while before, manifested toward them by the Lord Protector.
Cromwell accepted the Petition and Advice, "hugely taken," as he
says, with the word "settlement—both with the thing and the
notion"—it being the haven into which he had long sought, in a night
of storms, to bring the vessel of Church and State. But, in a speech
on the 21st of April, he could not help animadverting on debates in
Parliament respecting the civil disqualification of public preachers. "I
must say to you," he observed, "in behalf of our army—in the next
place to their fighting—they have been very good 'preachers,' and I
should be sorry they should be excluded from serving the
Commonwealth because they have been accustomed to 'preach' to
their troops, companies, and regiments—which I think has been one
of the blessings upon them, to the carrying on of the great work. I
think you do not mean so 'that they should be excluded' but I tender
it to you, that if you think fit there may be a consideration had of it.
There may be some of us, it may be, who have been a little guilty of
that, (the Lord Protector no doubt here thought of himself), who
would be loth to be excluded from sitting in Parliament 'on account
of it!'"[139]
Cromwell, in the same speech, could not but
cast a glance of approval at the proceedings of the 1657, April.
Commission of Triers, of whom, however, the
Advice says nothing. "We have settled very much of the business of
the ministry," observes his Highness. "If I have anything to rejoice in
before the Lord in this world, as having done any good or service, it
is this;" "there hath not been such a service to England since the
Christian religion was perfect in England!" "We did not trust upon
doing what we did virtute Instituti, as if these Triers were jure
Divino, but as a civil good. We knew not, and know not better, how
to keep the ministry good, and to augment it in goodness, than by
putting such men to be Triers: men of known integrity and piety,
orthodox men, and faithful." Then—with a decided nod of favour in
reference to that part of the petition—he looked at No. xi. on the
document, which he held in his hand—where it was written that
those ministers who should agree in doctrine, though not in
discipline, with the public profession, should be eligible for trust and
promotion in the ecclesiastical establishment of England. After
glancing obliquely at strifes of opinion—with frowns of displeasure
such as we can imagine overcasting his huge eyebrows—he
afterwards turned with radiant smiles to recognize so much as
existed of his own comprehensive church in this new settlement of
affairs. "Here are three sorts of godly men whom you are to take
care for, whom you have provided for in your settlement. And how
could you put the selection upon the Presbyterians, without, by
possibility, excluding all those Anabaptists, all those Independents?
And so now you have put it into this way, that though a man be of
any of those three judgments, if he have the root of the matter in
him, he may be admitted."[140]
The provisions for a more minute Confession of
faith had received special notice from the Protector Comprehensivene
ss of Cromwell's
at one of the earlier interviews which he had with a Views.
committee of Parliament, respecting the knotty
points of their advice. He said they had been zealous for the two
greatest concernments God hath in the world—religion and liberty.
"To give them all due and just liberty, and to assert the truth of
God:" this was the point. "And as to the liberty of men professing
godliness, you have done that which was never done before. And I
pray it may not fall upon the people of God as a fault in them, in any
sort of them, if they do not put such a value upon this that is now
done as never was put on anything since Christ's time, for such a
catholic interest of the people of God." Then touching on the subject
of civil liberty, the Protector added: "Upon these two interests, if God
shall account me worthy, I shall live and die."[141]
It need scarcely be remarked, that contemplated
in the light of the nineteenth century, the 1657.
restriction of what is called religious toleration
within such bounds as were specified in the new Articles of
Government must appear very partial and narrow. But judged
according to previous legislation—compared with the Presbyterian
polity of ten years before; with the prelatical persecutions of Charles,
James, and Elizabeth's reign; with the papal cruelties of Queen
Mary; and with the capricious despotism of Henry VIII.—the
measure of liberty now conceded must be pronounced to be very
liberal. Also, when compared with other European countries at the
same period, or just before, England under Cromwell is seen to
immense advantage; for Spain, Portugal, and Italy prohibited all
forms of religion except the Roman Catholic; in France and in
Germany the Protestant churches fought rather for their own
existence than for any principles of freedom applicable to differing
sects; Holland enforced the decrees of the Synod of Dort;[142]
Denmark, Sweden,[143] and Norway allowed nothing but a rigid
Lutheranism: and Geneva was intolerantly Calvinistic. Moreover, as in
point of liberty outside the Establishment the Protectorate proceeded
far beyond contemporary European powers, so also did the
comprehensiveness of Cromwell's establishment surpass every other
which existed in his day. One class of Protestant Christians only had
been aforetime in England, or was at this time abroad, allowed by
the State incorporation and support; but the Protector conceded
these privileges to Presbyterians, to Independents, and to Baptists,
in common. In several cases also he winked at the occupancy of
parish pulpits even by Episcopal clergymen.
Of toleration and of comprehension there was
very much more than there had been in England, Liberal Opinions.
or than could be found at the same time
elsewhere; but both toleration and comprehension had respect to
different forms of polity, worship, and discipline, rather than to
different phases of doctrinal sentiment. Liberty was conceded to
various parties so long as they were orthodox and evangelical. But
when teachers lapsed into what Puritans believed to be error, when
they lost their sympathy in what Puritans believed to be Christian
experience, they became at once objects of suspicion and dislike to
the Government, and ran the risk of being deprived and silenced.
There was freedom of speech, if not State support, for all who were
esteemed true and faithful servants of Christ, in spite of their
peculiar principles and usages. But toleration belonged to them only
as saints, not as subjects. Liberty was counted a religious privilege,
not a social right. The grounds of toleration rested upon by
Government, however they might appear in the speculations of
individual thinkers, were not of the same breadth and of the same
strength as they are in the present day. But if there was less of
liberty than some admirers of the Commonwealth imagine, there
was vastly more of order in the administration of ecclesiastical affairs
than those who dislike Cromwell and his Government are disposed to
admit. What has been already advanced in these pages serves to
shew that things were not left to be shaped by chance; that a
definite system of policy was framed; that there was a defined
establishment based on law; that liberty was fenced round by
distinct lines; and we may now remark, in conclusion, on this
subject, that Council books, and other documents in the State Paper
Office, prove that the ecclesiastical and other departments of the
State, throughout an imagined reign of confusion, were really
administered with singular and unprecedented regularity.
Before the business of the Petition and Advice
had brought to a close, there were certain other 1657, April.
matters been settled by Parliament. Upon a
resolution coming before the House to approve of the ordinance of
March the 30th, 1653, which appointed Commissioners for
approbation of public preachers, with the proviso that those
nominated in the intervals of Parliament should be sanctioned by
Parliament, Mr. Bodurda, member for Beaumaris, claimed that a
minister finding himself aggrieved should "have the benefit of the
law;" and went on to say that it was mischievous to entrust
commissioners with the power of determining in such cases, without
affording any legal remedy for injustice. Sir John Reynolds, an Irish
member, replied, that to adopt this suggestion would be to pluck up
by the roots a design which had proved itself already a good tree by
the fruits which it had borne. Delinquents, he urged, might claim as
their inheritance what they had forfeited, and obtain a writ of quare
impedit; whereupon the new ecclesiastical polity would fall to the
ground. The Ordinance for ejecting ministers came also under
consideration the very same day, when some members, as might be
expected, complained of irregularity, injustice, and extravagance,
chargeable upon the Commissioners. On the other hand, it was
contended that though many irreligious Clergymen had been
expelled, there were more who desired to be so. Some Counties had
not passed through any expurgation. Hence it was "resolved that the
Ordinances for the ejection of scandalous, ignorant, and insufficient
ministers and schoolmasters" should remain in force for three years,
unless the Parliament should take further notice of the subject in the
mean time.[144]
Upon a debate in the month of May, respecting
the administration of oaths to recusants, with a Tithes.
view to their detection, sentiments found
expression far above the current opinion of those days. It was
against the laws of Englishmen to impose such oaths on Roman
Catholics—said Captain Baines, member for Appleby. Colonel Briscoe
—who had been returned for Cumberland—maintained the same
opinion, adding that such an imposition was a revival of the ex
officio oath; that it was inconsistent with the liberty of conscience
which then existed, and which, according to the Lord Protector, had
never existed before since Christ's time; and that it would fall most
heavily upon conscientious persons, whereas to others it would only
be like "drinking another glass of sack." In the course of this same
discussion, complaints were uttered, to the effect that Papists
increased, and that it was difficult to get a jury to convict them:
after which Mr. Butler, member for Poole, declared that in one or two
parishes they had multiplied "one hundred in a year;" and he
thought he might say that he himself had convicted some hundreds.
[145]

The old difficulty, how to make people pay their tithes—not yet
overcome by all the legislation on the subject in the years 1647 and
1648—presented itself to this Parliament. Cromwell's Council books
afford numerous instances of ministerial complaints respecting
arrears of income. Orders promptly made are recorded; but
subsequent complaints indicate how the execution of these orders
must have been resisted. For example, it was directed, in 1654, that
an augmentation of the chapelry of Brentford, Middlesex, by a
charge on the tithes of the Rectory of Ashwell, in Hertfordshire, up
to that time paid in corn, should be paid in money; and the Lord
Protector recommended that the income should be increased to
£100 per annum. The same augmentation became afterwards
charged on other Rectories; and, in the year 1657, his Highness and
the Rector of Hanwell (Brentford being in Hanwell parish), appointed
Abriel Borfett to the Brentford chapelry. Yet, after all these repeated
arrangements, petitions for payment of arrears abundantly prove the
difficulty which existed in the way of enforcing the claim.[146]
On the 1st of June, 1657, Sir William Strickland,
member for Yorkshire, moved the first reading of a 1657, June.
new tithe Bill; and, upon Whitelocke's objecting to
a clause in it authorizing ministers or their agents to enter men's
houses to enforce payment, as a thing never granted even in times
of Popery—no man having ever heard of a distress for tithes—the
mover replied that he was afraid some persons had a design, by
bringing disgrace on the system, to dishonour the Gospel; that there
were men who would leap over hedge and ditch, and over the whole
decalogue, and then scruple about tithes, and never willingly pay
them; that some severity was needful to preserve Church revenues;
and that the same principle which endangered one kind of property
imperilled all the rest.[147]
The Presbyterians were zealous in catechising
their children. The Provincial Assembly of London Catechising.
had passed a series of resolutions on the subject in
1655,[148] and now an attempt was made to legislate upon the
subject; but when a Bill for this purpose was introduced on the 9th
June, 1657, Major-General Desborough moved that it be "left
behind," since it would "discontent many godly persons and make
them mourn." Others spoke in the same strain, but Mr. Vincent,
member for Truro, and Colonel Briscoe, begged on their knees, that
the House "would not forbear the Bill," in which earnest and
impassioned plea they were supported by so large a majority of
Presbyterian members that, on a division, the yeas were 82, and the
noes but 7. "So," as the Journals record, "it was resolved that the Bill
for catechising be now carried up." It was carried up with several
other bills: whereupon the Speaker made a short speech to his
Highness "relating to the slowness of great bodies moving, and how
our fruits were like that of the harvest, not all ripe at a time, but
everything in its season; and how he hoped that this was but the
vintage to the autumn the Parliament was preparing, and that it was
not with their productions as with Rebecca's births, where one had
another by the heel, but that their generation of laws was like that
of natural generation, and that his Highness was the sun in the
firmament of this Commonwealth, and he must give the ultimate life
and breath to our laws."
Thirty-eight of the Bills received the Protectoral
assent, but the thirty-ninth, the Bill for catechising, 1657, June.
met with a strange fate. After a little pause, his
Highness, looking at the parchment before him, said, "I am desirous
to advise of this Bill." Hence the Bill dropped. This being done, the
House returned about two o'clock to report proceedings, when Mr.
Bampfield, member for Exeter, standing by the table, declared "that
his Highness never did himself such an injury as he had done that
day." Mr. Scobell, the clerk, told Mr. Bampfield he ought not to talk
so, but the stiff Presbyterian declared "he would say it anywhere."
[149]

The same Mr. Bampfield made a report on the


11th of June "from the Grand Committee for 1657, June.
Religion," when a sub-committee was empowered
to send for godly and learned ministers and laymen to consult
respecting a better version of the Psalms. And, at the same time,
upon its appearing that the Scriptures had been grossly misprinted,
it was ordered that 7,900 copies, printed in 1653, should be seized
to prevent their sale or their dispersal; and that John Field, the
printer, should be required to get in such books as were of this
impression: and also attend the House to give an account touching
the misprinting of the said Bibles.[150]
The Sabbath question also came under debate
this same summer month. Too many penal laws, in Debates on
Sabbath
the opinion of Colonel Holland, who represented Observance.
Lancashire, had already been enacted for enforcing
the observance of the day. The last Bill, he said, had been passed on
a Saturday, and the consequence was, that the next morning, he
could not get to church by land or by water, without violating the
Act. The honourable member's own waterman, after conveying him
to hear a sermon at Somerset House, became subject to a fine, and
the honourable member's own boat was seized as a security for
payment. A debate ensued as to the right of searching houses to
find delinquents, when Mr. Godfrey, member for Kent, moved that
such right should be exercised only in taverns, tobacco-shops, and
alehouses. Mr. Vincent, and Colonel Chadwick—the latter then a
representative for Nottingham—thought that this restriction would
defeat the purpose in view, as the principal breaches of the law were
committed in private habitations. Lord Whitelocke, on a division,
carried an amendment to the effect that entry should only be
demanded, but not forcibly accomplished. The Bill enumerated such
offenders as, on Sundays, idly and profanely sat by their gate, or
door, or elsewhere, or walked in churchyards. He urged that all these
words ought to be left out; and Mr. Godfrey suggesting that idle
loungers thus described would plead that they were meditating upon
holy things, urged the omission of the terms "profane and idle
sitting," and especially the word "elsewhere." Major-General Whalley
objected that, if people at Nottingham, for example, might not sit by
the entrance of their rock houses on a Sunday, they would be
deprived of every breath of air. Mr. Bordura considered that as some
people had no accommodation for sitting, words should be subjoined
prohibiting them from "leaning or standing at doors." In reply to
Colonel Briscoe, who said he would not have laws too rigid, Major
Burton—member for Great Yarmouth—declared he would as soon
drop the Bill altogether as leave out the disputed clause. Then rose
Mr. West—who represented Cambridgeshire—saying they would not
leave out the word "elsewhere," for there might be profaneness in
sitting under a tree, or in an arbour, or in Gray's Inn Walks. The
stringent clause was thrown out on a division of 37 against 35.
Colonel Holland expressed himself as not satisfied in reference to the
time when the Lord's Day should be considered to begin; and added,
that some godly people were in doubt as to the institution
altogether; and that, whereas once he himself would have gone to
six or seven sermons a-day, now he would do no such thing. He
thought he could as well serve God at home. He was for keeping the
Sabbath as much as any man, believing that though there was no
precept enforcing it, every one by nature was tied to its observance.
Amidst cries of "question," the debate continued "so late that a
candle was called in, and after a while the Bill was agreed to pass,
and ordered to be engrossed."[151]
This animated conversation in the old House of
Commons—which we have thought it worth while Sabbath
Observance.
to report, even at inconvenient length—reflects the
various opinions, both strict and lax, which were then held relative to
the question of Sunday observance. Yet, after all, perhaps, the
report scarcely conveys to us exactly what the speakers meant.
Some of them really might intend by their extravagant statements
and ridiculous method of argument only to meet their opponents'
reasoning with a reductio ad absurdum, although the steady,
plodding diarist who took the notes from which we have drawn up
our summary did not seem to see the matter in that light.
The Act, as it appears in Scobell, prohibited
travelling, entertainment at inns, every kind of 1657, June.
trading, and all dancing and singing, and other
amusement, inclusive even of walking during Divine service.
Moreover, if people did not attend church or chapel where the true
worship of God was celebrated, they were to pay for each instance
of neglect two shillings and sixpence, which sum, after the payment
of informers, was to be appropriated for the benefit of the poor.[152]
At the close of the first session of the second
Parliament, there was enacted, on Friday, the 26th Cromwell's
Second
of June, 1657, a gorgeous ceremony, equivalent to
the coronation of the Puritan king. Purple robes, Installation.
sceptre, and sword, a chair of state—no other than
the regal one of Scotland, brought out of Westminster Abbey—and a
brilliant array of officers, judges, civic dignitaries, and the like, gave
regal pomp to the occasion.[153] The scene was exhibited under a
magnificent canopy of state in Westminster Hall, whose oaken
rafters had so often echoed with the music and revelry of
Plantagenet and Tudor feastings; and where, in 1653, Cromwell had
first been installed Protector, with less state splendour than on this
second occasion, and without the addition of any sacred rites.[154]
Religious worship, however, became associated with the present
solemnity, and there also appeared religious symbolism in a form
which passed quite beyond the common circle of Puritan ideas. The
Speaker of the House of Commons referred to Alexander, and
Aristotle, to Moses, and Homer, to David, and Solomon, and to "the
noble Lord Talbot, in Henry the Sixth's time," in order to shew what
appropriate spiritual lessons were suggested by the robes, the
sceptre, the sword, and the Bible. Richly-gilt and embossed, the Holy
Book was—with the regalia—laid upon a table covered with pink-
coloured Genoa velvet fringed with gold. "His Highness," dressed in
a costly mantle lined with ermine, and girt with a sword of great
value, stood—says a contemporary record—"looking up unto the
throne of the Most High, who is Prince of princes, and in whom is all
his confidence; Mr. Manton, by prayer, recommended his Highness,
the Parliament, the Council, his Highness's forces by sea and land,
the whole Government, and people of these three nations, to the
blessing and protection of God Almighty. After this, the people giving
several great shouts, and the trumpets sounding, his Highness sat
down in the chair of state, holding the sceptre in his hand."[155]
Heralds; Garter, and Norroy, King-at-Arms; his Highness's
Gentlemen; men of the Long Robe; the Judges; Commissioners of all
sorts; Robert, Earl of Warwick, bareheaded, with the sword of the
Commonwealth; the Lord Mayor, with the City sword; Privy
Counsellors and Generals took part in the ceremony—whilst on
seats, built scaffold-wise, sat the Members of Parliament; and below
them, the Judges and the Aldermen of London.
When the ceremony had ended, the Protector—
having saluted the foreign ambassadors—entered 1658, January.
his state coach, together with the Earl of Warwick,
Lord Richard Cromwell, his son, and Bulstrode, Lord Whitelocke, who
sat with him on one side; and Lord Viscount Lisle and General
Montague on the other: Lord Claypole led the horse of honour
caparisoned with the richest trappings. At night there were great
rejoicings.
Parliament reassembled January the 20th, 1658.
Lord Commissioner Fiennes made a speech that Re-assembling of
Parliament.
day before his Highness, in which he entered at
large upon the subject of toleration and charity. He spoke quaintly of
the Rock:—"A spirit of imposing upon men's consciences, where God
leaves them a latitude;" and of the Quicksand:—"An abominable
licentiousness to profess and practise any sort of detestable opinions
and principles." The object of the Petition and Advice was to steer a
middle course between the two. He strongly inveighed against
bigotry, and maintained that the right way was the golden mean,
even God's way. God, when he came to Elijah, was not in the
whirlwind, the earthquake, or the fire; but in the small still voice. So
with men's religious profession. "It must," said his Lordship, "be a
small and still voice, enough to hold forth a certain and distinct
sound, but not to make so great a noise as to drown all other voices
besides. It is good, it is useful, to hold forth a certain confession of
the truth; but not so as thereby to exclude all those that cannot
come up to it in all points, from the privileges which belong to them
as Christians, much less, which belong to them as men."[156] The
members who had been excluded were now admitted, after having
taken the oath according to the "Petition and Advice." They were
extremely republican in their ideas, and were inveterate enemies to
the Protector: their influence with their own party outside had been
increased by their recent conduct, which was regarded as proving
their strong attachment to "the good old cause." At the same time
some of Cromwell's warmest friends were removed to the other
House, which had been constituted so as to resemble somewhat the
ancient House of Peers. The effect of this new state of things upon
the two parties existing among the Commons became immediately
apparent.
After the new oath had been administered to all
the ministers—a business which it took some hours 1658, January.
for six commissioners to accomplish—the
Commons, preceded by their mace-bearer, as of old, marched up to
the House of Lords, where his Highness the Protector, in kingly state,
received them, and then proceeded to address the united assembly
as "My Lords and Gentlemen."—"You have now a godly ministry,"
said his Highness, "you have a knowing ministry; such an one as,
without vanity be it spoken, the world has not, men knowing the
things of God, and able to search into the things of God, by that only
which can fathom those things in some measure."[157]
Soon after Cromwell's opening speech, a debate
arose about the "maintenance of a godly Debates.
ministry"—by which words the Lord Protector on
the one hand, and on the other, many who sat in this Parliament,
would not mean quite the same thing. In the estimation of certain
members, scarcely any revenues remained for the Clergy,
notwithstanding all the provision which had been made for them of
late years. Forty or fifty petitions lay on the table, asking for aid to
support the preaching of the Gospel; but there existed no available
sources of relief. In Lancashire it was affirmed that there were
parishes, nineteen miles square, containing two thousand Protestant
communicants, besides as many Papists—which parishes greatly
needed subdivision, whilst the ministers equally needed increased
means of support. How to maintain the clergy was the question in
hand; but, according to a habit common in public assemblies, the
debate soon veered round to another point, and presently the House
was found struggling with the enquiry, Should there be another
Convocation or Assembly of Divines? One member battled both
points at once—contending there was no need of any further
assembly; and that before they raised additional money for religious
purposes they ought to pay their civil debts. A second speaker
observed that there had been already an Assembly, which had
settled foundations, but it had been dissolved, and to call another
would be very expensive—whilst persons fit to compose it would be
found very scarce. But, exclaimed a third, though what the late
Assembly resolved had been put in print, it had not been put in
practice, and there needed a new authority of the same kind, to
gather out the weeds from amidst the corn. The ordination of
ministers and some outward form of unity were also of great
importance, which could be obtained only by another ecclesiastical
Convocation. A fourth condemned the proposal altogether, inasmuch
as the former assembly had sat long, had cost much, and had
effected little. With such differences of opinion that question was
speedily waived. Complaints respecting the marriage law and the
insecurity of registration next came upon the carpet; and the non-
residence of leading men in the universities was attacked by the
introduction of a Bill for its prevention; but soon a subject arose
before the House which swallowed up all other subjects of debate.
Cromwell's batch of Peers proved the rock on which the second
Protectorate Parliament went to pieces.[158] Sir Arthur Haselrig—who
took his seat with the Commons, although nominated one of the
new Peers—appears prominently in the final Republican broil,
occasioned by the attempt to give to the Commonwealth somewhat
of the aristocratic aspect of a kingdom. And here, it is affecting to
recollect the change which eighteen years had effected in reference
to men as well as measures. Of the patriots who took the lead at the
opening of the Long Parliament, John Pym slept under the pavement
of Westminster Abbey; John Hampden was at rest in the village
church which bore his name; Brooke, years before, had ended his
career at Lichfield; Dering, after his changeful course, had been
gathered to his fathers; Vane and Marten were in retirement; others
had disappeared; and now, of all the most busy actors on the stage
in 1640, there remained before the public view only Oliver Cromwell,
with Haselrig, the "hare-brained" in hot opposition, and Nathaniel
Fiennes—more wise in council than valiant in war—fighting out this
last political battle at the side of the Protector, his old friend.
His Highness's speeches on the 25th of January
and 4th of February were filled with patriotism and 1658, January.
wisdom, and with manifest touches of pathos, in
harmony with such pensive memories of this mortal state of
existence as have been just indicated; and in keeping, too, with such
a foresight of the end soon to follow, as we now are able to
exercise. They are the last two of those memorable orations which,
after being long neglected, are now beginning to be studied and
understood.
In the former of these speeches, the brave and noble ruler of
England—burdened not so much with the infirmities of years as with
the cares of government, worn out not by old age, but by years of
toil and anxiety, of counsel, and of war—spoke of what was most
dear to his heart, of the Protestant interest abroad, and the
Protestant interest at home; for Cromwell was a Protestant to the
backbone. Papists had been England's enemies from Queen
Elizabeth's reign downwards, and as enemies to their country they
were treated by the Protector.[159] And besides Papists, others in his
estimation threatened the interests of the Commonwealth.
Just at this juncture, the Republicans, in their
opposition to the new settlement, were bent upon Cromwell's Last
Speeches.
upsetting everything. Foundation stones just laid
were being rudely torn up, and the whole fabric was fast falling to
pieces. Indeed some sectaries pleaded, in a certain foolish book,
quoted but not named, for "an orderly confusion." "Orderly
confusion!" exclaimed his Highness. "Men have wonderfully lost their
consciences and their wits. I speak of men going about who cannot
tell what they would have, yet are willing to kindle coals to disturb
others." Fifth Monarchy men, also, were now hastening in the same
direction as the Royalists. Whilst they wanted to set up a republic,
they were in fact playing the game of the King of Scots. "It were a
happy thing," said the old man, wearied out with the war of opinion,
"if the nation would be content with rule. 'Content with rule' if it
were but in civil things, and with those that would rule worst;
because misrule is better than no rule, and an ill government, a bad
government is better than none! Neither is this all, but we have an
appetite to variety, to be not only making wounds, 'but widening
those already made.' As if you should see one making wounds in a
man's side, and eager only to be groping and grovelling with his
fingers in those wounds! This is what such men would be at; this is
the spirit of those who would trample on men's liberties in spiritual
respects. They will be making wounds, and rending and tearing and
making them wider than they were. Is not this the case? Doth there
want anything—I speak not of sects in an ill sense, but the nation is
hugely made up of them—and what is the want that prevents these
things from being done to the uttermost, but that men have more
anger than strength? They have not power to attain their ends.
'There wants nothing else.' And I beseech you judge what such a
company of men of these sects are doing, while they are contesting
one with another! They are contesting in the midst of a generation
of men (a malignant Episcopal party, I mean) contesting in the midst
of these all united. What must be the issue of such a thing as this?"
[160]

Then, on the 4th of February, came those last


words which wound up all—last words which 1658, February.
Englishmen are now studying with deep
earnestness, and with increasing insight—"And if this be the end of
your sitting and this be your carriage, I think it high time that an end
be put to your sitting, and I do dissolve this Parliament. And let God
be judge between you and me."
"Believe me," said Hartlib, Milton's friend; "believe me it was of
such necessity, that if their session had continued but two or three
days longer, all had been in blood, both in city and country, upon
Charles Stuart's account."[161]
Ecclesiastical legislation for England, under
Oliver Cromwell's Protectorate, ended with the Council of State.
dissolution of Parliament. Of course there were no
more Acts; nor were there any more Ordinances, respecting Church
affairs. But the same sleepless vigilance and unwearied activity as
before, were shewn by the Protector in relation to religious as well
as other subjects. The ponderous Order Book for 1658—in which
may be traced the proceedings of Government from day to day—
bears witness to the large amount of ecclesiastical business
transacted by his Highness and his counsellors. They determined
upon the supply of destitute parishes, chapelries, and outlying
populations; the settlement of questions about tithes, church leases,
and rights of presentation; the union of parishes; the augmentation
of incomes, and various grants to public preachers.[162] There also
occur orders to make collections for the repair of a church at South
Oxendon, struck by lightning; and of another at Egbaston, damaged
in the wars. It is curious to meet with a petition of the members of
the Congregational Church, at Warwick, complaining that a constable
had indicted Mr. Whitehead, a member, for not attending the parish
church, and had demanded fines for absence; whereupon it was
ordered that a letter should be written to the Justices, to let them
know, that if the case were as it had been represented, the Council
was much dissatisfied therewith, as an abridgment of that liberty
which the law allowed. More curious still is it to meet with a
complaint of reproachful and provoking language having been used
at church by a Commonwealth's man against a Royalist, who is
described as being "under obligation, with great penalties, to his
Highness for keeping the peace, and good bearing of himself to his
Highness." It is most curious of all, to find a petition from Anastatius
Cominus—a Bishop of the Greek Church, under the patriarch of
Alexandria—on behalf of himself and others, referred to the
Committee for approbation of public preachers.[163]
How favourably these entries in the old
parchment-bound folio—written in a firm, bold, 1658.
legible hand, characteristic of the men whose
proceedings they chronicle—contrast with the records of the
Protectorate Parliament! Whilst the latter were spending their time
upon bigoted efforts to curtail the religious liberties of the people;
the Council of State, with the actual sovereign of England at its
head, was employing an effective influence to check the career and
to mitigate the mischiefs of intolerance. And as this supreme
executive body tempered the narrow policy of parties, it also
repressed the misguided zeal of individuals. How significant is that
expression of displeasure at the attempted abridgment of freedom
which had been made in a miserably sectarian spirit by some who,
professing to maintain justice and charity, to say the very least,
ought to have known better.
CHAPTER VIII.
The schemes of politicians, the proceedings of Parliament, and
the administration of affairs by a Council of State—although
necessary to be studied in order to obtain a knowledge of external
circumstances, such as, under the Commonwealth, powerfully
influenced religious society—can convey but a very inadequate idea
of the actual working of ecclesiastical institutions at that period; and
no conception whatever of the spiritual life either of churches or of
individuals. It is requisite, therefore, that we should turn our
attention to the inner history of different communions; and not only
look somewhat minutely at their character and proceedings, but also
glance at a few of the eminent individuals who were connected with
them.
Both in theory and practice, Cromwell's Broad Church included
Presbyterians, Independents, and Baptists. In reviewing the state of
these parties respectively, we commence with the Presbyterians.
The Presbyterian scheme of church government,[164] as
determined by the Assembly of Divines, contains an enumeration of
three kinds of officers—namely, pastors, who both preached and
ruled; lay elders, who ruled, but did not preach; and deacons, who
chiefly attended to the necessities of the poor. Each congregation
was to have its affairs administered by such officers; and upon the
Presbytery, consisting of Pastors and Elders,[165] devolved the
oversight of communicants, the maintenance of discipline, and the
administration of censures. Censures, too, admitted of three degrees
—admonition, suspension, and excommunication. Notorious
offenders were required to make an acknowledgment of sin before
the whole congregation; and if they proved incorrigible, they were to
be cut off from the communion of the Lord's Supper, and from the
right of bringing their children to be baptized. Means, however, were
to be employed for the restoration of such unhappy outcasts.[166]
Next to this congregational or parish Presbytery,
and superior to it, was the Classical Assembly, Presbyterian
System.
composed of delegates from parish congregations
—the number sent by each not being more than four, or less than
two. Their business was to take cognizance of the conduct of
Ministers and Elders; to admit candidates to office; to enquire into
the state of congregations; to decide cases too difficult for
settlement by Parochial Elders; and to discharge such legislative
functions as did not usurp the authority of the higher courts.
Disputes between Ministers and Elders were determined before this
classical tribunal. The Provincial Synod formed the next superior
court, to which delegates went from the classical Presbyteries;
meetings for the Province of Lancaster being held in the church at
Preston. Thither appeals were carried, and there judgments were
enforced; and there also candidates for the ministry passed through
a theological examination. The preliminary trials having reached a
satisfactory conclusion, notice was posted on the church door, that
the persons approved would be ordained at the end of a month, if
no objection were offered. That solemn service included the offering
of prayers, the preaching of a sermon, the asking of the Pastor Elect
certain questions, and the imposition of hands, with the delivery of a
pastoral charge. He afterwards received a certificate of ordination.
To crown the series of church courts, a General Assembly was
requisite; but to this point of perfection Presbyterianism in England
never attained. Even in Lancashire, where the system appeared in its
greatest vigour, its movements were greatly crippled. Episcopalians
resisted it; avowing their love for Bishops, continuing to use the
surplice and the liturgy, and condemning Presbyterian marriages and
sacraments. The want of State authority for the enforcement of a
complete scheme of discipline was a great vexation to its advocates;
and when the Covenant could no longer be pressed, and the law
against the Prayer Book proved a dead letter, the predominant
religionists found it difficult to contend against the lingering
popularity of ancient forms, and sometimes strove in vain to resist
the efforts which were made to introduce ejected Episcopalians into
vacant pulpits. They at length discovered it was to their own interest
to draw towards their Episcopalian brethren; and before the
Commonwealth expired, attempts were made to establish a
moderate form of diocesan rule, somewhat after the model ascribed
to Archbishop Ussher. The two parties searched for points of
ecclesiastical agreement, and went so far as to preach in each
other's places of worship. In some cases political sympathies formed
a still deeper basis of union. Disliking the Protectorate, and longing
for the restoration of royalty, both parties joined in the famous
insurrection under Sir George Booth in 1659. And a further bond
arose in a common antipathy to the sects and to all unordained
ministers.
Among the Lancashire Presbyterians were some
very remarkable men. Richard Herrick, Warden of Herrick at
Manchester.
the Collegiate church of Manchester, was learned,
munificent, disinterested, and conscientious; but he was one of the
most passionate of partizans, at a time when partizanship was pre-
eminently rife. He had little or no enmity to Episcopacy in the
abstract,[167] but only disliked certain individual bishops, whom he
considered to have been indifferent to the advances of Popery. The
mild Juxon incurred his rebuke, because, as Herrick said, he
preferred his hounds and his falcons to the defence of Protestantism.
It was mainly through the exertions of the Manchester Warden, that
Presbyterianism acquired ascendancy in Lancashire; he having
promoted a petition to Parliament for that end, signed by many
thousand persons. Resolutely did he resist the sequestration of
church lands; doggedly did he refuse to give up the charter chest,
even when soldiers came to burst open the door. His sympathy with
Love caused him at one time to be placed under arrest; and nothing
could induce him to leave Manchester, where he believed Providence
had stationed him in troublous times, that he might defend the faith
which was beleaguered by so many and such various foes. There in
the Collegiate Church—now transformed into a Cathedral—he
thundered out his anathemas against Rome, and fearlessly arraigned
the proceedings of men in power. John Knox, before the Lords of the
Council, and Hugh Latimer, in St. Paul's Churchyard, never launched
more fiery bolts against the Mother of Harlots.
Herrick once addressed his audience in the following words—and
we give them as a specimen of the kind of oratory then popular, and
as a picture, though a very exaggerated one, of the state of things
in some parts of England.
"Be pleased to conceive a Parliament at this time convened in
Heaven, and God on His throne asking this question: 'Shall I destroy
England?' And so some answer after this manner, and some after
that: 'Great cry of injustice, of oppression, of wrong, of injury!"
'Blood toucheth blood; courts of justice and committees are courts of
robbery and spoil; the poor sheep flies to the bush for shelter, and
loses his fleece!' 'Papists and malignants compound, and they
oppress their poor tenants that have engaged themselves in the
public cause for the Lord against their lords!' A fourth confirms, and
concludes with the other three: 'England must be destroyed. They
have falsified the oath of God. Oaths and covenants are like
Sampson's cords; every one makes use of them to his own
interests!' To these agreed many more, so that there was a great cry
heard in the house: 'Down with it, down with it, even to the ground!'
God looked from His throne, and wondered there was not one found
—not one to stand in the gap to make an atonement to speak in the
behalf of England. After a short silence, one arose from his seat, and
said: 'Lord, wilt Thou destroy England—England, for whom Thou
hast done so great things? Wilt Thou destroy what Thine hand hath
done? What will the Atheists, the Papists, the malignants say? Surely
God was not able to save them. Save them, then, for Thy great
name's sake!' A second ariseth, and saith: 'England must not be
destroyed! Lord, wilt Thou destroy a righteous nation, if there be
fifty, forty, thirty, twenty, ten righteous there? Shall not the judge of
all the earth do that which is right? There are seven thousand at
least that have not bowed their knees to Baal! There are sixty
thousand, and more, yea, than sixty hundred thousand, that cannot
discern betwixt the right hand and the left! Thou never didst destroy
a praying, a reforming people! Wilt Thou now do what was never in
Thy thoughts before?' A third ariseth after the second, and pleads
the same cause: 'England must not be destroyed! There is a
Parliament in the midst of them—physicians of great value! God hath
been amongst them, and in the midst of them; and they are still
acting for God and the kingdom's safety! Did ever Parliament perish
before?' After all these, the fourth ariseth, that there might not
appear fewer to speak for than there was to speak against England:
'England must not be destroyed! They cannot die alone; the three
kingdoms must die with them—yea, the Protestants' churches
throughout the world! Hast Thou not said that hell gates shall not
prevail against Thy people?' To these many more joined in heart and
vote, so that there was a considerable party of both sides; nor could
it be determined whether had more voices, those that spake for the
destruction, or they that spake for the salvation of England. And
having said, they were silent.
"And behold, as we read in the Revelation, there was in heaven
great silence for half an hour, both sides waiting for God's
determination. At last, God in His glorious majesty raised Himself
from His throne, and effectually cried out: 'How shall I give thee up,
England? how shall I give thee up?' And so, without conclusion and
final determination, He dissolved the session, to the admiration and
astonishment of both parties."[168]
Adam Martindale, with whom we become
intimately acquainted through the medium of his Martindale.
autobiography—had been a tutor, and had kept
school in very strange places—even in public-houses, where he had
been compelled to share in both bed and board with such
companions as Papists, and soldiers, and drunkards. His employment
as a schoolmaster had been adopted in order to avoid enlistment as
a soldier; yet he was taken prisoner by Prince Rupert in the town of
Liverpool, and made to walk without any shoes—the troopers, as he
Welcome to Our Bookstore - The Ultimate Destination for Book Lovers
Are you passionate about books and eager to explore new worlds of
knowledge? At our website, we offer a vast collection of books that
cater to every interest and age group. From classic literature to
specialized publications, self-help books, and children’s stories, we
have it all! Each book is a gateway to new adventures, helping you
expand your knowledge and nourish your soul
Experience Convenient and Enjoyable Book Shopping Our website is more
than just an online bookstore—it’s a bridge connecting readers to the
timeless values of culture and wisdom. With a sleek and user-friendly
interface and a smart search system, you can find your favorite books
quickly and easily. Enjoy special promotions, fast home delivery, and
a seamless shopping experience that saves you time and enhances your
love for reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!

ebookgate.com

You might also like