• Recent blogs

    How to Set targets in RHEL/CentOS 7?

    How to Set targets in RHEL/CentOS 7?

    Previous versions of RHEL, which were distributed with SysV init , implemented a
    predefined set of runlevels that represented specific modes of operation. These runlevels were numbered from 0 to 6. In RHEL/CentOS 7, the concept of runlevels has been replaced with systemd targets.

    Systemd targets are represented by target units. Target units end with the .target file extension and their only purpose is to group together other systemd units through a chain of dependencies.

    Runlevel Target Units Description
    0 runlevel0.target, poweroff.target Shut down and power off the system.
    1 runlevel1.target, rescue.target Set up a rescue shell.
    2 runlevel2.target, multi-user.target Set up a non-graphical multi-user system.
    3 runlevel3.target, multi-user.target Set up a non-graphical multi-user system.
    4 runlevel4.target, multi-user.target Set up a non-graphical multi-user system.
    5 runlevel5.target, graphical.target Set up a graphical multi-user system.
    6 runlevel6.target, reboot.target          Shut down and reboot the system.

    How to get the Default Target ?
    [root@dockerserver ~]# systemctl get-default
    [root@dockerserver ~]#

    How to List all target ?
    [root@dockerserver ~]# systemctl list-units --type target --all
      UNIT                   LOAD      ACTIVE   SUB    DESCRIPTION
      basic.target           loaded    active   active Basic System
      cryptsetup.target      loaded    active   active Encrypted Volumes
      emergency.target       loaded    inactive dead   Emergency Mode
      final.target           loaded    inactive dead   Final Step
      getty.target           loaded    active   active Login Prompts
      graphical.target       loaded    inactive dead   Graphical Interface
      local-fs-pre.target    loaded    active   active Local File Systems (Pre)
      local-fs.target        loaded    active   active Local File Systems
      multi-user.target      loaded    active   active Multi-User System
      network-online.target  loaded    active   active Network is Online
      network-pre.target     loaded    inactive dead   Network (Pre)
      network.target         loaded    active   active Network
      nss-user-lookup.target loaded    inactive dead   User and Group Name Lookups
      paths.target           loaded    active   active Paths
      remote-fs-pre.target   loaded    inactive dead   Remote File Systems (Pre)
      remote-fs.target       loaded    active   active Remote File Systems
      rescue.target          loaded    inactive dead   Rescue Mode
      shutdown.target        loaded    inactive dead   Shutdown
      slices.target          loaded    active   active Slices
      sockets.target         loaded    active   active Sockets
      sound.target           loaded    active   active Sound Card
      swap.target            loaded    active   active Swap
      sysinit.target         loaded    active   active System Initialization
    ● syslog.target          not-found inactive dead   syslog.target
      time-sync.target       loaded    inactive dead   System Time Synchronized
      timers.target          loaded    active   active Timers
      umount.target          loaded    inactive dead   Unmount All Filesystems

    LOAD   = Reflects whether the unit definition was properly loaded.
    ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
    SUB    = The low-level unit activation state, values depend on unit type.

    27 loaded units listed.

    How to Change Default target?
    Check the Current Runlevel or Target.
    [root@Linux-box yum.repos.d]# systemctl get-default
    Who -r

    Netmeds [CPS] IN
    Set the Default target.
    [root@Linux-box yum.repos.d]# systemctl set-default graphical.target
    Removed symlink /etc/systemd/system/default.target.
    Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/graphical.target.
    [root@Linux-box yum.repos.d]#

    How to change to rescue mode?
    [root@dockerserver ~]# systemctl rescue
    PolicyKit daemon disconnected from the bus.
    We are no longer a registered authentication agent.

    Broadcast message from root@dockerserver.org on pts/0 (Sat 2018-08-18 13:21:51 IST):

    The system is going down to rescue mode NOW!

    [root@dockerserver ~]#
    How to Change current target?
    [root@dockerserver ~]# systemctl isolate graphical.target
    [root@dockerserver ~]#

    How to Change to Emergency Mode ?
    Emergency mode provides the most minimal environment possible and allows you to repair your system even in situations when the system is unable to enter rescue mode.  In RHEL7, emergency mode requires the root password.

    [root@dockerserver ~]# systemctl emergency
    PolicyKit daemon disconnected from the bus.
    We are no longer a registered authentication agent.

    No comments