The blog of Philippe Ndiaye2015-03-17T16:54:12+00:00http://phndiaye.github.ioPhilippe Ndiayeme@iamphinson.comThe current state of init systems2014-02-11T00:00:00+00:00http://phndiaye.github.io/the-current-state-of-init-systems<p>Recently, the <strong>init systems</strong>’s world has been moving a lot. After many
discussions, <em>systemd</em> have good chances to be adopted as Debian’s default init
system. But, for those who do not really know what it is and mean, this
information is pretty useless… or at least «just another news in a day».</p>
<h3 id="whats-that-init-system-">What’s that init system ?</h3>
<p>According to <a href="http://en.wikipedia.org/wiki/Init">Wikipedia</a>:
> […] init (short for initialization) is the first process started during
> booting of the computer system. Init is a daemon process that continues
> running until the system is shut down. It is the direct or indirect ancestor
> of all other processes and automatically adopts all orphaned processes…</p>
<h3 id="know-the-linux-startup-process">Know the Linux startup process</h3>
<p>To my eyes, this definition needs additional informations. In fact, to easily
understand the place and role of the init system in Linux, one might know
the Linux startup process. And as a picture is worth a thousand words, here is
one!</p>
<p><img src="/public/linux-startup-process.jpg" alt="Linux Startup Process" width="100%" /></p>
<p>First, note that the schema has been highly simplified. Only one blog post will
never suffice to describe the whole startup process.
As you may notice, the main parts of the schema are commented, but still need
some additional stuffs…</p>
<ul>
<li>
<p>BIOS: Once you turn on your computer, the first task it does is to run the
BIOS (or <em>Basic Input/Output System</em>). Unlike following parts, this software
is tied to the computer manufacturer and is part of the hardware.
Its main task is to run tests on hardware and detect failures (no RAM, problem
with the CPU…) BIOS is slowly being replaced by
<a href="http://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface">UEFI</a></p>
</li>
<li>
<p>Boot loader: If nothing went wrong during the BIOS’ tests, this one runs the
boot loader from the MBR (Master Boot Record). Explained simply, the boot
loader is just a software that you use to start an OS, or do some advanced
tasks as an administrator (in case you reach some extrem cases). The runnable
OSes can be others than Linux, you can even run your good’ol Windows (And even
Windows have its own bootloader).</p>
</li>
<li>
<p>Kernel loading: this is probably the darkest part of the process. Given that a
«normal» user should not be able to run some critical tasks on the OS, this
one start itself in kernel mode for loading device drivers, or a bunch of
kernel modules. By the way, apart the security issue, i am sure you does not
want to do all these by hand…</p>
</li>
</ul>
<h3 id="you-missed-one-and-whats-that-init-system-again">You missed one, and what’s that init system again?</h3>
<p>The best part, or let’s say, the <em>Human</em> part of the Linux startup process is
the <strong>userland</strong>. Once the kernel finished all its tasks, the userland space
just take over and run all the tasks that are possibly runnable by users without
too many risks. And that’s where the <strong>init system</strong> step in.</p>
<p>This one has been created to execute all the early run tasks like mounting the
filesystem. Plus, it also manages all the process that will be spawned during
the machine’s uptime until it gets shut down. Yes, even your <em>nginx</em> you
launched 5 minutes ago is managed by the init system, what makes it its parent.
So, init is the first process that is launched in userland (its PID is 1), and
is the parent of all other processes. If one die, it knows it. And if init is
killed, every other process dies with it. It is that simple.</p>
<h3 id="why-are-there-so-many-init-systems">Why are there so many init systems?</h3>
<p>Initially, the default init system where just named after <strong>init</strong>
(«init daemon» or «SysV init»); but it went old and its designs are not suitable
for our time anymore, so some replacements has been created.</p>
<p>However, from all the candidates, 3 has been widely used: <strong>OpenRC</strong>,
<strong>upstart</strong> and <strong>systemd</strong>. All of them are Free and Open Source softwares.</p>
<p>From now, i will explicitely name the init daemon by SysV init. If <em>init system</em>
is present, it means the generic initialization system (without distinction
between daemons.)</p>
<ul>
<li>
<p>OpenRC only works <em>with</em> the init system (usually Sysv init) and does not aim
to replace it. One of its greatest features and advantages is that it is
portable to non-linux distributions, so you can use script for Linux
distributions on a BSD-based distribution for example.</p>
</li>
<li>
<p>Upstart has been developed by Canonical as a replacement for Sysv init, this
one having some design issues. The main difference between them, which is also
a strength for Upstart, is that Upstart is a non-blocking init system. So
if you start to tasks, the later run will not have to wait the first to finish
before launching.</p>
</li>
<li>
<p>The last one, systemd, is the future. In addition to the parallel starting of
the processes, systemd is also a whole framework, as it comes with a logging
system, a job sheduler (replacements for <em>syslog</em> and <em>cron</em>), and many other
features/programs.</p>
</li>
</ul>
<h3 id="why-is-systemd-winning-the-init-war">Why is systemd winning the init war?</h3>
<p>Since it announcement, systemd has been widely adopted. Practically all the
major Linux distribution now enable it by default as there init system
(Fedora, ArchLinux, RHEL 7 => CentOS, OpenSuse…) and it will be <a href="https://lists.debian.org/debian-ctte/2014/02/
msg00402.html">choosen for
the next Debian release (Jessie)</a>. After Debian decided to use systemd, Mark Shuttleworth announced
on <a href="http://www.markshuttleworth.com/archives/1316">his blog</a> that this would be
also an decision for Ubuntu as a part of the Debian family.</p>
<p>But why does it succeed? IMHO, one key of its success is the set of features it
comes with. Instead of being a replacement for just Sysv init, it also comes
with a complete ecosystem. Plus, the systemd startup scripts are not written as
shell script but in a simple and powerful declarative language.</p>
<p>But apart the technical features, i think the biggest advantage it have against
its concurrent are not even technical. And i will finish on these:</p>
<ul>
<li>
<p>Documentation => systemd has an extensive documentation, from internal designs
to usage and include configuration.</p>
</li>
<li>
<p>Communication => If systemd is were it is now, IMO, it’s because its
developers has been «selling» their product to distributions. Fedora, which is
really not a small distro, adopted it one year after the initial release as
its default init system. And even <a href="https://bugs.
debian.org/cgi-bin/bugreport.cgi?msg=3546;bug=727708">people at Spotify like it</a>.</p>
</li>
<li>
<p>It has a growing community; which is to me one of the most important arguments
when picking a solution.</p>
</li>
</ul>
<p>Some comments has been added via reddit, here is the thread: <a href="http://www.
reddit.com/r/linux/comments/1xtg4j/the_current_state_of_init_systems/">http://www.reddit.
com/r/linux/comments/1xtg4j/the_current_state_of_init_systems/</a></p>
So you want to learn Python...2014-01-20T00:00:00+00:00http://phndiaye.github.io/so-you-want-to-learn-python<p>Last month, i’ve been posting and reading posts on G+ more than i did since i subscribed on it (almost 2 years).</p>
<p>The first thing i realized is that it’s that it’s awesome for learning and read thoughts on technos or project. The second was the amount of posts about learning Python. As i do not see myself as a Python expert (i’m so far from it at the moment), i think i have been dealing with the language and learned lot of things about it since i wrote my first <code>#! /usr/bin/env python</code> line. So, here i wanted to share my thoughts about my learning path and some links too.</p>
<h2 id="do-not-want-to-learn-just-learn-">Do not want to learn, just learn !</h2>
<p>I’ve been wanting to learn Python for more than 2 months. And now i realize that it is a lot of lost time. Wanting to learn Python, or any other language after getting some resources to get started is just boring as there is not a defined list of resources to read. When i decided that it was high time i dive into Python, i just started with the <a href="http://docs.python.org/2/tutorial/">Python official tutorial</a>.</p>
<p>As far as i’m concerned, it’s one of the best resources for getting started. And even with other technos/projects unrelated to Python, if the website or documentation have <em>Getting Started</em> section, reading it is totally worth it.</p>
<h2 id="the-weird-path-learn-from-the-top-level">The weird path: Learn from the top-level</h2>
<p>When i started to learn Python, i was doing a lot of web development in PHP and was not really interested in system administration. So i first searched for Python-written projects to, let’s say, motivate me. Knowing that my favourite web applications (Dropbox and Pinterest) was written in Python boosted me as i’ve never been. After that, i searched for frameworks for web development and finally had to choose between Django and Flask. I choose Flask. Just because it was lightweight and looked like a great framework (nice doc, extensible…).</p>
<p>The reason i consider this way of learning weird, is that for all languages i learned, i went through a classic path: learn basics, write programs for whichPython could be a suitable language, write shitty programs you will never use only because they are in the tutorial, code advanced programs like games. But i could not use this method this time for 2 reasons:</p>
<ul>
<li>You can do almost every type of program in Python, so «Python could be a suitable language» was not really valid in this case.</li>
<li>I was sick of writing games. We do that at school, in tutorials, everywhere. But i’m not a even a gamer so writing games is a torment.</li>
</ul>
<p>What i want to say after all this long block of thoughts, is that the learning path can be different for you. And do not think that you are doing it wrong only because all people you met say they won’t learn this way. Follow the learning method used by others and not by you and you won’t learn anything.</p>
<h2 id="find-a-mentor">Find a mentor</h2>
<p>This is not always possible in the real world. It depends on your entourage. I’ve been learning Python as a student, but on my own. In 5 years of school, we have no Python courses, so i’ve been harassing my friend who told me about the language for a long time before going on my own. Thanks to him. If you can’t find a mentor in the real life, the guyz/gals on the Internet will be glad to help you. I’ve seen people on G+ answering at any kind of questions, from the ultimate beginner one, to the expert pythonista of the death one.</p>
<h2 id="github-is-your-mentor">Github is your mentor</h2>
<p>You still not find a mentor. I’ve discovered a guy named after Github that can help you. The best mentor i found the last year were… <em>reading other’s code</em>. This can teach you a lot of things. From patterns to best practices. And the projects there are often used in production. Pick a project you like, not the biggest one you find. Even if it’s 100 lines of code, if you can read them and explain what they do, it’s always better than the 32168 lines of code of the biggest project you find and do not even know what the half do.</p>
<p>Personally, i started with Flask, because i loved it and wanted to know more about the framework i used. I read the code, and i even knew WSGI implementations with it.</p>
<h2 id="read-peps">Read PEPs</h2>
<p>I know, that’s weird. Many people read the PEP8 and other code presentation related PEPs. I want to read them all. After reading Python code for more than a year now, and understand what these codes do, i wanted to know WHY they do that. Python’s PEPs is the only system i know to be that open. 2 clicks to see all the PEPs when you are on the website’s homepage. This part may wait that you are already comfortable with Python, but hey ! Some does not even require a high level in understanding the language.</p>
<h2 id="be-a-mentor">Be a mentor</h2>
<p>This is probably the best way to learn: <em>teaching</em>. Trying to get people around be learn our language bring me into teaching them the basics, answer to their questions, even if i’m not an expert. Helping people helps you learn more and more each day. For example, questions about the encoding «problems» (not a problem, i think) have me learning lots of stuffs about encoding in general. Same thing with frameworks like Flask or Tornado and explaining WSGI interface to non web developers.</p>
<h2 id="links-">Links !</h2>
<p>Here are some links that have been useful for me in my Python adventure (not many as you can notice):
* <a href="http://docs.python.org/2/tutorial/">Python’s tutorial</a>
* <a href="https://wiki.python.org/moin/WebFrameworks">Python Web Frameworks</a>
* <a href="http://www.codecademy.com/tracks/python">Codecademy Python course</a>
* <a href="http://learnpythonthehardway.org/">Learn Python The Hard Way</a></p>
My awesome Linux environment: from apps to dotfiles2013-12-16T00:00:00+00:00http://phndiaye.github.io/my-awesome-linux-environment<p>Since i switched from Windows to Linux, i have been using <em>Ubuntu</em>, <em>Fedora</em>, then
Ubuntu again, before choosing this last for almost 4 years. In these for years,
i’ve been using multiple apps, before and after being interested in computer
science, even if, as you can imagine, it changed a lot of my habits.</p>
<p>Today, i’m using <strong>Archlinux</strong>. Yes, i leaved my lovely Ubuntu since 6 months now.
The main reason was that, as a developer, i hated on the fact that last
packages’ versions were almost never available. And i had to search for hours
for a PPA to install some packages, before realizing i got the wrong version.</p>
<p>But, we are not there to talk about my hatred of the late Ubuntu packages
availability. Contrariwise, i will talk about the tools i use in my daily life.</p>
<h1 id="i-see-code-everywhere">I see code everywhere</h1>
<p><img src="/public/gvim-django.png" alt="GVim, the most powerful editor" /></p>
<p>Even if i know it quite a long time, i beginned using <strong>Vim</strong> since only 6 months.
If you want to join the Vim users, you should use GVim, which is a Vim version
with a graphical interface. By using this, you could learn at your rhythm and
use the mouse for almost all tasks (i think …).</p>
<p>It is an awesome text editor, and i really don’t regret using it. It have all i
need for coding, editing all sort of files, and even if i wont probably use it
for languages like Java, i will always use it for those like Python or Perl.</p>
<h1 id="desktop-environments">Desktop environments</h1>
<p>Having used Ubuntu for years, when Gnome was still the desktop manager, i never
changed. I spent a little time testing Unity but i finally returned to Gnome.
Now, it’s Gnome Shell but the break have not been too hard for me. It’s pretty
easy to use, and the desktop switching is THE feature i love for coding.</p>
<p>Next to Gnome Shell, i use the Awesome window manager occasionally to see how it
works and test some of the capabilities. It’s highly configurable and could even
help me learning Lua so maybe i will swich from Gnome Shell to it one day. If
they stop breaking the API at each release.</p>
<h1 id="probably-my-favourite-gui-programs-">Probably my favourite GUI programs …</h1>
<ul>
<li>
<p>Chromium</p>
<p><strong>Chromium</strong> is the base of the Google Chrome web browser. It’s open source and
heavily improved by the community. Being the codebase of Chrome, it’s not a
lot different of it. The missing parts are the PDF reader (Adobe Reader) and some
other stuffs … It supports Chrome Extensions.</p>
</li>
<li>
<p>Transmission</p>
<p><strong>Transmission</strong> is probably the tool i liked the most in Ubuntu, where it
stands as the default Torrent/Magnet client.</p>
</li>
<li>
<p>Mozilla Thunderbird</p>
<p>To my eyes, it’s the most featured graphical e-mail client on Linux. I tried
to use Mutt (a command-line one) but i did not last long. The main problem
that i could have with it, is that it’s not highly configurable … :/</p>
</li>
<li>
<p>Gnome Terminal & Terminator</p>
<p>What’s a Linux user without a terminal emulator ? Nothing. That’s why i
spend the most of my time (or almost) trying to find THE terminal that will
change my life. But for the moment, i only found these two. <strong>Gnome
Terminal</strong> is the terminal of the Gnome project and <strong>Terminator</strong> is a
terminal multiplexer, in that you can have multiple terminals in only one
window. They both worth a try.</p>
</li>
</ul>
<h1 id="command-line-tools-rocks">Command Line Tools Rocks.</h1>
<p>I write code a lot. And versionning, testing librairies and writing unit tests
have become parts of my life.
* For versionning, i’m using <strong>Git</strong>, because it rocks and because i want to
know it more deeply too.</p>
<ul>
<li>
<p>As a Python developer, testing librairies, and their support of Python’s
versions is the daily life now. So i use <strong>Virtualenv</strong> to test multiple
versions of librairies or Python versions. They are all sandboxed so their is
no way to break my other projects.</p>
<p>I discovered unit tests this year as an intern @ <a href="http://kozea.fr" title="Kozea">Kozea</a>. They were using <em>nose</em> as the unit testing tool, so i adopted it. I
should take the time to test some other tools one of these days.</p>
</li>
</ul>
<p>By the way, i love IRCs, and i use <strong>IRSSI</strong> for it.</p>
<h1 id="keep-calm-and-write-dotfiles">Keep calm and write .dotfiles</h1>
<p>These files changed my life. Customizing almost all my tools so that i can use them
without losting time even increased my motivation for learning and working. It
started with <em>.zsh</em>, the configuration file for the <strong>Zsh shell</strong>. Then it was
the turn of <strong>Irssi</strong>, my favourite IRC client. Anyway, writing these made me
gain a lot of productivity. And, even if you don’t know how to write your
dotfiles, Github is a great source of inspiration. And community-driven
frameworks like <a href="http://github.com/robbyrussell/oh-my-zsh">OhMyZsh</a> or <a href="http://dotfiles.github.io">Github’s
dotfiles</a> can help you setting your workflow up
more easily.</p>
<h1 id="the-closing-thoughts">The closing thoughts</h1>
<p>Switching from tool to tool these last year helped me gain in productivity and,
ironically, lazyness. I realized how powerful and useful were the Open Source
culture and i learned a lot from only watching repos on Github (dotfiles, cool
projects, useful tools, etc) …</p>
<p>If you have any idea of tools that’s worth testing, let me know ;)</p>
Learning curves overcome — The Hard Way (or not)2013-12-09T00:00:00+00:00http://phndiaye.github.io/learning-curves-overcome-the-hard-way<p>We all had a mental block when replaced our nice and <em>all-doable-with-the-mouse</em>
operating system called Windows by this <em>users-must-be-crazy</em> operating system
called Linux (and Unices too). If you did not have this problem, maybe you are
one of these people who are able to change their habits from one day to the next
without any problem.</p>
<p>As far as i am concerned, it took a long, long time before i switched completely
to Linux. Here i talk about all the changes, not only about Windows-to-Linux
switching but about tools i was using too.</p>
<h2 id="windows-to-linux-omg--i-did-it-o">Windows to Linux: OMG ! I did it :o</h2>
<p>As many people of the 90’s generation, i discovered computers with Windows
systems. I started with Windows XP when was 6 years old, played lot
of PC Games, used Windows Vista, then came back to Windows XP. And the last
Windows system i used was <em>Seven</em>.</p>
<p>Those days, i thought their was only two operating systems: Windows and Mac OS.
Then, one day like any other, my brother talked me about Ubuntu, that himself
was using since few months. My answer to that “change-your-life” proposition
was: «Your are a just a geek ! Why do you want to complicate your life ?» … or
something like that. But i tried it anyway, when my Windows crashed. My brother
told me i could get a free installation CD. Imagine my reaction when i received
a free OS, shipped to Senegal (West Africa) for free !</p>
<p>So, i installed my new OS as a dual-boot with Windows Seven. It was Ubuntu 9.04
(Jaunty Jackalope), those days. Cool installation, not what i expected to see
(an old and hard console), then the desktop revolution, this good ol’ Gnome. The
only thing i missed was games, that’s why i keeped a Windows installation.</p>
<p>From this day, i always worked with dual-boots. More time spent on Windows in
the first year, then maybe equal time, then i became a Ubuntu user and Linux
systems evangelist. It made my brother laugh.</p>
<h2 id="from-classic-ides-to-vim-wait--whaaaaaat-">From “classic” IDEs to Vim: Wait ! Whaaaaaat ?</h2>
<p>Being a Linux user got me interested in computer science more than i already
was. Yet when using Windows and learning programming languages, i was using IDEs
like Code Blocks for C, or Dreamweaver for HTML/CSS. When i entered university
cursus, i discovered Sublime Text 2. I used it for 2 years, even for languages
requiring a compilator because i compiled from the terminal. Handmade forever !</p>
<p>It was like that until my internship at <a href="http://kozea.fr/" title="Kozea">Kozea</a>. All
the team’s members was using either Vim or Emacs. My tutor proposed me to try
Vim or Emacs. I choosed Vim, mainly because Vi was installed on almost, if not
all, Linux systems. It was hard the first week. Then i realized that working
everyday with a tool, even if it’s different from all tools you was used to work
with, makes you overcome the learning curve.</p>
<p>So, after only 2 weeks as an intern, i replaced my Sublime Text by GVim, first.
I used some settings to have it working as classic IDEs (copy-paste with Ctrl-C,
Ctrl-V). As time passes, i removed some of these “hacks” and beginned using Vim
as it was originally shipped. Finally, in the end of my first month, i went from
saying «You are crazy using Vim.» during 2 years to «You should use Vim. It will
boost your productivity to an unexpected level.»</p>
<h2 id="everybody-has-his-method-for-overcoming-learning-curves-here-is-mine">Everybody has his method for overcoming learning curves. Here is mine.</h2>
<p>In the last 6 months, i practically changed all my habits as an aspiring
sysadmin and developer. But it was not easy.</p>
<p>The most suitable exemple is with Vim. I started with custom configuration to
help me use the mouse, copy-paste like in other editors like Sublime Text,
change the colorscheme with the mouse in GVim … Then i removed some of these
settings, one by one to my rythm. And now i’m using Vim in the console without
particular problems.</p>
<p>Once i found my learning curve overcoming method, i applied it to almost all
tools i wanted to learn. It started with Zsh, that i have heard a lot of good.
For this case, i started with Oh-My-Zsh, then uninstalled it and tried to set
some of the stuffs that i liked myself (Git branch displaying, Shell prompt
settings …). Now, we can say that it helped me learn an extraordinary Shell.</p>
<h2 id="the-closing-thoughts">The Closing Thoughts</h2>
<p>Learning curves are not same for all people. And it will never be, whatever tool
you want to use. Some people can trade their super awesome IDEs in a week, some
other in a month, like it took me. But, if their is something i learned during
my last 6 months, it is that accepting that the tool you want to use is
«different from what you was using» is the most difficult part. The real
learning is just after that.</p>
An intro to this new blog: What have changed ?2013-12-01T00:00:00+00:00http://phndiaye.github.io/diving-into-blogging-once-and-for-all<p>Almost a year, i tried to get myself involved in blogging community. It
was not as good as i expected.</p>
<p>When i started, i was not prepared, i did not have any content, i was not
experienced and did not have some kind of minimal knowledge in domains i wanted
to talk about: System administration (mainly on Linux, i’m currently not good at
Windows stuffs) and Python development, because these where the stuffs i loved,
a year ago.</p>
<h2 id="the-trigger">The trigger</h2>
<p>Meanwhile, i have been in an internship at <a href="http://kozea.fr/" title="Kozea">Kozea</a>
which has been a great step in my IT Student life, and more … A great team,
working on great projects. That’s it. It gave me more subjects to
talk about, a better technical backend, and a «think about it, first» attitude,
in that, prior, when i was facing a programming or almost any computer science
problem, i used to rush headlong. No need to say it never worked.</p>
<h2 id="what-have-changed-">What have changed ?</h2>
<p>So, on this 2013 year-end, I come again trying to open a blog. But this time,
it’s different. I have content, a better technical backend, some global
knowledge about most of the current technos, in devevelopment as well as in
Linux ecosystem. And, last but not least, i am not going to set myself some
unachievable goals like «Write 1 post per day, all the year». This time is gone
and, anyway, i am not good enough currently to set myself this type of goal.
Maybe one day.</p>
<h2 id="what-i-will-be-talking-about">What i will be talking about.</h2>
<p>This has nothing definitive. I will be talking about many stuffs, from technical
to personal (at a certain level), or even raging on something. But, it will be,
mainly, some Linux/Unix posts on technos such as Linux Containers, OpenVZ,
Clusters. On the development level, it could be anything about Python language,
Node.js (that i’m discovering), language learning, learning curves, or personal
projects.</p>
<h2 id="the-final-">The Final !</h2>
<p>Last stuff, the langage. It can be weird (or not), but i have better writing
skills in english than in french. Weird in that i have been living in two
African countries with french as official language. Then i started University in
France. All French-speaking countries, but i can’t write technical stuffs in
french. So, i decided to write in english this time. </p>
<p><em>Excuse me by advance if i write something you, native english speaking person,
could laugh for …</em></p>
<p>Thanks ! And see you soon for some cool thoughts.</p>