<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:og="http://ogp.me/ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:schema="http://schema.org/" xmlns:sioc="http://rdfs.org/sioc/ns#" xmlns:sioct="http://rdfs.org/sioc/types#" xmlns:skos="http://www.w3.org/2004/02/skos/core#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" version="2.0" xml:base="https://www.linuxjournal.com/">
  <channel>
    <title>systemd</title>
    <link>https://www.linuxjournal.com/</link>
    <description/>
    <language>en</language>
    
    <item>
  <title>Embracing the Future: The Transition from SysVinit to Systemd in Linux</title>
  <link>https://www.linuxjournal.com/content/embracing-future-transition-sysvinit-systemd-linux</link>
  <description>  &lt;div data-history-node-id="1341145" class="layout layout--onecol"&gt;
    &lt;div class="layout__region layout__region--content"&gt;
      
            &lt;div class="field field--name-field-node-image field--type-image field--label-hidden field--item"&gt;  &lt;img loading="lazy" src="https://www.linuxjournal.com/sites/default/files/nodeimage/story/embracing-the-future-the-transition-from-sysvinit-to-systemd-in-linux.jpg" width="850" height="500" alt="Embracing the Future: The Transition from SysVinit to Systemd in Linux" typeof="foaf:Image" class="img-responsive" /&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-author field--type-ds field--label-hidden field--item"&gt;by &lt;a title="View user profile." href="https://www.linuxjournal.com/users/george-whittaker" lang="" about="https://www.linuxjournal.com/users/george-whittaker" typeof="schema:Person" property="schema:name" datatype="" xml:lang=""&gt;George Whittaker&lt;/a&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"&gt;&lt;h2&gt;Introduction&lt;/h2&gt;

&lt;p&gt;Linux, the powerhouse behind countless servers and desktops worldwide, relies heavily on an initialization (init) system to bootstrap user space and manage system processes after booting. Traditionally, this role was fulfilled by SysVinit, the standard init system derived from the UNIX System V operating system. However, the evolving complexity and needs of modern computing systems have led to the development of systemd, which has increasingly become the default init system for many Linux distributions. This article explores the transition from SysVinit to systemd, discussing the intricacies and implications of this pivotal change.&lt;/p&gt;

&lt;h2&gt;Understanding SysVinit&lt;/h2&gt;

&lt;p&gt;SysVinit was one of the first init systems widely adopted across various UNIX-like operating systems, serving as a de facto standard for many years. It operates by executing scripts located in the &lt;code&gt;/etc/rc.d&lt;/code&gt; directory. These scripts are run sequentially at boot to start various services. Despite its widespread use, SysVinit has several limitations:&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;&lt;strong&gt;Sequential processing:&lt;/strong&gt; SysVinit starts services in a linear order, which can lead to inefficiencies as faster services must wait for slower ones to start.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Lack of dependencies:&lt;/strong&gt; There is no inherent mechanism for handling service dependencies, often resulting in complex and error-prone script-based solutions.&lt;/li&gt;
	&lt;li&gt;&lt;strong&gt;Limited management capabilities:&lt;/strong&gt; SysVinit provides minimal tools for actively managing running services, making dynamic control and supervision challenging.&lt;/li&gt;
&lt;/ul&gt;&lt;p&gt;These limitations prompted the Linux community to look for a more robust and dynamic init system, leading to the development of systemd.&lt;/p&gt;

&lt;h2&gt;Introduction to Systemd&lt;/h2&gt;

&lt;p&gt;Systemd, introduced by Lennart Poettering and Kay Sievers, is a suite of tools providing powerful capabilities to manage system resources and services. It is designed to be backward compatible with SysVinit scripts but also introduces many features that enhance the functionality and performance of the system:&lt;/p&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-link field--type-ds field--label-hidden field--item"&gt;  &lt;a href="https://www.linuxjournal.com/content/embracing-future-transition-sysvinit-systemd-linux" hreflang="en"&gt;Go to Full Article&lt;/a&gt;
&lt;/div&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;

