Use systemd and Oracle Linux (2023)


  • This tutorial is available in aFree lab environment provided by Oracle.
  • It uses example values ​​for Oracle Cloud Infrastructure credentials, tenancy, and compartments. When completing your lab, replace these values ​​with values ​​specific to your cloud environment.


In this tutorial, you will learn how to use thesystemctlCommand line utility to manage and view systemd units that are controlled by systemd. This tutorial is intended for users of Oracle Linux 8 or later.

systemd is the first process to start at boot and is the final process to end at shutdown. systemd is mainly used to manage system services or processes and to start the system at startup. However, systemd is also capable of handling many other tasks and functions, including event logging, device management, user login, task scheduling, time synchronization, and system initialization. Many systemd features are not fully utilized, as users may be more comfortable with alternative software for these purposes, or different Linux distributions may have preferred approaches to system configuration.

The different types of behavior or functions within systemd are handled in systemd units. For example, daemon processes or system services run as service units, while system states are often defined as target units. Timer units can be configured to schedule tasks in the same way that you can use the system cron service, and a mount unit can be used to configure a mount point in the same way that you can configure a mount point. in the system fstab.

systemd is used to manage system-level processes and functions, but is also capable of managing processes running in user space. Users of a system can configure and manage their own services, and systemd can even be configured to allow these services to continue running after the user logs off.


  • Discover different types of systemd units
  • Use systemd target units
  • learn commonsystemctlcommand syntax
  • Create your own systemd timer unit in user space
  • Configure systemd to allow userland processes to run after logoff

What do you need?

  • A system with Oracle Linux 8 installed.

Observation:When using the free lab environment, seeOracle Linux Lab Basicsfor connection and other instructions for use.

Browse the systemd unit files

After connecting to the Oracle Linux 8 instance, you can begin to experience thesystemctlcommand to know the different units available.

  1. run orsystemctlcommand to list all systemd units currently loaded by systemd:


    Use the Space or Page Down keys on your keyboard to scroll through the output.

    This command is equivalent to running:

    systemctl unit-list

    The output shows all currently active configuration units that systemd is managing. In the output, you should notice that there are drives named with different suffixes, including drives named with the suffixes '.device', '.mount', '.service', '.target', and '.timer'.

    Drives are active in the sense that they start, run, mount, or connect, depending on their purpose. Drives can be idle in the sense that they are stopped, unmounted, or offline. If you want to see all drives regardless of whether they are active or not, you can run:

    systemctl unit-list--all

    The output of these commands shows a selection of the different types of systemd units:

    • auto mount- Provides automount capabilities for on-demand mounting of file systems and parallel boot.
    • Mount: Controls mount points in the current date and time displays of the file system.
    • camino: You can enable services when the file system path information changes.
    • attain: Similar to service units, but manages foreign processes instead of starting them.
    • Service: Starts and controls daemons and their component processes.
    • cut in slices: Used to group units that manage system processes, such as service units and scope units, in the cgroup hierarchical tree for resource management purposes.
    • Plug: Encapsulates local interprocess communication (IPC) or network sockets on the system, which are useful for socket-based triggering.
    • objective: Used to group drives or to provide known synchronization points during boot.
    • chronograph: Used to trigger the activation of other units by timers. They provide an alternative to tasks that may have been previously managed by the cron service.
    • device: exposes kernel devices to systemd and can also be used to implement device-based activation.
    • exchange: Encapsulates memory swap partitions or swap files.
  2. Restrict the list of drives to a specific type of drive using the--modeloption.

    • use thesystemctl unit-list --services typecommand to list the currently active service units on your system.

      systemctl unit-list--modelService
    • Run the same command again, but include the--alloption to view all loaded drives, including idle ones, if any.

      systemctl unit-list--modelService--all

You can repeat these commands for each of the available service types to limit the information to the type you are interested in working with at any given time.

Working with systemd target units

