The Start


Hi, What and Why

Compare to Arduino

What do you need to buy ?

It's plugged in, what's first ?

How to install packages.

Recommended packages.

Essential Linux Commands.

How to use the vi editor.

The next step


Set up I2C.

My first program - blink.

VNC - Use your computer to control your Pi.

Samba - copy files.

Essential Linux commands for the Pi

If you are new to linux, and the commands that you can type in, then these will prove invaluable.

$
$ cp myfile myfile.py
$
( note: this will create a copy of file myfile, with the name myfile.py )
 
$
$ mv myfile myfile.py
$
( note: this will rename file myfile, with the name myfile.py )
 
$
$ cat /etc/modules
$
( note: this will show the contents of the file modules, in the /etc/ directory. Incidentally, this file contains the kernel modules that are loaded at boottime. You will need this file if you want to enable the i2c interface, for use with the GPIO pins. )
 
$
$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games
$
$ which python
/usr/bin/python
( note: your PATH is the environment variable that tells linux which directories to search for a command, when you type a command in. The which command tells you which directory the file has been found in. Note that your current directory is not in your path ! )
 
$
$ sudo bash
#
( note: sudo will run the following command with root privileges. The command 'bash' runs a new shell. Put the 2 commands together, and you get a terminal command line where every command will be run with root priv. This saves you having to type sudo at the start of every command. )
 
$
$ sudo updatedb
$ locate jpg
( note: the locate command very quickly finds any file in any directory that matches the string; in this case, and file with jpg in the name will be listed for you. The locate command is a package that you must install, see page 'recommended packages'. )
 
$
$ ls -ltr
$
( note: the ls command will list files in your current directory. ls -l will give you the file details as well as the filenames. ls -lt will list the same, in datetime order. ls -ltr will list the same, in reverse datetime order. This means that the last file you created or edited will be at the end of the list - very useful when you transfer a file to your pi and can't exactly remember the name. )
 
$
$ bunzip2 anyfile.tar.bz2
$
( note: .tar signifies the file contains an archive of other files. .bz2 signifies that the tar file is compressed, usually to reduce the filesize. )
 
$ tar tvf anyfile.tar
$
( note: Use the tar command to deal with a tar archive. tar tvf will LIST the files in the archive )
 
$ tar xvf anyfile.tar
$
( note: tar xvf will EXTRACT the files in the archive )
$
$ grep -i i2c *
$
( note: the grep command searches files for a matching string. The -i means 'ignore case'. * means all files. This example will tell you which files in the current directory contain the string i2c. )
 
$
$ locate jpg | more
$
( note: we've seen the locate command above. The rest is pronounced "pipe more". The more command will give you the results a page at a time, allowing you to read the results. Press space to see the next page. )
 
$
$ top
$
( This will show you the processes that are running, ordered by the most cpu-intensive first. Most useful, it gives you the process ID which you can use with the kill command, below. )
 
$
$ kill 12345
$
( This will kill process number 12345; find the PID of the process you wish to kill using top or ps, and use the kill command to terminate it. Use sudo kill for a more effective zap. Use sudo kill -9 12345 for the ultimate thumping.)
 
$
$ ps -ef
$
( This will list all running processes, with the owner (usually pi or root), the process ID and the parent process ID. You can see what's going on in your linux system, and kill processes that you don't want running.)
 
$
$ ifconfig
$
( The quickest way to find your local IP address of your pi. You usually have three network interfaces; eth0 for your ethernet port, wlan0 for your wireless, and lo for loopback. (Ignore loopback).)
 
$
$ lsmod
$
( list the loaded kernel modules. You might use this when you enable the GPIO I2C interface, since additional kernel modules need to be loaded. )
 
$
$ df
$
( Note : this gives you a list of devices and the space free on them. This includes your hard disk (/dev/sda) and the partitions (/dev/sda1, /dev/sda2 etc) and any other USB hard disks, USB cameras, that you have plugged in.
 
$
$ file myfile.jpg
$
( Note : The file command looks at the contents of the file, and tells you what type of file it is. So, before you edit one of the linux programs, you can see whether the program is a shell script (and therefore editable) or a compiled C executable (not editable).
 
$
$ lsusb
$
( Note : this gives you a list of all USB devices that have been plugged in and detected. You can explore them under /dev/bus/usb. Everything in linux is a file - RAM, cpu, USB bus - it's all got a file that can be read and/or written to ).