</description>
  <pubDate>Thu, 09 May 2024 16:00:00 +0000</pubDate>
    <dc:creator>George Whittaker</dc:creator>
    <guid isPermaLink="false">1341145 at https://www.linuxjournal.com</guid>
    </item>
<item>
  <title>Systemd Service Hardening</title>
  <link>https://www.linuxjournal.com/content/systemd-service-strengthening</link>
  <description>  &lt;div data-history-node-id="1340835" class="layout layout--onecol"&gt;
    &lt;div class="layout__region layout__region--content"&gt;
      
            &lt;div class="field field--name-field-node-image field--type-image field--label-hidden field--item"&gt;  &lt;img loading="lazy" src="https://www.linuxjournal.com/sites/default/files/nodeimage/story/systemd-service-strengthening.jpg" width="850" height="500" alt="Systemd Service Strengthening" typeof="foaf:Image" class="img-responsive" /&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-author field--type-ds field--label-hidden field--item"&gt;by &lt;a title="View user profile." href="https://www.linuxjournal.com/users/alessio-greggi" lang="" about="https://www.linuxjournal.com/users/alessio-greggi" typeof="schema:Person" property="schema:name" datatype="" xml:lang=""&gt;Alessio Greggi&lt;/a&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"&gt;&lt;h2&gt;Introduction&lt;/h2&gt;

&lt;p&gt;In an age where hacker attacks are a daily occurrence, it is of fundamental importance to minimize the attack surface. Containerization is probably the best way to isolate a service provided for the public, but this is not always possible for several reasons. For example, think of a legacy system application developed on systemd. This could make the most of the capabilities provided by a systemd-based operative system and it could be managed via a systemd unit, or it could automatically pull updates using a systemd timer, and so on.&lt;/p&gt;

&lt;p&gt;For this reason, we are going to explain how to improve the security of a systemd service. But first, we need to step back for a moment. 
With the latest releases systemd has implemented some interesting features relating to security, especially sandboxing.
In this article we are going to show step-by-step how to strengthen services using specific directives, and how to check them with the provided systemd suite.&lt;/p&gt;

&lt;h2&gt;Debugging&lt;/h2&gt;

&lt;p&gt;Systemd provided an interesting tool named &lt;a href="https://www.freedesktop.org/software/systemd/man/systemd-analyze.html"&gt;systemd-analyze&lt;/a&gt;. This command analyzes the security and the sandboxing settings of one or more specified services. The command checks for various security-related service settings, assigning each a numeric "exposure level" value, depending on how important the setting is. It then calculates an overall exposure level for the whole unit through an estimation in the range 0.0…10.0, which tells us how exposed a service is security-wise.&lt;/p&gt;
&lt;img alt="Systemd Analyze" data-entity-type="file" data-entity-uuid="06100b04-3378-4f54-97c4-ebcf3f987ab7" height="471" src="https://www.linuxjournal.com/sites/default/files/u%5Buid%5D/systemd-analyze.jpg" width="558" class="align-center" loading="lazy" /&gt;&lt;p&gt; &lt;/p&gt;

&lt;p&gt;This allows us to check the improvements applied to our systemd service step-by-step.
As you can see, several services are now marked as UNSAFE, this is probably due to the fact that not all of the applications are applying the features provided by systemd.&lt;/p&gt;

&lt;h2&gt;Getting Started&lt;/h2&gt;

&lt;p&gt;Let's start from a basic example. We want to create a systemd unit to start the command &lt;code&gt;python3 -m http.server&lt;/code&gt; as a service:&lt;/p&gt;

&lt;pre&gt;
[Unit]
Description=Simple Http Server
Documentation=https://docs.python.org/3/library/http.server.html

[Service]
Type=simple
ExecStart=/usr/bin/python3 -m http.server
ExecStop=/bin/kill -9 $MAINPID

