EToy : Linux for noob

While reading presentations from Free Electrons (thanks a lot !), I quickly understood I had to move to Linux.

It's not a real problem since it's something I wanted to try for a long time.
Fortunately for me, I messed a lot with MS-DOS before and 'played' with a CentOS server, so CLI is not a nightmare for me (I even like it).

 

Step 1: Find a suitable distro for my need.

If you search for "download install linux" on Google, you'll find a lot of different answers
Slackware, Debian, Ubuntu, Lubutuntu and all of these Linux name are in fact name of Linux Distrib.
They all use the main Linux source code (with some adjustement) and add they own features.
Let be honest, it's a real mess ! The openess of Linux make it "easily" hackable by anyone who know how to untar and read man
It's why DistroWatch is a very handy website.

I so took the time to download and test a lot of LiveCD, a way to launch Linux with install it on your hardware.
For ex, I really liked Slitaz but I had to drop it because I doubt you'll find Slitaz on an embedded system.
In fact, I finally selected Debian, a raw (ie not based on another one) distro available with or w/o GUI
Since a lot of others distro are based on this one, I get the possibility to move it on any sub distro feeling at home

Enlightenment is another one to check...because it keeps small devices in mind (like the famous Freebox in France !)

Update : While Tiny Core Linux is a perfect lightweight distro, it's not the best choice for a first distro.
Start with a basic one before using a customized version of Linux.

 

Step 2: Virtually boot on Linux.

I don't want, for now, install Linux on a dedicated machine since I'm not a Linux pro.
To use a virtualization solution has several benefits :

Select your solution according the features you need.
Make your choice : VMWare, VirtualBox, QEmu, Parallels (Mac) ....
Note QEmu is a common tool on embedded industry but I'll keep it for another use : cross compilation.

I'm used to VMWare so I simply look for a VMWare appliance on Google, avoiding the hassle to install Linux.
I downloaded mine from ThoughtPolice, their appliance are generally well done and come with a little how-to.
Since I need to be able to work with CLI (embedded system rarely comes with GUI for OS), I selected the "minimal" version

The only drawback was the age of the appliance : it was not the last Debian release.
So after some times, I made my own virtual image !
This time, I used VirtualBox, since it's free, with the minimalist LiveCD of Debian (standard), available on the liveCD repo.
I was easy : create a new virtual image (VBox knows Debian), define the RAM to use, select if you need a hard drive or not (not needed for pure LiveCD) and load the ISO on the storage setup.

 

Step 3: Play with Linux

I so used the appliance to "feel" Linux for some weeks, based on some "10 commands you should know on Linux" or "configure your network on Linux : the easy guide" posts.
I won't explain them here, there are some many sites which already list them perfectly.

File System
The first thing to learn before you move to Linux is its file system hierarchy .
Unfortunately, not every distro follow these architecture but, for the most of them, you won't be totally lost.
In addition, this chart is a good one to print and pin on the wall in front of your desktop for reference.
I'm still trying to figure WHAT should be installed on the opt folder but it's a good start

Security
When I first used a Linux PC some years ago, I was totally lost because I didn't understand the security.
root / user / admin / group were nothing for me.
I usually log in as root every time because I want to be able to do everything I want but...is it REALLY the right thing to do ?

The answer is clearly NO.
The way to do is to use sudofor any system related command
What's the exact difference with root ?
This will give you more details but what I personally like is
Note you sould always use sudo visudo to edit the rights of sudoers (users able to use the sudo command)

 

Step 4: Configure Debian

Let be honest, while Linux detects and initialize a lot of things for you (wired network works like a charm at first boot for ex), you ALWAYS need to adjust some settings for your needs and network environment.
You could configure anything you want, but first, you need to know how !
And it's the first bad point of Linux : not a single thing is configured the same way !
Nothing like a setup folder or a file extension to use only for configuration...
It's the counter effect of an open system : you're free to do anything you want...so software developers made anything they want !

On the following chapters, I'll (try to) explain how I defined the settings for my own needs
Read the ones you need only ...or every chapter if you're curious !

Keymap
After a awful experience trying to tape sudo apt-get update, I need to setup the keyboard mapping.
I use azerty fr-latin keyboards and I don't want to lose 2 minutes every times I need to press a "/" or a "|" ... which you need everytimes on Linux !

The Linux way to change the keyboard mapping is
loadkeys fr
Good try...but you first need the mapping for your keyboard to be in /usr/share/keymaps/i386/<subdir> (it depends of your release, it may or may not be available)
Let's try to download it !
ToughtPolice's quick-how-to gives the command to change your keyboard.
Unfortunately, I quickly jumped in the Linux mess :
First, it's just awesome how every distro uses its own way to charge a keyboard mapping (look at the others ways on the other "how to")
Second, the Debin way, using dpkg-reconfigure gave me an error not found....and let me feel lost in a desert !

After some hours (hence the use of virtualization !), I finally found my answer :

If you get the error that console-data is not installed, issue this command:
   sudo apt-get install console-common

So I have an azerty keyboard ! Cool !
Well...not really, console-common adds EVERY known keyboard mapping (atari, mac..!)
Do I really need to use 4 Mb for a French keyboard ?! It's not a solution for embedded device.
So I need to install it, save the fr.kmap.gz on a shared folder, revert back my VMWare image and install back the file (a light version of apt-get console-common made manually)

For a shared folder, I have 2 solutions :
1/ install VMWare tools to support local shared folder
2/ configure my network to use a shared folder anywhere in my LAN

Since I don't want to lose +40Mb for VMWare tools and I'll need to learn to quickly setup a local network, save a snapshot on my now heavy DebianFr and let's go for the network shared folder....

Network
//TODO : SMB Share

Proxy
For one of my tests, I was under a proxy.
It's quite easy to configure the proxy on Debian...if you know how to do it !
Since I was on a LiveCD, no need to configure it the hard way, just for the session
You have to define the env var http_proxy this way : export http_proxy="http://username:password@proxyadress_or_ip:port"
Hint: it doesn't like special char on username/password so use %<ascii_code> for any special char

This is a user env solution : env vars defined here are env vars using default user.
If you ever use sudo, only some defined vars will passed from user to root environment.
To fix this, we'll need to add the http_proxy var to this common vars list:
launch sudo visudo and add
Defaults env_keep += "http_proxy https_proxy ftp_proxy no_proxy"
Be sure to use a tab after Defaults
visudo is an editor based on Vi, the best or worsteditor existing, so be sure to know how to use it !

 

Step 5: Master boot process

Boot is a key feature on embedded device.
You'll quickly need to initialize a (hardware) device or a service within the boot process, not manually.

I learnt, thanks to linux openness again, there is several ways to do it
I personnaly find that using the rcX.d/Sxx file to be the best and more logic way to do it
The only difficulty is to know which rcX.d/Sxx file to update and in which rcX.d folder !
I was totally lost at first. Reason was you first need to be aware of the "run levels".
Is it normal you need to know with kind of infoto automatically launch an application after the boot successfully end ?
From my point of view, no. It's one of the (lot of) reasons why mister everyone won't move to Linux

So yes, you first need to understand what happen and what is launched on boot (or reboot or halt).
Hopefully, everyone is explained (good luck!) on the official Linux Intro documentation