Category: "Linux stuff"

Getting Started with Raspberry Pi (2017)

Getting Started with Raspberry Pi (2017)

The above is my first boot up of my Raspberry Pi 3, as purchased in January 2017.

I am writing this because so much of the information you can find on Google about the Raspberry Pi is actually outdated with regards to what you get when you order one in 2017.

In my case, I got a starter kit including an SD card, preloaded with NOOBS (which stands for "New Out Of the Box Software").

First thing to watch out for: you want to get a Class 10 SD card. These are the fastest available at this time. You can identify the card by its "C10" logo (or better said: a "10" with a "C" wrapped around it).

NOOBS is supposed to give you a choice of operating systems... except when it doesn't. And in my case it really didn't seem to offer any choice. When I booted up the Raspberry Pi for the first time, it booted straight into some version of Raspbian (the "standard" OS for the Raspberry Pi, based on Debian 8).

I'm not sure which version of Debian it really was because I could never get back the exact same one later (after installing something else...)

Boot into Recovery mode

So here's what you need to know if you actually want to choose which OS you want in NOOBS: Reboot the Raspberry Pi and hold down the Shift key. This will launch the Recovery mode of NOOBS and actually let you install the OS you want... except when it won't let you...

When I first did this, it offered my only one choice which was Raspbian.

After some research I found that this is normal. Only Raspbian is included by default...

Give NOOBS internet access!

In order to get other OSes, you actually need to connect to the Internet so that NOOBS can download additional OS images.

It's interesting the note that NOOBS can easily connect to WiFi without you entering a WiFi password. If your WiFi router has a WPS pairing button, press it and tell NOOBS to auto-pair.

Once NOOBS is connected to the internet, you actually get a wider selection of OSes to choose from:

Getting Started with Raspberry Pi (2017)

You can install more than one and NOOBS will act as a multi-boot loader at every restart.

There is a catch though: every time you want to install an additional OS or remove one you don't need, NOOBS will wipe out everything you have on your SD card and re-install everything from scratch. That's the moment I realized I would probably need several SD cards to swap out and be able to keep some stuff safe while experimenting with other OS packages. (I guess backup/restores would also work, but it would not be very convenient...)

I wish there'd be some system to have, say 4 partitions on the SD card, and being able to change the OS on each partition without affecting the others.

root password

The other thing I have wrestled with a little bit was to find the root password on Raspbian.

By default, you connect as user pi and your password is raspberry.

You can perform a series of system tasks by prefixing them with sudo. However, there are many times where you actually need to log in as root. But there is no root password!

So you actually have to create your own root password by typing sudo passwd root. After that, enter a new password for root and you'll be able to use it from that point on.

Ok, that's all for now. Back to trying out OSes...

evo-sublime theme for Sublime Text

evo-sublime theme for Sublime Text

I've just uploaded the evo-sublime theme for Sublime Text on GitHub .

It is a dark text on light background theme, with vivid highlights.

This is the theme I use to work on b2evolution.

Installation

You need to copy the color scheme into the Sublime Text Packages directory.

  1. You can find the path of the directory using the Preferences -> Browse Packages menu within Sublime Text.
  2. Copy the color scheme into this directory.
  3. Use the Color Schemes option of your preferences menu to select the evo color scheme.

How to find files recursively on Linux (or OS X terminal)

How to find files recursively on Linux (or OS X terminal)

Sometimes you need an emergency reminder about how to find all files of a certain name in a directory structure… like say: find all .htaccess files hidden in my web site. Well, here’s the magic command:

Shell

find . -name ".htaccess"

Also if you want to look for all hidden files (all files starting with a dot), you’d go like this:

Shell

find . -name ".*"

Using this to find images in iPhoto or Aperture

Sometimes you want to find the original or a preview of an image that is in your iPhoto or Aperture Library but you just can’t find it when you click on “Show Package Contents". The above command is your savior. Just execute it from within the library folder and it will find any JPG file you know the name of in a matter of seconds.

How to automatically copy out the images you find

Now let’s assume you can use this command to find lost files in your library, here’s an example of how you copy them out:

Shell

cp -`find . -name "IMG_542*.jpg"` ../recovered_files

Note the backquotes (back ticks) are used to reuse the results of the find command as arguments to the cp command. This is called “Command Substitution” in the shell.

How to check when Linux was installed

How to check when Linux was installed

If you have several servers to maintain like I do, at some point you’ll want to know how old exactly an installation of Debian (or another flavor or Linux) has gotten since you last wiped it clean…

So how do you check the install date?

I found the easiest way was to simply check the date of the lost+found folder. This folder is created at installation time and basically never removed after that. So I just go with:

ls -l /home/

and look at the date for lost+found .

Why echo is slow in PHP and how to make it really fast

You may have noticed that PHP scripts that echo a lot of content appear to be running with poor performance…

Well, the operative word here is “appear". It is a common misconception that “echo is the slowest PHP command"! :p

The problem is actually just a bandwidth issue! When you try to pump a lot of content though the Internet, at some point you experience “load time"… and at some point PHP actually experiences “send time"!

You may measure the execution time between the begining and the end of your script, and, on a slow connection, it may show you that it took 500 ms to execute. You may even narrow it down to a single echo statement that takes 480 ms to execute. But that time actually includes wait time where PHP cannot send any more data back to apache!

There is a common trick that consists of starting output befering before echoing, like this:

PHP

ob_start(); 
echo $a_lot_of_content;

This will allow PHP to move on and appear to terminate fast. But the truth is, all the content is now in PHP’s output buffer, and although your script is done, PHP is still working in the background to send all that data to your web server (apache for instance).

Full story »