Thursday, January 21, 2016

Controlling services and DAEMONS::

for the kernel representation of system CPUs

[root@localhost ~]# grep "model name" /proc/cpuinfo
model name      : Pentium(R) Dual-Core  CPU      E5300  @ 2.60GHz



Controlling services and DAEMONS::

daemons are processes that wait or run in the background performing various tasks.

To view the status of a service::

systemctl status name.type

without type it will display the status of a service unit, if one exists
root@localhost ~]# systemctl status sshd.service
● sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2016-01-21 09:47:09 EST; 3h 22min ago
     Docs: man:sshd(8)
           man:sshd_config(5)
 Main PID: 1535 (sshd)
   CGroup: /system.slice/sshd.service
           └─1535 /usr/sbin/sshd -D

Jan 21 09:47:09 localhost.localdomain systemd[1]: Started OpenSSH serve...
Jan 21 09:47:09 localhost.localdomain systemd[1]: Starting OpenSSH serv...
Jan 21 09:47:10 localhost.localdomain sshd[1535]: Server listening on 0...
Jan 21 09:47:10 localhost.localdomain sshd[1535]: Server listening on :...
Jan 21 09:59:42 localhost.localdomain sshd[4268]: Accepted password for...
Jan 21 11:01:34 localhost.localdomain sshd[6101]: Accepted password for...
Jan 21 12:22:57 localhost.localdomain sshd[8134]: Accepted password for...
Hint: Some lines were ellipsized, use -l to show in full.


to query the state of only service units::
systemctl --type=service

 to view if there are any failed or maintainence state::
systemctl status rngd.service -l ( -l option will show the long listing)

 alternate commands to check whether the particular command is active or not...

root@localhost ~]# systemctl is-active sshd( it shows whether its current state is active or not)
active
[root@localhost ~]# systemctl is-enabled sshd (it shows whether it was enabled at boot time or not)
enabled
 
to list all active state of all loaded units::

systemctl list-units --type=service
[root@localhost ~]# systemctl list-units --type=service
  UNIT                      LOAD   ACTIVE SUB     DESCRIPTION
  abrt-ccpp.service         loaded active exited  Install ABRT coredump ho
  abrt-oops.service         loaded active running ABRT kernel log watcher
  abrt-xorg.service         loaded active running ABRT Xorg log watcher
  abrtd.service             loaded active running ABRT Automated Bug Repor
  accounts-daemon.service   loaded active running Accounts Service
  alsa-state.service        loaded active running Manage Sound Card State
  atd.service               loaded active running Job spooling tools
  auditd.service            loaded active running Security Auditing Servic
  avahi-daemon.service      loaded active running Avahi mDNS/DNS-SD Stack
  blk-availability.service  loaded active exited  Availability of block de
  bluetooth.service         loaded active running Bluetooth service

if -all option is used (systemctl list-units --type=service --all) it even displays inactive units
 
TO list all socket units active or inactive in the system::
systemctl list-units --type=socket --all


To display if sshd is active without displaying all other status information::
systemctl is-active sshd
[root@localhost ~]# systemctl is-enabled sshd
enabled

Now if we have to display even other status information::
systemctl status sshd

 List the enabled and disabled states of all service units::
systemctl list-units --type=service --all
Unit dependcies::
services may have depencies on one another. For example if we have to stop printing services , we have to stop 
all three units related to that very unit that may be from other units

 masking services::
 if there are conflicting services installed and we dont want to open up tha conflicted service accidently we have to mask that 
service to /dev/null.
systemctl mask network
[root@localhost ~]# systemctl mask network
Created symlink from /etc/systemd/system/network.service to /dev/null.

Now the service cannot be opened manually as well as automatically



restarting a service will change its process id..
but reloading wont change any process id and no connections are interrupted

enabling any service will make it ready to start at system boot

No comments:

Post a Comment