Target drives are used to group different drives together to bring the system to a specific state so that it is ready to work for a specific purpose.

  1. available listobjectiveunits.

    systemctl unit-list--modelobjective

    Units may require other units to be loaded or may be set to conflict with specific units. For example, himmultiuser.targetrequires theobjective.basicto function and also conflicts with therescue serviceIt's inrescue.targetunits. Units also specify other units that they want to carry in order to function.

    In this way, targets can be chained to set a specific state, but are also modular enough to be reused to trigger an alternate state.

  2. View the default destination drive.

    The default target drive defines the default state of the system after boot.

    • use thesystemctl get-defaultCommand to see which destination drive is used by default. The default target unit is represented by the/etc/systemd/system/default.objetivoOffice hour.

      systemctl get-default
    • use thels-lCommand to list information about the/etc/systemd/system/default.objetivoOffice hour.

      ls -UE/etc/systemd/system/default.objetivo
      (Video) systemd System and Service Manager on Oracle Linux 8

      Observation:ostandard.targetThe file is a symbolic link to the current default destination drive file.

  3. Change the default destination drive.

    • use thesystemctl set defaultcommand to change the default destination drive to thetarget.chartUnit.

      systemctl set-default graphic.objetivo
    • use thels-lcommand to confirm that thestandard.targetis now a symlink to thetarget.chartOffice hour.

      ls -UE/etc/systemd/system/default.objetivo

      Observation:Changing the default destination drive deletes the existing one.standard.targetsymlink and recreates the symlink, pointing to the new default destination drive.

  4. Explore a target to learn more.

    • use themostrar systemctlcommand to get more information about any specific target.

      systemctl show

      The output shows all the parameters for the specified target. Note that you can identify the units the target requires, wants, and conflicts with, and you can also see which units that target should execute before and after.

    • use thesystemctl dependency-listCommand to display the tree of dependencies that are needed or wanted for a given goal to reach its state:

      systemctl dependency-list

      This command lists all drives that are booted when the default target boots. The unit string is laid out recursively in a tree that allows you to fully assess what the goal accomplishes when it starts. If you set thetarget.chartas the default destination, you can see that the system wants to run thedisplay-manager.serviceto load the graphical display, but it also runs themultiuser.targetto do whatever is necessary before running the graphical screen.

Using systemctl to enable, disable, and mask drives

Units can be disabled or enabled and can also be masked so they never work under any circumstances. Some units are static because they are always available, usually because they are dependencies for other units to work. EITHERsystemctl unit-listThe command can only be used to display drives that are active or inactive in the system.

  1. List all available drives on the system, along with their status:

    systemctl list unit files

    Many of the units available are static. Enabled drives start at boot time. Disabled drives are drives that are available on the system but are not configured to start at boot. Masked drives are available on the system, but have been actively set to an unbootable state.

  2. use thestatus systemCommand to view detailed information about thenfs-server.serviceUnit.

    systemctl status nfs-server.service

    osystemctlcommand allows you to drop the.Serviceextension when referring to service units.

    The status command indicates whether a drive is enabled, active, inactive, disabled, or masked.

    For hyphenated solutions,systemctlprovides short commands to display status on a single line:

    • use thesystemctl is activeCommand to check if theservidor nfsthe service is running (active) or not running (inactive).

      systemctl is-server nfs-active
    • use thesystemctl is enabledCommand to check if theservidor nfsthe service is enabled or disabled. With the service enabled, the service starts on a system reboot.

      systemctl is enabled nfs server
  3. Enable a service to start at startup.

    use thesystemactl activatecommand to enableservidor nfsService.

    sudosystemctlto allow --nowservidor nfs
    (Video) systemd Target Units on Oracle Linux 8

    You must execute thesystemctlcommand with administrator privileges if the command changes the state or configuration of the system. you can use the--nowoption to additionally start the service at the same time you enable it.

    Observation:The command starts the service by creating a symbolic link to the lowest level system state target where the service starts. In the output, the command created the symbolic linknfs-server.servicefor himmulti userobjective.

    use thesystemctl status commandto confirm theservidor nfsthe service is already up and running.

    systemctl status nfs-server
  4. Disable and stop a service.

    use theDesactivar systemctlcommand to disableservidor nfsService. Also note that theDesactivar systemctlThe command removes the systemctl binding to the service.

    sudosystemctl disable nfs server

    use thedetener systemctlcommand to stop theservidor nfsService.

    sudosystemctl stop nfs server

    You can combine these steps using the--nowoption when you disable the service.

  5. Mask and unmask a unit.

    In some cases, you may want to disable drive initialization. You can usually do this if a particular drive conflicts with some other system functionality or for policy reasons.

    use thesystemctl maskCommand to mask theservidor nfsService:

    sudosystemctl mask nfs-server

    A symbolic link is created to ensure that the systemd unit configuration points to /dev/null. This prevents the service from being enabled or started.

    Confirm that you cannot start the nfs server drive while it is masked:

    sudosystemctl iniciar servidor nfs

    The service fails to start and an error is returned to indicate that the service is masked.

    Unmask the drive to return it to its original state and allow users to start or enable the service.

    sudosystemctl desenmascarar servidor nfs

