Installation of Raspberry Pi

Basic config

ssh pi@raspberry


sudo raspi-config

Here you can change

  • Change User password
  • Change Device name
  • Add Wifi connection
  • Change TimeZone
  • Setup Locales

LCD screen

Change name of the device by command line

Change name to two sections:

sudo nano /etc/hosts
sudo nano /etc/hostname

Then flush and reboot

sudo /etc/init.d/
sudo reboot


Setting the locale to en_US.UTF-8 for example:

export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
sudo locale-gen en_US.UTF-8
sudo dpkg-reconfigure locales


New user

add user guide

Add new user

sudo adduser username

After that you can give them sudo privileges by editing the sudoers file

sudo visudo
pi    ALL=(ALL) ALL

Delete user and folder

sudo adduser username
sudo visudo
pi    ALL=(ALL) ALL
sudo deluser pi 
sudo deluser -remove-home pi


adduser USERNAME gpio
adduser USERNAME sudo

usermod -a -G video USERNAME
usermod -a -G gpio USERNAME

Disable wifi

Edit in /boot/config.txt


Mount devices

Directories for mounting

sudo mkdir /mnt/MediaGarden
sudo mkdir /mnt/usb
sudo mkdir /mnt/timemachine

USB Drive

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install hfsprogs hfsplus hfsutils
sudo mount /dev/sda1 /mnt/usb

Add mounts to /etc/fstab

sudo nano /etc/fstab

Raspberry Backup

How to backup raspberry

Backup script

# Backup OS to the USB Hard Disk Drive

# Create a filename with datestamp for our current backup (without .img suffix)
ofile="/mnt/usb/backup_$(date +%d-%b-%y_%T)"

# Create final filename, with suffix

# Begin the backup process, should take about 1 hour from 8Gb SD card to HDD
sudo dd if="/dev/mmcblk0" of=$ofile bs=1M

# Collect result of backup procedure
  # If command has completed successfully, delete previous backups and exit
  if [ $result=0 ]; then rm -f /mnt/usb/backup_*.img; mv $ofile $ofilefinal; exit 0;fi

#If command has failed, then delete partial backup file
if [ $result=1 ]; then rm -f $ofile; exit 1;fi

Install R

Link rbloggers

sudo apt-get update
sudo nano /etc/apt/sources.list
GNU nano 2.2.6 File: /etc/apt/sources.list

deb jessie main contrib non-free r$
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
deb-src jessie main contrib non-free rpi
deb stretch main
deb jessie main
deb xenial/

If you are using a Debian distribution you would add the following line to the file: jessie main
sudo apt-get install r-base r-base-core r-base-dev

Install packages

  • For devtools in R: libcurl4-openssl-dev libssl-dev libssh2-1-dev
  • For RMariaDB libmariadb-client-lgpl-dev
  • For odbc unixodbc-dev
  • xml-library needs libxml2-dev
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install libcurl4-openssl-dev libssl-dev libssh2-1-dev libmariadb-client-lgpl-dev unixodbc-dev libxml2-dev -y

For example devtools you can install from command line:

sudo R -e 'install.packages("devtools", repos = "")' 

run r script

sudo Rscript myscript.R

Install GitLab-CTL

Install these before GITLab;

sudo apt install curl openssh-server ca-certificates postfix apt-transport-https

Once installed, we will now add the GitLab repository to Raspbian in order to manage software updates more easily.

curl | sudo apt-key add -
sudo curl -o /etc/apt/sources.list.d/gitlab_ce.list "" && sudo apt-get update

Now we can install gitlab and configure it:

sudo apt-get install gitlab-ce
sudo gitlab-ctl reconfigure

If server is installed with apache web server, change relative URL port to 81.

sudo nano /etc/gitlab/gitlab.rb

and there edit external_url ''.


sudo gitlab-ctl start
sudo gitlab-ctl stop
sudo gitlab-ctl restart

To disable autostart when reboot

sudo systemctl disable gitlab-runsvdir.service

Install Time Capsule compound

Mount Your External Drive