[Install]
WantedBy=multi-user.target&lt;/pre&gt;

&lt;p&gt;Save the file and place it under the specific systemd directory of yor distribution.&lt;/p&gt;

&lt;p&gt;By checking the security exposure through &lt;code&gt;systemd-analyze security&lt;/code&gt; we get the following result:&lt;/p&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-link field--type-ds field--label-hidden field--item"&gt;  &lt;a href="https://www.linuxjournal.com/content/systemd-service-strengthening" hreflang="en"&gt;Go to Full Article&lt;/a&gt;
&lt;/div&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;

</description>
  <pubDate>Fri, 14 May 2021 16:00:00 +0000</pubDate>
    <dc:creator>Alessio Greggi</dc:creator>
    <guid isPermaLink="false">1340835 at https://www.linuxjournal.com</guid>
    </item>
<item>
  <title>Linux Filesystem Events with inotify</title>
  <link>https://www.linuxjournal.com/content/linux-filesystem-events-inotify</link>
  <description>  &lt;div data-history-node-id="1339561" class="layout layout--onecol"&gt;
    &lt;div class="layout__region layout__region--content"&gt;
      
            &lt;div class="field field--name-node-author field--type-ds field--label-hidden field--item"&gt;by &lt;a title="View user profile." href="https://www.linuxjournal.com/users/charles-fisher" lang="" about="https://www.linuxjournal.com/users/charles-fisher" typeof="schema:Person" property="schema:name" datatype="" xml:lang=""&gt;Charles Fisher&lt;/a&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"&gt;&lt;p&gt;
&lt;cite&gt;Triggering scripts with incron and systemd.&lt;/cite&gt;
&lt;/p&gt;

&lt;p&gt;
It is, at times, important to know when things change in the Linux OS. The uses to
which systems are placed often include high-priority data that must be processed
as soon as it is seen. The conventional method of finding and processing new file
data is to poll for it, usually with cron. This is inefficient, and it can
tax performance unreasonably if too many polling events are forked too often.
&lt;/p&gt;

&lt;p&gt;
Linux has an efficient method for alerting user-space processes to changes
impacting files of interest. The inotify Linux system calls were first discussed
here in &lt;em&gt;Linux Journal&lt;/em&gt; in a &lt;a href="http://www.linuxjournal.com/article/8478"&gt;2005 article by Robert Love&lt;/a&gt;
who primarily addressed
the behavior of the new features from the perspective of C.
&lt;/p&gt;

&lt;p&gt;
However, there also are stable shell-level utilities and new classes of
monitoring dæmons
for registering filesystem watches and reporting events. Linux installations
using systemd also can access basic inotify functionality with path units. The
inotify interface does have limitations—it can't monitor remote,
network-mounted filesystems (that is, NFS); it does not report the userid involved in
the event; it does not work with /proc or other pseudo-filesystems; and mmap()
operations do not trigger it, among other concerns. Even with these limitations,
it is a tremendously useful feature.
&lt;/p&gt;

&lt;p&gt;
This article completes the work begun by
Love and gives everyone who can write a Bourne shell script or set a crontab the
ability to react to filesystem changes.
&lt;/p&gt;

&lt;span class="h3-replacement"&gt;
The inotifywait Utility&lt;/span&gt;

&lt;p&gt;
Working under Oracle Linux 7 (or similar versions of Red Hat/CentOS/Scientific
Linux), the inotify shell tools are not installed by default, but you can load
them with yum:

&lt;/p&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-link field--type-ds field--label-hidden field--item"&gt;  &lt;a href="https://www.linuxjournal.com/content/linux-filesystem-events-inotify" hreflang="und"&gt;Go to Full Article&lt;/a&gt;
&lt;/div&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;

</description>
  <pubDate>Mon, 08 Jan 2018 15:38:34 +0000</pubDate>
    <dc:creator>Charles Fisher</dc:creator>
    <guid isPermaLink="false">1339561 at https://www.linuxjournal.com</guid>
    </item>