Configuring systemd for user space units

In general, systemd is used to manage drives at the system level. Users need administrator-level access to the system to manage systemd units configured in this way. In some environments and for some types of drives, users may want to use systemd's ability to run drives within user space. For example, users may want to schedule tasks using systemd's timer unit functions; or users may want to run specific applications or services as service units that should not require root level permission to run.

systemd starts a systemd-user process for a user at login. Drives located in the following directories are processed in the following order for the user:

  • /usr/lib/systemd/user/: userspace units provided by installed packages
  • $HOME/.local/share/systemd/usuario/: user space drives of packages installed in the home directory
  • /etc/systemd/usuario/: system-wide global user drives that should run in user space for all users
  • $INICIO/.config/systemd/usuario/: user created units

You can tell systemd that you are working in user space by using the--From the useroption to any systemd command.

  1. List the drive files currently available to your user.

    systemctl--From the userlist drive files

    Note that the list of available drives is significantly smaller than when you issued the same command without the--From the useroption.

    Most of these drive files, on a new system, are located in/usr/lib/systemd/user🇧🇷 List the files in this directory to see the drives located here:

    ls -a/usr/lib/systemd/user/
  2. Create a directory to house your own systemd unit files.

    mkdir -p $HOUSEHOLD/.config/systemd/usuario
  3. Create your own systemd service unit.

    (Video) [LINUX systemd] How to automate startup shutdown Oracle Database on Linux

    cat << EOF > $HOME/.config/systemd/user/uptime.service[Unit]Description="Log or system uptime and a load medium"Wants=uptime.timer[Service]ExecStart=/usr/ bin /uptime[Install] WantedBy=default.targetEOF

    This service unit provides three configuration sections.

    oUnitThe section provides a description of the unit and the requirements. In this case, oneWould you like itThe entry defines a weak requirement for a timer unit that does not yet exist. Units listed asWould you like itentries are executed if they are available, but do not prevent execution of the main drive if they are not found or are not executed.

    oServiceThe section defines the behavior of that particular service unit when it is executed. We rely on many default values ​​for the options available here, and only specify theExecStartline, which specifies the command to run when the service starts. In this case, theactivity timeThe command is executed to record system uptime and load values.

    oinstall on pcThe section defines how the service should be installed on the system when activated. In particular, the service is added as a service that iswanted forthe 'target.default'. This would mean that the service is enabled as part of the default target for that user.

  4. Run the systemd unit and check its output.

    Since you added a new unit, it's generally a good idea to reload the systemd configuration before trying to run the service:

    systemctl--From the userdaemon-reload

    Now start the new drive.

    systemctl--From the userto startactivity time

    Verify that the command ran as expected. You can verify that the service has run by checking its status:

    systemctl--From the userstateactivity time

    Observation:These commands use the--From the useroption to run inside user space.

    To check the output ofactivity timecommand that was executed, use thedailyctlcommand to view the log and specify the tag option to view specific logs for the command:

    dailyctl-t activity time

    You can enable this service to start when the user first logs into the system.

    systemctl--From the user enable uptime

    Note that the service runs when the user logs into the system for the first time. It does not start automatically at system startup. Typically, services running in user space end after the user logs off or all user sessions end. Enabling persistence for human services is covered later in this tutorial.

