Dealing with services in RHEL 7 (Part -3)

Where is init in RHEL 7 ?

Concept of init has been replaced with targets in RHEL 7. We can see below directory all the runlevel are soft link to targets. Purpose of targets is to group together systemd units through chain of dependencies.

[root@localhost system]# cd /usr/lib/systemd/system
[root@localhost system]# ll | grep runlevel
lrwxrwxrwx. 1 root root 15 May 27 14:43 runlevel0.target -> poweroff.target
lrwxrwxrwx. 1 root root 13 May 27 14:43 runlevel1.target -> rescue.target
drwxr-xr-x. 2 root root 49 May 27 14:43 runlevel1.target.wants
lrwxrwxrwx. 1 root root 17 May 27 14:43 runlevel2.target -> multi-user.target
drwxr-xr-x. 2 root root 49 May 27 14:43 runlevel2.target.wants
lrwxrwxrwx. 1 root root 17 May 27 14:43 runlevel3.target -> multi-user.target
drwxr-xr-x. 2 root root 49 May 27 14:43 runlevel3.target.wants
lrwxrwxrwx. 1 root root 17 May 27 14:43 runlevel4.target -> multi-user.target
drwxr-xr-x. 2 root root 49 May 27 14:43 runlevel4.target.wants
lrwxrwxrwx. 1 root root 16 May 27 14:43 runlevel5.target -> graphical.target
drwxr-xr-x. 2 root root 49 May 27 14:43 runlevel5.target.wants
lrwxrwxrwx. 1 root root 13 May 27 14:43 runlevel6.target -> reboot.target
-rw-r–r–. 1 root root 761 Nov 20 2013 systemd-update-utmp-runlevel.service

Now if we want to poweroff or shutdown the system redhat recommend to use the systemctl command

If we want to check the default run level or now in RHEL 7 I can say the target. We can issue the below command. This will get the output from file /etc/systemd/system/default.target

[root@localhost system]# systemctl get-default
graphical.target

If we want to change the current level of system we can use the below command which will take from GUI mode to CLI mode in other words from runlevel 5 to runlevel 3.

[root@localhost system]# systemctl isolate multi-user.target
[root@localhost system]# who -br
system boot 2014-06-03 16:18
run-level 3 2014-06-03 18:46 last=5

Coming back again to runlevel 5.

[root@localhost system]# systemctl isolate graphical.target
[root@localhost system]# who -br
system boot 2014-06-03 16:18
run-level 5 2014-06-03 19:10 last=3

We can go to resuce mode by issuing “systemctl rescue”.

Below is the command see the currently loaded targets on system.

[root@localhost system]# systemctl list-units –type target
UNIT LOAD ACTIVE SUB DESCRIPTION
basic.target loaded active active Basic System
cryptsetup.target loaded active active Encrypted Volumes
getty.target loaded active active Login Prompts
graphical.target loaded active active Graphical Interface

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s