<item>
  <title>Initializing and Managing Services in Linux: Past, Present and Future</title>
  <link>https://www.linuxjournal.com/content/initializing-and-managing-services-linux-past-present-and-future</link>
  <description>  &lt;div data-history-node-id="1338725" class="layout layout--onecol"&gt;
    &lt;div class="layout__region layout__region--content"&gt;
      
            &lt;div class="field field--name-node-author field--type-ds field--label-hidden field--item"&gt;by &lt;a title="View user profile." href="https://www.linuxjournal.com/users/jonas-gorauskas" lang="" about="https://www.linuxjournal.com/users/jonas-gorauskas" typeof="schema:Person" property="schema:name" datatype="" xml:lang=""&gt;Jonas Gorauskas&lt;/a&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"&gt;&lt;p&gt;
One of the most crucial pieces of any UNIX-like operating system is the
init dæmon process. In Linux, this process is started by the kernel,
and it's the first userspace process to spawn and the last one to die
during shutdown.
&lt;/p&gt;

&lt;p&gt;
During the history of UNIX and Linux, many init systems have
gained popularity and then faded away. In this article, I focus on the
history of the init system as it relates to Linux, and I talk about the
role of init in a modern Linux system. I also relate some of the history
of the System V Init (SysV) scheme, which was the de facto standard for many
Linux distributions for a long time. Then I cover a couple more
modern approaches to system initialization, such as Upstart and systemd.
Finally, I
pay some attention to how things work in systemd, as this seems to be
the popular choice at the moment for several of the largest distributions.
&lt;/p&gt;


&lt;span class="h3-replacement"&gt;
The Role of Init&lt;/span&gt;

&lt;p&gt;
Init is short for initializer, and it's both a startup manager and a
session manager for Linux and other UNIXes. It's a startup manager,
because it plays a crucial role in the startup of Linux. It's the
process that creates or initializes userspace and, ultimately, all
userspace processes. It also may be considered a session manager,
because it takes care of many aspects of userspace and its processes
once the system is up and running.
&lt;/p&gt;

&lt;p&gt;
The call to start this process is, in fact, hard-coded in the Linux
kernel. Download the latest kernel sources and look for a function
called kernel_init in the file init/main.c. Among the files that the
Linux kernel will try to execute is /sbin/init. If Linux cannot find
one of these processes, it throws a kernel panic and halts.
&lt;/p&gt;

&lt;p&gt;
The kernel gives the init process an ID of 1 or PID 1. All other
userspace processes are forked from init, and therefore, PID 1 claims
ancestral rights to all other userspace processes. PID 1 also
automatically will become the direct parent process of any userspace process
that is orphaned.
&lt;/p&gt;


&lt;span class="h3-replacement"&gt;
A Little Bit of History&lt;/span&gt;

&lt;p&gt;
Now that I have set the stage for the article and given you a very basic
understanding of what init is and does, I'd like to digress into
a little bit of UNIX history.
&lt;/p&gt;

&lt;p&gt;
There has been a lot of diversity in the initialization schemes for
UNIX-like operating systems over time. Two of the most important init
schemes that had a historical impact on how different Linux distributions
do things are the rc scheme used in the 4.4 BSD and the SysV scheme
used in SunOS and Solaris.
&lt;/p&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-link field--type-ds field--label-hidden field--item"&gt;  &lt;a href="https://www.linuxjournal.com/content/initializing-and-managing-services-linux-past-present-and-future" hreflang="und"&gt;Go to Full Article&lt;/a&gt;
&lt;/div&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;

</description>
  <pubDate>Wed, 20 May 2015 18:17:58 +0000</pubDate>
    <dc:creator>Jonas Gorauskas</dc:creator>
    <guid isPermaLink="false">1338725 at https://www.linuxjournal.com</guid>
    </item>
