Conventions
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Codes and command lines
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "To get the preceding kernel messages, we can use both the dmesg
and tail -f /var/log/kern.log
commands."
A block of code is set as follows:
#include <stdio.h> int main(int argc, char *argv[]) { printf("Hello World!\n"); return 0; }
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("Hello World!\n");
return 0;
}
Any command line input or output given on the BeagleBone Black is written as follows:
root@BeagleBone:~# make CFLAGS="-Wall -O2" helloworldcc -Wall -O2 helloworld.c -o helloworld
Any command line input or output given on my host computer as a non-privileged user is written as follows:
$ tail -f /var/log/kern.log
When I need to give a command as a privileged user (root) on my host computer the command line input or output is then written as follows:
# /etc/init.d/apache2 restart
The reader should notice that all privileged commands can be executed by a normal user too by using the sudo
command with the form:
$ sudo <command>
So the preceding command can be executed by a normal user as:
$ sudo /etc/init.d/apache2 restart
Kernel and logging messages
On several GNU/Linux distribution a kernel message has the usual form:
Oct 27 10:41:56 hulk kernel: [46692.664196] usb 2-1.1: new high-speed USB device number 12 using ehci-pci
Which is a quite long line for this book, that's why the characters from the start of the lines till the point where the real information begin are dropped. So, in the preceding example, the lines output will be reported as follow:
usb 2-1.1: new high-speed USB device number 12 using ehci-pci
Long outputs, repeated or less important lines in a terminal are dropped by replacing them with three dots ...
shown as follows:
output begin output line 1 output line 2 ... output line 10 output end
File modifications
When the reader should modify a text file, I'm going to use the unified context diff format since this is a very efficient and compact way to represent a text modification. This format can be obtained by using the diff
command with the -u
option argument.
As a simple example, let's consider the following text into file1.old
:
This is first line This is the second line This is the third line ... ... This is the last line
Suppose we have to modify the third line as highlighted in the following snippet:
This is first line
This is the second line
This is the new third line modified by me
...
...
This is the last line
The reader can easily understand that reporting each time the whole file for a simple modification it's quite obscure and space consuming, however by using the unified context diff format the preceding modification can be written as follow:
$ diff -u file1.old file1.new --- file1.old 2015-03-23 14:49:04.354377460 +0100 +++ file1.new 2015-03-23 14:51:57.450373836 +0100 @@ -1,6 +1,6 @@ This is first line This is the second line -This is the third line +This is the new third line modified by me ... ... This is the last line
Now the modification is very clear and written in a compact form! It starts with a two-line header where the original file is preceded by ---
and the new file is preceded by +++
, then follows one or more change hunks that contain the line differences in the file. The preceding example has just one hunk where the unchanged lines are preceded by a space character, while the lines to be added are preceded by a +
character and the lines to be removed are preceded by a -
character.
Other conventions
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "If it prints Hello World, then our code has been executed successfully!"
Note
Warnings or important notes appear in a box like this.
Tip
Tips and tricks appear like this.