Working with systemd timer units

This exercise builds on the previous exercise to create and enable a timer unit to regularly run another systemd unit at a given time or interval. Timer units can be defined at both the system and user level and can be used to define when systemd should execute another unit. Timer units provide granular control over scheduled events and can act as an alternative to using the cron daemon to handle more subtle configurations.

Many system services include timer units to track when they run. A great example of a timer unit is included indnf-autopackage that can be used to keep your system up-to-date by running regular dnf updates automatically. To see this in action at the system level, install the package and enable the timer unit:

sudodnfinstall on pc -ydnf-autosudosystemctlto allowdnf-automatic.timer

You can view the unit file to see how this unit is configured:


Notable content in this unit includes aWould you like itline waiting for therede-online.goalbe served thein the calendarno entrychronographThe configuration section suggests that this action be performed daily at 06:00 am. It is also of interest toRandomizedDelaySecinput, which can help prevent all the timer units from turning on at exactly the same time and suddenly increasing the load on the system.

The example provided here is part of a much more complex set of units. To better understand how timer units work, add a timer unit in user space to schedule theuptime.servicethat you created in the previous exercise to run at regular intervals.

  1. Create a timer unit file.

    cat <<EOF > $HOME/.config/systemd/user/uptime.timer[Unit]Description=Timer para el servicio de uptime que registra uptimeRequires=uptime.service[Timer]Unit=uptime.serviceOnCalendar=*-*-* * :*:00[Instalar]

    This file specifies that theuptime.serviceThis timer unit is required to work. This is a much stronger requirement than anything defined in aWould you like itdefinition and the unit does not work if the requirement is not met.

    ochronographsection defines what theuptime.serviceunit using ain the calendarForbidden. EITHERin the calendarEntry works similar to options in a crontab definition, but provides more granularity. In this case, the unit is set to run every minute at 00 seconds.

  2. Since you modified the systemd configuration, reload the systemd daemons and restart the uptime service so that it can pick up the new timer unit:

    systemctl--From the userdaemon-reloadsystemctl--From the userrestartactivity time
    (Video) Minecraft Server - Autostart using systemd - Linux Beginner Friendly
  3. List the units to verify thatuptime.servicemiuptime.timerthe units are working.

    systemctl--From the userenumerate units
  4. Monitor the journal output to see the uptime output triggered by the uptime service that runs every minute.

    dailyctl-F -t activity time

    After a few minutes, several starting lines should have appeared. If you're paying attention, you may notice that the uptime command doesn't always fire exactly to the minute. This is an intentional feature within the systemd timer functionality. Timer jobs are activated with a randomizer that can allow a task to be activated up to one minute late. This helps prevent all the timers from going off at exactly the same time. You can force a timer to be incredibly precise by setting the scheduled event to nanosecond precision by adding the following configuration entry to the timer unitchronographsection:


    However, for most tasks, it is sensible to allow a certain degree of inaccuracy to prevent tasks from running too synchronously.

    You can use the Ctrl-C key combination to exit the journal when you are done monitoring.

Configure userland processes to continue after logout

By default, services and processes started and owned by a user end when the user logs off or when all user sessions end. There are several methods you can use to change this default behavior in systemd. Two options are explored here.

Use the loginctl command to enable systemd persistent users

olog inThe command can be used to change the default behavior of a specific user and to allow that user's processes to "linger" after the user's session ends.

  1. use thelog inutility to enable persistence for a specific user. In this case, enable systemd's persistence behavior for user 'oracle':

    sudologinctl enable-linger oracle
  2. To verify that the settings have been applied, check if a file with the same name as the user exists in the/var/lib/systemd/persistentesdirectory.


    The command should check if the file exists.

Edit the systemd logind.conf file