<item>
  <title>Infinite BusyBox with systemd</title>
  <link>https://www.linuxjournal.com/content/infinite-busybox-systemd</link>
  <description>  &lt;div data-history-node-id="1338711" class="layout layout--onecol"&gt;
    &lt;div class="layout__region layout__region--content"&gt;
      
            &lt;div class="field field--name-node-author field--type-ds field--label-hidden field--item"&gt;by &lt;a title="View user profile." href="https://www.linuxjournal.com/users/charles-fisher" lang="" about="https://www.linuxjournal.com/users/charles-fisher" typeof="schema:Person" property="schema:name" datatype="" xml:lang=""&gt;Charles Fisher&lt;/a&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"&gt;&lt;p&gt;Lightweight virtual containers with PID 1.&lt;/p&gt;

&lt;p&gt;
In this article, I demonstrate a method to build one Linux system
within another using the latest utilities within the systemd suite of
management tools. The guest OS container design focuses upon BusyBox and
Dropbear for the userspace system utilities, but I also work through
methods for running more general application software so the containers are
actually useful.
&lt;/p&gt;

&lt;p&gt;
This tutorial was developed on Oracle Linux 7, and it likely will run
unchanged on its common brethren (Red Hat, CentOS, Scientific Linux), and
from here forward, I refer to this platform simply as V7. Slight
changes may be necessary on other systemd platforms (such as SUSE, Debian
or Ubuntu).
Oracle's V7 runs only on the x86_64 platform, so that's this article's
primary focus.
&lt;/p&gt;

&lt;span class="h3-replacement"&gt;
Required Utilities&lt;/span&gt;

&lt;p&gt;
Red Hat saw fit to remove the long-included BusyBox binary from its V7
distribution, but this easily is remedied by downloading the latest binary
directly from the project's Web site. Since the /home filesystem gets a
large amount of space by default when installing V7, let's put it there
for now. Run the commands below as root until indicated otherwise:

&lt;/p&gt;&lt;pre&gt;&lt;code&gt;
cd /home
wget http://busybox.net/downloads/binaries/latest/busybox-x86_64
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;
You also can get a binary copy of the Dropbear SSH server and client from
this location:

&lt;/p&gt;&lt;pre&gt;&lt;code&gt;
wget http://landley.net/aboriginal/downloads/
↪binaries/extras/dropbearmulti-x86_64
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;
For this article, I used the following versions:
&lt;/p&gt;

&lt;ul&gt;&lt;li&gt;
&lt;p&gt;
BusyBox v1.21.1.
&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;
&lt;p&gt;
Dropbear SSH multi-purpose v2014.63.
&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;
These are static binaries that do not link against shared objects—nothing
else is required to run them, and they are ideal for building a new UNIX-ish
environment quickly.
&lt;/p&gt;

&lt;span class="h3-replacement"&gt;
Build a chroot&lt;/span&gt;

&lt;p&gt;
The chroot system call and the associated shell utility allow an
arbitrary subdirectory somewhere on the system to be declared as the root
for all child processes. The commands below populate the "chroot
jail", then lock you in. Note that the call to chroot needs your change to
the SHELL environment variable below, as you don't have bash inside the jail
(and it's likely the default value of $SHELL):

&lt;/p&gt;&lt;/div&gt;
      
            &lt;div class="field field--name-node-link field--type-ds field--label-hidden field--item"&gt;  &lt;a href="https://www.linuxjournal.com/content/infinite-busybox-systemd" hreflang="und"&gt;Go to Full Article&lt;/a&gt;
&lt;/div&gt;
      
    &lt;/div&gt;
  &lt;/div&gt;

</description>
  <pubDate>Tue, 12 May 2015 12:58:35 +0000</pubDate>
    <dc:creator>Charles Fisher</dc:creator>
    <guid isPermaLink="false">1338711 at https://www.linuxjournal.com</guid>
    </item>

  </channel>
</rss>
