These are appendixes from the set of posts about setting up and using a Raspberry Pi.
As part of the boot process, your Pi used DHCP to get an IP address from the router. The problem with this is that it is an automated process which is invisible to you unless you log onto your router’s admin page to discover it. If only the Pi and your router know what its IP address is, you don’t know where to log on to your Pi. The easiest thing to do is change the IP settings on the Pi’s card to a static address, assigned by you. That way you know what it is and you know it won’t change. You don’t need to let the router know which address you have chosen, as the magic IPixies in the Pi sprinkle the router with their Ipixie Dust to let it know automatically. Well, they do for all I know; I’ve no idea how the router finds out, but it does.
You need to pick an address for your Pi – something like 192.168.1.16, but you want to pick one that is not in the range of addresses your router assigns for DHCP requests. If the address you choose is within the router’s DHCP address range there is a possibility that you will end up with two devices using the same address.
I’m going to leave it to you to find out what range of addresses your router assigns for DHCP and which ones are suitable for static IP addresses. The settings will be available somewhere in your router’s admin pages. If fiddling around with your router is out of the question, as a quick bodge you could try finding the IP address of your PC in order to guess a safe non-DHCP range address for your Pi. Copy the first 3 sets of numbers of your PC’s address and change the last number to a low one if it’s not low or a high one (maximum 254) if it is low.  e.g.
- Your PC’s IP is 192.168.1.3 so you pick 192.168.1.250 for your Pi
- Your PC’s IP is 192.168.1.101 so you pick 192.168.1.3 for your Pi
You also need to know the gateway (the router’s IP address on the LAN) and subnet mask (which will probably be 255.255.255.0 – it usually is for home networks).
Go back
Appendix B: The Linux Filesystem
Here’s a quick and dirty note about the way the Linux filesystem is arranged. For a better description try this or this.
You might be used to Windows, with its lame C: drives, D: drives, random assignation of drive letters for plug-in devices, and its pathetic attempts to hide this lameness with My Documents, libraries and other rubbish.  Linux has one hierarchical tree of files, with everything hanging off the root “/” directory. There are no drive letters or special places; everything – programs, user data, log files, temporary files and even devices, is placed on the same directory tree. There is a convention as to where different types of file are stored, but let’s have a little wander around and see for ourselves.
Take a look at the command prompt – “naich@raspberrypi ~ $” It contains 4 pieces of information; your name and the name of the computer you are on (with an “@” between them), the working directory (~) and the effective user ID ($). The “$” changes to a “#” if you are currently root – that’s all that does, but it is important to know if your powers are currently elevated to those of the godly root. The working directory is where you currently are in the directory tree, i.e. it is the directory that a command will take action in if you don’t actually specify which directory you want the command to do its stuff in. Get it? No? An example will demonstrate better than that convoluted jumble of words; type ls:
naich@raspberrypi: ~ $ ls
naich@raspberrypi: ~ $
See anything? Nope. ls means list all the files in a directory. As you did not specify a directory it lists the files in the working directory, which is “~”, and is currently empty. If you tell it to list files in a different directory it will use that one instead of the working one; type ls /:
naich@raspberrypi ~ $ ls /
bin  dev home lost+found mnt proc run  selinux sys usr
boot etc lib  media      opt root sbin srv     tmp var
naich@raspberrypi ~ $
These are all the files and directories in the root directory “/”. Try ls /bin – see what is happening there? You are listing all the files in the “/bin” directory. This rule also goes for file names. If you want to access a file but only write a file name, the command or program will look for that file in the working directory. If you include the directory that the file is in, it will look there instead. This goes for any type of file – data, programs or devices. Think of your terminal window as psychically sitting on a branch of the directory tree, with everything you type in acting on that branch unless you explicitly specify otherwise. The location of that branch is the working directory.
Handy hint – Stuff shooting off the top your screen before you can read it? Add “ | more” to the end of your command, (e.g. ls /bin | more) to show one page of output at a time. Scroll to the next page with the space bar or press “Q” to quit. This works with all commands. Don’t try to understand how it works for the moment, just consider it magic.
You can move your terminal around the directory tree with the cd (change directory) command. Type cd / to move your working directory to the root directory and type ls again. Now your working directory is “/”, it lists the files there when you don’t explicitly say otherwise. Try moving to “/bin” and looking at the files there. Try moving to other places and have a good old poke around. Even with a basic install there are tens of thousands of files on your Pi, so there’s plenty to look at. When you are done, move back to your home directory by simply typing cd ~.
As well as looking at the the prompt, another way to find out the working directory is to type pwd:
naich@raspberrypi ~ $ pwd
/home/naich
naich@raspberrypi ~ $
Eh? I thought we were in “~”? Well, we are. “~” means “my home directory”, which is “/home/your_username”. Your home directory is where you put all your stuff and is probably the only directory you can write to. If you are going to start drawing Windows analogies, it is a bit like “My Documents”. The “~” provides a reference to where all your stuff is, so using “~/README.txt” refers to README.txt which resides in your home directory, rather than any other README.txt which might be in whatever working directory you happen to be in.
It’s all relative though. When you specify a directory to move to, look in, or to find a file in, the location you give is relative to where you currently are – i.e. your working directory. If you start the directory location off with a “/” or “~/” it doesn’t matter where you are, as the location you are specifying starts at the root or home directory. These are fixed absolute points on the tree, but miss off the “/” or “~/” from the start of the directory or file and it becomes relative to your working directory. Type cd /usr to move your working directory to the “/usr” directory. Do a ls to see the contents. See that directory called “bin”? It’s not the one you looked at earlier; that was a directory for general system bin(ary) programs, this one is for user-orientated bin(ary) programs. Type ls bin. The files listed are not the ones you saw earlier in “/bin” but are the ones in “/usr/bin”. Because the “/” is missing from the front of “bin”, the “bin” it is showing you is the one relative to your working directory, which is currently “/usr”. You can still see the contents of “/bin” (with the slash) by typing ls /bin (with the slash).
If you understand the concept that everything is relative to the working directory unless you say so, you are ready to know about dots – “..”, “.” and dots at the start of files.
A double dot is shorthand for “the parent directory”, i.e. the next directory down on the way to the root. If your working directory is “/home/naich” then typing cd .. will change your working directory to “/home”. Typing ls .. will list the contents of “/home” and so on. You can string double dots together as if they were real directories. cd ../.. will move you two directories towards root – from “/home/naich” to “/”. You can do daft things like cd /home/naich/../../home/naich to end up in “/home/naich”, the first “/home/naich” having been rendered pointless by the two sets of double dots moving you back down to “/” again.
A single dot means “this directory”, i.e. the current working directory. That might not sounds useful, seeing as how, by it’s very nature, you are already working in the working directory but it does have its uses. I’m not going to go in to them here, but you should know about it in case you see it later on.
Finally, there are hidden files. These are hidden for convenience not security and are simply files that you don’t care about in the normal scheme of things. Files like configuration files or log files. You can hide a file or directory by starting its name with a dot, e.g. “.config_file”. You have some in your home directory but didn’t see them earlier. Go home (cd ~) and have a closer look – type ls -a.
naich@raspberrypi ~ $ ls -a
. .. .bash_history .bash_logout .bashrc .profile
naich@raspberrypi ~ $
The “-a” bit is an “option” that tells the “ls” command to show hidden files. Those hidden files are configuration files that are automatically generated when you create a user and control parameters about the way your terminal works. Most of the time you don’t need to see them, so they are hidden. You can also see the “.” and “..”, which show up as directories in their own right.
Go back
Appendix C: Commands
The basic format for doing things from the command line has 3 sections separated by spaces:
command [-options] [the_thing_you_are_doing_it_to]
An “option” is a way to modify what the command does. For example, the default thing for the ls command to do is show the files as a horizontal list, so to list all the files in the root “/” directory:
naich@raspberrypi ~ $ ls /
bin  dev home lost+found mnt proc run  selinux sys usr
boot etc lib  media      opt root sbin srv     tmp var
naich@raspberrypi / $
but if you add the option “-l” (minus lower case L) to the “ls” command it does this:
naich@raspberrypi ~ $ ls -l /
total 84
drwxr-xr-x 2 root root 4096 Aug 6 12:35 bin
drwxr-xr-x 2 root root 16384 Jan 1 1970 boot
... skip a few ...
drwxr-xr-x 10 root root 4096 Jul 15 19:57 usr
drwxr-xr-x 11 root root 4096 Jul 15 20:42 var
naich@raspberrypi / $
The “-l” means print it in “long” format, i.e. with more information about what sort of file or directory it is (the “d” in “drwxr-xr-x” means directory, don’t worry about the rest for now), who owns it (“root”), the group they are in (root), the size of the file, date it was last modified and its name. You can have more than one option. Try ls -lh /. The “h” means put the file sizes in human readable units.
naich@raspberrypi ~ $ ls -lh /
total 84K
drwxr-xr-x 2 root root 4.0K Aug 6 12:35 bin
drwxr-xr-x 2 root root 16K Jan 1 1970 boot
... and so on
You could make it show you hidden files (“-a”), in date order (“-t”), but reversed so the latest is at the bottom (“-r”) by using ls -lhatr /
naich@raspberrypi ~ $ ls -lahtr /
total 92K
drwxr-xr-x 2 root root 16K Jan 1 1970 boot
dr-xr-xr-x 68 root root   0 Jan 1 1970 proc
drwxr-xr-x 12 root root   0 Jan 1 1970 sys
drwxr-xr-x 2 root root 4.0K Jun 2 10:25 mnt
... etc. ...
Note that the “Jan 1 1970” comes from boot time, when the Pi doesn’t know what time it is (no real time clock), so it defaults to the earliest time a Unix timestamp can have.
It would be pretty unreasonable to expect everyone to remember what all the options are, so most commands have help built in, accessible by using either “-h” or “–help” (that’s two dashes there, compared to the one for single letter options). Â With ls, “-h” is used for specifying human-readable units, so –help (with the two dashes) is the option to use for help.
naich@raspberrypi ~ $ ls --help
Usage: ls [OPTION]... [FILE]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
Mandatory arguments to long options are mandatory for short options too.
 -a, --all                 do not ignore entries starting with .
... blah blah etc. ...
Options with two dashes and a word are called “long options”, one dash, one letter ones are “short” options. Obviously you can’t lump long options together behind the same dashes, so you have to use them seperately, i.e. ls --all --human-readable /. You can also mix them if you want, i.e. ls -la --human-readable /.
A huge amount of help is also available from the manual pages residing on your Pi, which contain more verbose instructions. You use these by typing “man command”, e.g. man ls or man adduser or even man man. While they are very detailed and available for pretty much every command you’ll use, a) you need to already know what command you want, and b) they aren’t always written in the clearest manner for a beginner. Don’t be afraid to google for information too – for example, putting “how do i add a user in linux” into google’s search box gives you exactly what you need to know. You aren’t born with knowledge of how Linux works so you need to find it somewhere. Start off with the manual pages but if you only understand a few of the words on them, have a google for it.
Go back