Set up development environment


This article describes my working environment for development and troubleshooting that I encountered while configuring applications.

Edit hosts file on OS X (10.5 and 10.7)

You can find hosts file on older OS X in /private/etc/hosts file (use sudo to edit).

Customize CLI commands (OS X 10.7, Raspbian)

To create a customized CLI command, eg. ll = ls -la, add the following line in .profile file in user's home directory:

alias ll="ls -la"

VirtualBox (OS X)

Free tool for virtualization. It provides some CLI options with VBoxManage app.

Check status of Virtual Machnes:

$ VBoxManage list vms

Check status of Virtual Machnes (only running):

$ VBoxManage list runningvms

Installing CentOS 6 in VirtualBox

Download the minimalistic image of CentOS 6 (CentOS-6.4-i386-minimal.iso).

Install it in VirtualBox according to the user manual (set the root password and other stuff).

The installed OS is more or less empty. There is no GUI, no network...

Enable eth0 network interface:

$ ifup eth0

Now you should have access to network (via VirtualBox NAT). To set its own IP to VM, change network adapter to 'Bridged' in VirtualBox. Try $ ping

Troubleshooting: No Suitable Device Found: No Device Found for Connection 'System eth0'

This erros occurs after cloning a virtual machine or if the host hardware was changed. Kernel cannot find find device eth0, therefore it creates new one, namely eth1. To change eth1 back to eth0, follow the next steps:
1. First check MAC address of network adapter ($ ifconfig).
2. Open /etc/sysconfig/network-scripts/ifcfg-eth0 file and enter correct MAC address in HWADDR parameter. Make sure you are using unique IP address. Here is my example:

NAME="System eth0"

3. Restart network service (or reboot):

$ service network restart

4. Open the /etc/udev/rules.d/70-persistent-net.rules file and delete unused devices. You should only leave devices that you use (eth0 in this case):

# PCI device 0x8086:0x100e (e1000) (custom name provided by external tool)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:22:28:4c", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

Instal Desktop Tools for CentOS (CentOS 6 in VirtualBox)

To install GUI (windows), first install X system and then Gnome desktop

$ yum groupinstall -y 'X Window System'
$ yum groupinstall -y 'Desktop'

Optionally install additional desktop tools:

$ yum groupinstall -y 'Desktop Platform'
$ yum groupinstall -y 'Graphical Administration Tools'
$ yum groupinstall -y 'Internet Browser'
$ yum groupinstall -y 'General Purpose Desktop'
$ yum groupinstall -y 'Office Suite and Productivity'
$ yum groupinstall -y 'Graphics Creation Tools'

To install KDE desktop:

$ yum groupinstall -y kde-desktop

Optionally install additional desktop tools:

By default the OS is running in CLI mode. To automatically start Gnome desktop at startup, open the file /etc/inittab with vi and change:




Manually start Gnome desktop with:

$ init 5

Alternative way to start Gnome desktop:

$ startx

Follow the initial setup wizzard.

Because Terminal has terrible fonts, install additional fonts:

$ yum groupinstall -y fonts

Set Liberation mono, size 10 as default font in Terminal (or whatever you prefer).

Installing CentOS 7 in VirtualBox

Download the minimalistic image of CentOS 7 according to your system requirements. In my case: CentOS-7-x86_64-Minimal-1511.iso or CentOS-7-i386-Minimal-1511.iso (for non 64 bit).

Install it in VirtualBox (set the root password and other stuff).

The installed OS is empty. There is no GUI, no network... To install GUI, see Installing GUI in CentOS 6 and do all the yum groupinstall. I just noticed that the yum groupinstall 'Desktop' was replaced by 'GNOME Desktop'.

In CentOS 7 the well known ifconfig was replaced with ip command. Try these commands and figure out what it means:

$ ip addr
$ ip link
$ ip -s link // show statistics

Ifconfig command is still available as part of net-tools package:

$ yum install net-tools

First you need to get CentOS online. I tried traditional $ ifup eth0 and failed since the file ifcfg-eth0 does not exist. Instead eth0 you probably have enps0s3 which might be used as well with ifup, but I want ETH0! No problem. Let's create it:

$ vi /etc/sysconfig/network-scripts/ifcfg-eth0

The contents should look like this (note that static IP is set):

NAME="System eth0"

Reboot and try again:

$ reboot
$ ifup eth0
$ ping

FTP client (Fedora 17, CentOS 6)

Install FTP client:

$ yum install ftp

FTP command line manual: here

vsftpd FTP server (Fedora 17, CentOS 6)

Install vsftpd:

$ yum install vsftpd

Start FTP server:

$ service vsftpd start

To automatically start vsftpd at boot on Fedora 17:

$ systemctl enable vsftpd

To automatically start vsftpd at boot on CentOS 6 (also works on Fedora 17; the request is forwarded to systemctl anyway):

