Boot Kernel Command Line

On boot systemd activates (by default), the target unit default.target whose job is to activate services and other units by pulling them in via dependencies.

To override the unit to activate, systemd parses its own kernel command line arguments via the systemd.unit= command line option. This may be used to temporarily boot into a different boot unit. The classical run-levels are replaced as following:

systemd.unit=rescue.target is a special target unit for setting up the base system and a rescue shell (similar to run level 1); systemd.unit=emergency.target, is very similar to passing init=/bin/sh but with the option to boot the full system from there; systemd.unit=multi-user.target for setting up a non-graphical multi-user system; systemd.unit=graphical.target for setting up a graphical login screen.

For details about these special systemd boot units, view the man systemd.special page.

What is the status of systemd in Fedora?

Fedora 14 featured it is a technology preview. It is the default in Fedora 15 and has replaced Upstart.

Has all legacy System V init files been converted to systemd service files or equivalent?

What is the tool to manage services with systemd?

systemctl is the primary tool to use. It combines the functionality of both service and chkconfig into a single tool that you can use for instance to enable/disable services permanently or only for the current session.

list all running services etc:

systemctl

Refer to man systemctl for more details. systemd-cgls lists the running process in a tree format. It can recursively show the content of any given control group. Refer to man systemd-cgls for more details.

How do I start/stop or enable/disable services?

Activates a service immediately:

systemctl start foo.service

Deactivates a service immediately:

systemctl stop foo.service

Restarts a service:

systemctl restart foo.service

Shows status of a service including whether it is running or not:

systemctl status foo.service

Enables a service to be started on bootup:

systemctl enable foo.service

Disables a service to not start during bootup:

systemctl disable foo.service

Check whether a service is already enabled or not:

systemctl is-enabled foo.service; echo $?

0 indicates that it is enabled. 1 indicates that it is disabled

Refer to man systemctl for more details.

How do I change the runlevel?

systemd has the concept of targets which is a more flexible replacement for runlevels in sysvinit.

Run level 3 is emulated by multi-user.target. Run level 5 is emulated by graphical.target. runlevel3.target is a symbolic link to multi-user.target and runlevel5.target is a symbolic link to graphical.target.

How do I know the current run level?

runlevel command still works with systemd. You can continue using that however runlevels is a legacy concept in systemd and is emulated via 'targets' and multiple targets can be active at the same time. So the equivalent in systemd terms is

systemctl list-units --type=target

How to power off the machine ?

You can use

poweroff

Some more possibilities are: halt -p, init 0, shutdown -P now

Note that halt used to work the same as poweroff in previous Fedora releases, but systemd distinguishes between the two, so halt without parameters now does exactly what it says - it merely stops the system without turning it off.

Does service command work with systemd?

Yes. It has been modified to call systemctl automatically when dealing with systemd service files. So either of the following commands does the same thing

service NetworkManager stop

(or)

systemctl stop NetworkManager.service

Does chkconfig command work with systemd?

Yes, for turning on/off services, compatibility has been provided both ways. chkconfig has been modified to call systemctl when dealing with systemd service files. Also systemctl automatically calls chkconfig when dealing with a traditional sysv init file.

Note that if you exit tty8 session, you wont be able to use it until next reboot or manual start by systemctl, except if you leave Restart as ‘always’, but I highly recommend to avoid this according to security reasons.

How do I customize a unit file/ add a custom unit file?

The unit files in /etc/systemd/system have a higher precedence over unit files in /lib/systemd/system. Copy them from the latter to the former and customize it as per your requirements.

If a line starts with .include followed by a file name, the specified file will be parsed at this point. Make sure that the file that is included has the appropiate section headers before any directives.

You should use .include statement instead of copying the whole unit file from /lib/systemd/system to /etc/systemd/system if possible. This will enable to update the unchanged directives correctly during future package updates.

Be careful when using .include together with directives that can be defined multiple times (like EnvironmentFile=), since we can only add new directives, but we can't remove already defined ones. We have to copy the whole file from /lib/systemd/system to /etc/systemd/system in this case.

Let's say we use a lighttpd server and we want to lower its niceness value. All we need to do is to add Nice=-5 to the lighttpd.service file. We can do this by either copying the whole file from /lib/systemd/system/lighttpd.service to /etc/systemd/system/lighttpd.service or creating the following file in /etc/systemd/system/lighttpd.service:

When modifying an unit that has an symlink pointing to that unit for example like the display-manager.service -> prefdm.service does, the symlink should be copied instead of the actual unit as in display-manager.service should be copied to the /etc/systemd/system directory or a new unit created with .includes that bears that name .