Format external hard drive to hfs format and plug it in to Raspberry. Then get updates and install hfsprogs and hfsplus.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install hfsprogs hfsplus hfsutils

Find drive with Parted. Then mount hfs formatted usb drive for example to /mount/tm.

sudo /sbin/parted
sudo mkdir -p /media/tm

…and then add some information to the fstab file

sudo nano /etc/fstab

Paste the following line into the document, replacing /dev/sda2 with your drive’s partition, if different from /dev/sda2.

/dev/sda1 /mnt/timemachine hfsplus force,rw,user,auto 0 0

Then, mount the drive with:

sudo mount -a

Compile and Install Netatalk

Install packages

sudo aptitude install build-essential libevent-dev libssl-dev libgcrypt11-dev libkrb5-dev libpam0g-dev libwrap0-dev libdb-dev libtdb-dev libmysqlclient-dev avahi-daemon libavahi-client-dev libacl1-dev libldap2-dev libcrack2-dev systemtap-sdt-dev libdbus-1-dev libdbus-glib-1-dev libglib2.0-dev libio-socket-inet6-perl tracker libtracker-sparql-1.0-dev libtracker-miner-1.0-dev

check if you can install package libmysqlclient-dev or is there some other similar package.

Get netatalk from their webpage, and check the latest version!


Unpack the file

tar -xf netatalk-3.1.11.tar.gz

Go in to folder

cd netatalk-3.1.10

Next, you can configure all of netatalk’s settings before compiling the program, by using this command:

./configure \
        --with-init-style=debian-systemd \
        --without-libevent \
        --without-tdb \
        --with-cracklib \
        --enable-krbV-uam \
        --with-pam-confdir=/etc/pam.d \
        --with-dbus-daemon=/usr/bin/dbus-daemon \
        --with-dbus-sysconf-dir=/etc/dbus-1/system.d \

Assuming you don’t see any error messages, you can move on to the next stage and run:


and you`re ready to

sudo make install

Wasn’t that fun? Quickly check that Netatalk is actually running:

netatalk -V

Configure Netatalk

Now that Netatalk is installed, you need to tell it to share your drive. First up, you’ll need to edit nsswitch.conf.

sudo nano /etc/nsswitch.conf

Here you need to add mdns4 and mdns to the line that starts with “hosts:”, so that it looks like this:

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 mdns

This tweak means your Time Machine drive will show up in Finder’s sidebar as soon as you connect your Raspberry Pi to the network.

Next, you’ll need to edit afpd.service:

sudo nano /etc/avahi/services/afpd.service

Copy this block of text and paste it into that file:

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
    <name replace-wildcards="yes">%h</name>

Among other things, this information makes your Raspberry Pi mimic an actual Apple Time Capsule, complete with the appropriate icon.

Finally, it’s time to set up your external drive as a network share.

sudo nano /usr/local/etc/afp.conf

At the bottom of this document, paste the following text:

  mimic model = TimeCapsule6,106

[Time Machine]
  path = /media/tm
  time machine = yes

You can put a different name than “Time Machine” between the second brackets, if you want. This will change the name of the drive you back up to, as shown in Finder and Time Machine itself.

Finally, go ahead and launch the network services. In order, run these two commands:

sudo service avahi-daemon start
sudo service netatalk start

Your drive is now offered on the network. To make sure this happens every time you start up your Raspberry Pi, enter these commands, again, one after the other:

sudo systemctl enable avahi-daemon
sudo systemctl enable netatalk

Connect to server

We’re really close now! Now you can connect in you Mac to timemachine server in Finder by command + K and connect to server


You`re Time Machine should be running and ready to go when you connect



Usually you can just use:

make uninstall


sudo make uninstall


Temperature alias

Measure CPU temperature by

/opt/vc/bin/vcgencmd measure_temp

Or make it a shortcut by

cd ~
sudo nano .bash_aliases
alias temp='/opt/vc/bin/vcgencmd measure_temp'


How to make a python script executable in unix


chmod +x


Check package version

apt-cache policy {package}