$ chkconfig --level 235 vsftpd on

Allow user access to ftp (create also empty file /etc/vsftpd/chroot_list)

$ vi /etc/vsftpd/vsftpd.conf

Due to security reasons, create new user without any login permissions, just own a directory for sharing files:

$ mkdir /home/ftpuser
$ groupadd ftp-users
$ useradd --home /home/ftpuser --group ftp-users --shell /sbin/nologin ftpuser
$ passwd ftpuser
$ chown -R ftpuser /home/ftpuser/
$ chmod 755 /home/ftpuser/

If created user cannot login to ftp, you might need to disable SELinux (/etc/sysconfig/selinux).

Enable FTP server on OS X 10.7

Apple removed FTP configuration from GUI (System Preferences - > Sharing) in OS X 10.7. You can enable FTP server through CLI.

Enable FTP server:

$ sudo -s launchctl load -w /System/Library/LaunchDaemons/ftp.plist

Disable FTP server:

$ sudo -s launchctl unload -w /System/Library/LaunchDaemons/ftp.plist

Enable SSH (Fedora 17)

Enable SSH access in firewall configuration:

$ system-config-firewall &

Start SSH server:

$ service sshd start

To automatically start sshd at boot on Fedora 17:

$ systemctl enable sshd

To automatically start sshd at boot on CentOS 6.5 (also works on Fedora 17; the request is forwarded to systemctl anyway):

$ chkconfig --level 235 sshd on

Install Java (Centos 6, Fedora 17)

Download binary distribution of java (eg. jdk-5u43-linux-i586-rpm.bin)

Change permissions to executable:

$ chmod a+x jdk-5u43-linux-i586-rpm.bin

Run as root:

$ ./jdk-5u43-linux-i586-rpm.bin


$ JAVA_HOME=/path/to/jdk1-5_43


$ export PATH

To remember PATH permanently, you need to specify PATH every time when system starts. Place custom shell script into /etc/profile.d directory. PATH will be visible to all users.

$ vi /etc/profile.d/


export JAVA_HOME

export PATH

$ chmod +x /etc/profile.d/

Install Apache Tomcat (Fedora 17)

Download Apache Tomcat and unzip to /opt directory

Create symbolic link:

$ ln -s tomcat apache-tomcat-x.x.x

To run Tomcat as normal user, change ownership to normal user:

$ chown -R matjaz:matjaz apache-tomcat-x.x.x

MySQL (Fedora 17)

I installed MySQL with GUI tool Add and Remove applications

I encountered some errors when trying to run MySql, so I changed ownership and group:

$ chown -R mysql /var/lib/mysql
$ chgrp -R mysql /var/lib/mysql

Then run mysql daemon as root:

$ mysqld_safe &

Now continue reading MySql tutorial: here

net-snmp (CentOS 6)

Install net-snmp and net-snmp-utils with Add and Remove applications

Start snmpd (as root because it opens port 161):

$ service snmpd start

Allow connections to 161 through the firewall:

$ iptables -I INPUT 5 -p udp --dport 161 -j ACCEPT
$ service iptables save

net-snmp-utils provide commands for snmpget, snmpset, snmpwalk...

tcpdump (CentOS 6)

tcpdump is packet analyzer tool (aka Wireshark in CLI)

$ yum install tcpdump

Click here to see instructions

Grunt (CentOS 6)

First you need to install Node.js from Node is a platform where Grunt can run. Node installs npm tool, which is mandatory to run Grunt. During installation of node.js npm should automatically be added to the PATH, so it can be used in CLI from terminal window.

I got the source files from NodeJS download page. You will have to compile them first. To compile the sources, you need a C compiler, which I downladed via 'Add/Remove software' tool. This was not enough to compile the node.js, so I downloaded also gcc-c++ with yum:

$ yum install gcc-c++

Then compile the node.js sources (from nodejs directory):

$ ./configure
$ make
$ make install

Create new file inside your project directory: package.json. This file describes components (Grunt plugins) that will be used by Grunt. The file must contain at least the following contents:

"name": "test-project",
"version": "1.0.0",
"devDependencies": {
"grunt": "~0.4.1"

Place the file inside your project root directory and run the command:

$ npm install

New directory node_modules should be created in project root directory.

Then install Grunt CLI tool:

$ npm install -g grunt-cli

Go (golang) (OS X 10.7)

Go is programming language by Google. The easiest way to install it on OS X is by downloading .pkg and let the installer to do its job (go1.6.darwin-amd64.pkg).

The installer installs all necessary files in /usr/local/go directory and adds go to the PATH.

Go requires to add your workspace location to the PATH as $GOPATH:

$ export GOPATH=/path/to/your/workspace

To permanently add GOPATH to PATH then add it into $HOME/.profile file.

Inside workspace create directory structure: src/ and create new .go file inside hello directory:

$ vi src/

package main

import "fmt"

func main() {
fmt.Printf("Hello world!\n")

Compile (from $GOPATH directory).

$ go install

Compiled binary file is stored in $GOPATH/bin directory. Run it with (it must be executable):

$ ./hello

LiClipse - Python IDE (OS X 10.7)

There are a few things to verify and configure before LiClipse can be used.

These instructions are written from back to start, since there is always something else to to first.

Download LiClipse. It comes as .dmg image. Just copy the LiClipse to Applications directory.

Start LiClipse. Open Preferences -> Interpretes -> Python interpreter. Here you must set path to python. Because the default installation of Python is missing source files and /Lib directory, you must first install the individual installation of Python from I choose sources tarball, so the sources must be compiled first.

Download Python sources (in my case 2.7.11). To compile the sources you need gcc compiler which also doesn't come with OS X.

Via Apple Developer download Command Line Tools for XCode (luckily I have XCode 4.6.3 already installed) and install it.

Now back to compiling Python sources. Run './configure --enable-framework=/Users/matjaz/Library/Frameworks'. This will install Python into Frameworks directory under selected user. Then execute 'make && make install' from the Python top level directory.

Now you can configure Python interpreter in LiClipse. Select /Users/matjaz/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7

Making bootable SD card for Raspberry Pi (OS X 10.7)

If you don't have a SD card reader I am pretty sure you have smart phone with Android. Insert SD card into smart phone and connect the phone to computer using USB cable. Select to mount SD card as disk (drive). SD card can be formatted using DiskUtility (use FAT32). Then you can burn the Raspbian image to the disk using the following commands:

$ diskutil list
# search for correct disk identifier (in my case disk2)
$ diskutil unmountDisk /dev/disk2
$ sudo dd bs=1m if=/path/to/raspbian.img of=/dev/rdisk2

Eject the SD card and use it with Raspberry Pi

Well, it would be too good if things go so smoothly. Later I discovered that the whole root partition on SD card was filled with Raspbian OS, leaving me only about 100 MB of free space (on 8 and 16 GB card). Digging deeper into google I found the solution. Don't ask me what and why and how because I didn't understand well. It has to do something with Linux partition that was left unused. Read more on this link: Here are the steps how to expand the root partition.

sudo fdisk /dev/mmcblk0

Type p to list the partition table. You should see twoo (or three) partitions. In my case: W95 FAT32 and Linux.

Command (m for help): p
Disk /dev/mmcblk0: 14.9 GiB, 15931539456 bytes, 31116288 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3e7fd08e

Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 131071 122880 60M c W95 FAT32 (LBA)
/dev/mmcblk0p2 131072 8060927 7929856 3.8G 83 Linux

Remember the start number for partiton 2 (131072).

Type d to delete a partition. Enter the number of partition to be deleted - in this case the second partition (2). Repeat for partition 3 if exists.

Command (m for help): d
Partition number (1,2, default 2): 2

Partition 2 has been deleted.

Now you can resize the main partition. Type n to create a new partition, then type p to create primary partition and enter 2 for partition number. When prompted enter the start number of first sector 131072. At the end you'll be prompted to enter the number of last sector - just hit enter to accept default value (all remaining space).

Command (m for help): n
Partition type
   p primary (1 primary, 0 extended, 3 free)
   e extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2048-31116287, default 2048): 131072
Last sector, +sectors or +size{K,M,G,T,P} (131072-31116287, default 31116287):

Created a new partition 2 of type 'Linux' and of size 14.8 GiB.

Type w to save the changes:

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy

The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).

Reboot the system

sudo reboot

Execute the next command:

sudo resize2fs /dev/mmcblk0p2

Reboot the system again

sudo reboot

Check the size of partitions:

$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/root 15G 3.4G 11G 25% /
devtmpfs 459M 0 459M 0% /dev
tmpfs 463M 0 463M 0% /dev/shm
tmpfs 463M 6.4M 457M 2% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 463M 0 463M 0% /sys/fs/cgroup
/dev/mmcblk0p1 60M 20M 41M 34% /boot
tmpfs 93M 0 93M 0% /run/user/1000

Configuring static IP on Raspberry (Raspbian Jessie)

Configure network interfaces:

$ sudo nano /etc/network/interfaces

auto lo
iface lo inet loopback

iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf

iface mySSID inet static

iface default inet dhcp

Configure wpa_supplicant.conf file:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev


Notice that id_str in wpa_supplicant.conf must match iface name in interfaces file!!

Raspberry Pi - Remote Desktop Connection via X11 (OS X 10.7)

On OS X it is very easy to setup remote desktop to Raspberry.

First start X11 on OS X (additionally set 'Allow connections from network clients' in preferences and execute 'xhost +' command)

Connect to Raspberry with ssh using -X option:

$ ssh -X pi@

On Raspberry then execute:

$ /etc/X11/Xsession

The Raspberry Desktop should open on your Mac.