Systemd manages user login events and provides a configuration file that can be edited to define default behavior for different user session related events. This configuration file is located at/etc/systemd/logind.conf.

  1. Dump the content of the existing configuration in/etc/systemd/logind.confto the screen to review:


    Most of the options are commented out, but show the default compile-time values. There are three options in this file that can control how systemd handles processes running in user space when the user is logged off.

    • KillUserProcesses: This option can control whether or not user processes are terminated by default when the session ends. Setting this option to 'no' allows systemd to run user processes after any user logs off the system.
    • KillExcludeUsers: Se oKillUserProcessesWhen enabled, this option allows you to specify a space-separated list of users for whom systemd allows processes to continue running after session termination. Adding a username to this list behaves similarly to adding a user to systemd's persistence group using thelog indomain.
    • KillOnlyUsers: Se oKillUserProcessesis disabled, this parameter can be used to specify a space-separated list of users for whom processes should end on logoff.

video demo

Video demos on systemd are provided at you need more information on working with systemd on Oracle Linux 8.

Systemd sysadmin and services without Oracle Linux 8

systemd target units en Oracle Linux 8

More information

  • System documentation:
  • systemad(1)man page
  • sistemactl(1)man page
  • dailyctl(1)man page
  • systemd.unit(5)man page
  • logind.conf(5)man page
  • Oracle Linux 8: Central System Configuration Administration
  • Oracle Linux documentation

More learning resources

Explore other labs access more free learning content atOracle Learning Channel without YouTube🇧🇷 Also, become an Oracle Learning Explorer.

For product documentation, visitAjuda da Oracle Headquarters.

Title and copyright information


Does Oracle Linux use systemd? ›

This tutorial is targeted at users of Oracle Linux 8 or later. systemd is the first process that starts at boot and is the final process to terminate at system shutdown. systemd is primarily used to manage system services or processes and system initialization at boot.

How to connect to Oracle database from Linux server? ›

Connect to Oracle Database Server using SQL*Plus
  1. sqlplus. ...
  2. Enter user-name: sys as sysdba Enter password: ...
  3. SQL>_ ...
  4. SQL> SHOW con_name; CON_NAME ------------------------------ CDB$ROOT. ...
  6. SQL> EXIT. ...
  7. >sqlplus OT@PDBORCL.

What Linux uses systemd? ›

In May 2011 Fedora Linux became the first major Linux distribution to enable systemd by default, replacing Upstart. The reasoning at the time was that systemd provided extensive parallelization during startup, better management of processes and overall a saner, dependency-based approach to control of the system.

What's the problem with systemd? ›

The binary logging is a criticism a lot of people have, it provides faster indexing but binary logs are more easily corrupted and that's in general what people dislike. Log corruption has been witnessed more than once in the wild with systemd.”

Can Linux run without systemd? ›

Alpine Linux is yet another independent Linux distribution without systemd. When it comes to init system, it uses OpenRC. The distribution focuses on security and resource efficiency. So, if you were looking for a simple systemd-free distro with a focus on security, Alpine Linux can be a good choice.

Which Linux does not use systemd? ›

Pages in category "Linux distributions without systemd"
  • Absolute Linux.
  • Alpine Linux.
  • Android (operating system)
  • Android-x86.
  • AntiX.
  • ArchBang.
  • Artix Linux.
  • Austrumi Linux.

Which Linux is best for Oracle Database? ›

Oracle Linux includes the Unbreakable Enterprise Kernel (UEK), which is specifically optimized for the best performance of Oracle software.

Is Oracle Linux same as RHEL? ›

Oracle Linux and Red Hat Enterprise Linux (RHEL) are both distributions of the Linux open-source operating system. Oracle Linux is a free distribution used mainly by small to mid level outfits with existing Oracle databases, while RHEL is favored by enterprise-level businesses that prioritize stability and uptime.

How to connect to Oracle database from Unix server? ›

Starting SQL*Plus Command-line
  1. Open a UNIX or a Windows terminal and enter the SQL*Plus command: sqlplus.
  2. When prompted, enter your Oracle Database username and password. ...
  3. Alternatively, enter the SQL*Plus command in the form: sqlplus username. ...
  4. SQL*Plus starts and connects to the default database.

Do all Linux distros use systemd? ›

Linux has many distros, and as per their design constraints they are forced to use either SystemV or SystemD. Debian, Fedora, CentOS, Red Hat, Ubuntu, OpenSUSE, Arch, and Amazon Linux use SystemD, while Slackware and Gentoo use System V.

Is systemd better than init? ›

Conclusion. Init and Systemd are both init daemons but it is better to use the latter since it is commonly used in recent Linux Distros. Init uses service whereas Systemd uses systemctl to manage Linux services.

What can replace systemd? ›

There are more than 10 alternatives to systemd for a variety of platforms, including Linux, BSD, Mac, Windows and Self-Hosted solutions. The best alternative is GRUB, which is both free and Open Source. Other great apps like systemd are MSConfig, OpenRC, runit and s6.

How much RAM does systemd use? ›

In the top example below, during normal web serving without other processes running, systemd, systemd-logind, systemd-journal, and dbus-daemon use a combined total 10.7% of a quad-core CPU, and systemd is consuming 19% of the system's 16GB of RAM.

Is systemd better than GRUB? ›

Conclusion: Is Grub or Systemd-boot better? If you have problems with Grub, systemd-boot provides a dramatically simplified boot infrastructure with drop-in file configuration. It's more robust, but it's also not nearly as configurable or adaptable as Grub.

Is systemd run as root? ›

System services are the "default" kind of service, and the service you set up is probably one of these. Their service files are linked in /etc/systemd/system/ . They run as root by default.

Is systemd same as init? ›

Systemd is the new init framework, beginning with Fedora and presently embraced in numerous circulations like RedHat, Suse, and Centos.

Is systemd the same as Systemctl? ›

systemctl is the systemd command for controlling how services start on a Linux system. A service can be enabled, disabled, or masked, and it can be configured to start at boot, on demand, manually, or prevented from starting under any circumstances.

What is the benefit of systemd? ›

systemd provides a number of benefits. It is a single daemon that performs complete process management, from startup to shutdown. It speeds up boot times by parallelizing service starts. It conserves system resources by starting services on demand, and puts them to sleep when there is no demand.

Does Redhat use systemd? ›

The reality is that many distributions, Red Hat Enterprise Linux (RHEL) included, have begun managing services with systemd .

How do I know if my system uses systemd? ›

Checking the init system in Linux

The /sbin/init is a symbolic link to the actual init process. You can follow the symbolic link and see real process. I am using the stat command and you can see that /sbin/init is linked to /lib/systemd/systemd in Ubuntu. This is an indication that systemd is in use.

Does Redhat 7 use systemd? ›

System startup: The systemd process is the first process ID (PID 1) to run on RHEL 7 system. It initializes the system and launches all the services that were once started by the traditional init process.

What Linux does Oracle use? ›

Oracle Linux is an optimized and secure operating environment for application development and deployment. Oracle Linux 9 with UEK R7 provides kernel, performance, and security enhancements.

What Linux is Oracle Linux based on? ›

It is based on the mainline Linux kernel version 5.15.

Is systemd part of Linux? ›

Systemd is a system that is designed specifically for the Linux kernel. It replaces the sysvinit process to become the first process with PID = 1, which gets executed in user space during the Linux start-up process.


1. Use chroot on Oracle Linux 8
(Oracle Learning)
2. System Logging with journald using journalctl on Oracle Linux 8
(Oracle Learning)
3. Oracle Linux 7 Control Groups (11-13)
4. How To Autostart Programs On Linux
5. systemd on Linux 3: Targets
6. Introducing Udev on Oracle Linux
(Oracle Learning)


Top Articles
Latest Posts
Article information

Author: Lilliana Bartoletti

Last Updated: 09/28/2023

Views: 6791

Rating: 4.2 / 5 (53 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Lilliana Bartoletti

Birthday: 1999-11-18

Address: 58866 Tricia Spurs, North Melvinberg, HI 91346-3774

Phone: +50616620367928

Job: Real-Estate Liaison

Hobby: Graffiti, Astronomy, Handball, Magic, Origami, Fashion, Foreign language learning

Introduction: My name is Lilliana Bartoletti, I am a adventurous, pleasant, shiny, beautiful, handsome, zealous, tasty person who loves writing and wants to share my knowledge and understanding with you.