From IT Mission Linux Tips, Hacks, Tutorials, Howtos - Itmission.org

Main: Systemctl-Control-the-systemd-system-and-service-manager


systemctl - Control the systemd system and service manager

Finding openssh-server install files on fedora - 17

[fedora@localhost system]$ rpm -ql openssh-server-5.9p1-22.fc17.i686
/etc/pam.d/sshd
/etc/ssh/sshd_config
/etc/sysconfig/sshd
/usr/lib/fipscheck/sshd.hmac
/usr/lib/systemd/system/sshd.service
/usr/libexec/openssh/sftp-server
/usr/sbin/sshd
/usr/sbin/sshd-keygen
/usr/share/man/man5/moduli.5.gz
/usr/share/man/man5/sshd_config.5.gz
/usr/share/man/man8/sftp-server.8.gz
/usr/share/man/man8/sshd.8.gz
/var/empty/sshd



Another Example:

[fedora@fedora system]$ pwd
/usr/lib/systemd/system

[fedora@fedora system]$ ls -l mysqld.service 
-rw-r--r--. 1 root root 1408 Aug  6 12:02 mysqld.service
[fedora@fedora system]$ 



Enabling sshd.service

[fedora@localhost system]$ sudo systemctl enable sshd.service
ln -s '/usr/lib/systemd/system/sshd.service' '/etc/systemd/system/multi-user.target.wants/sshd.service'
[fedora@localhost system]$ sudo systemctl status sshd.service
sshd.service - OpenSSH server daemon
	  Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled)
	  Active: inactive (dead)
	  CGroup: name=systemd:/system/sshd.service

Starting sshd.service

[fedora@localhost system]$ sudo systemctl start sshd.service

Checking Status for sshd.service


[fedora@localhost system]$ sudo systemctl status sshd.service
sshd.service - OpenSSH server daemon
	  Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled)
	  Active: active (running) since Wed, 15 Aug 2012 21:55:35 +0530; 3s ago
	 Process: 3544 ExecStartPre=/usr/sbin/sshd-keygen (code=exited, status=0/SUCCESS)
	Main PID: 3548 (sshd)
	  CGroup: name=systemd:/system/sshd.service
		  └ 3548 /usr/sbin/sshd -D

Aug 15 21:55:35 localhost.localdomain sshd[3548]: Server listening on 0.0.0.0 port 22.
Aug 15 21:55:35 localhost.localdomain sshd[3548]: Server listening on :: port 22.
[fedora@localhost system]$ pgrep ssh
3548
[fedora@localhost system]$ 

Verification using netstat

[fedora@localhost system]$ sudo netstat -nlp |grep 22
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      3548/sshd           
tcp6       0      0 :::22                   :::*                    LISTEN      3548/sshd           
[fedora@localhost system]$

/usr/lib/systemd/system


[root@fedora system]# pwd
/usr/lib/systemd/system
[root@fedora system]# ll |grep httpd
-rw-r--r--. 1 root root  450 Apr 30 15:22 httpd-event.service
-rw-r--r--. 1 root root  434 Apr 30 15:22 httpd.service
-rw-r--r--. 1 root root  454 Apr 30 15:22 httpd-worker.service

[root@fedora system]# systemctl show httpd.service |grep -i state
LoadState=loaded
ActiveState=inactive
SubState=dead
UnitFileState=disabled

[root@fedora system]# systemctl status httpd.service
httpd.service - The Apache HTTP Server (prefork MPM)
	  Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled)
	  Active: inactive (dead)
	  CGroup: name=systemd:/system/httpd.service

[root@fedora system]# 

From the man help page systemctl -h


Unit Commands:
  list-units                      List loaded units
  start [NAME...]                 Start (activate) one or more units
  stop [NAME...]                  Stop (deactivate) one or more units
  reload [NAME...]                Reload one or more units
  restart [NAME...]               Start or restart one or more units
  try-restart [NAME...]           Restart one or more units if active
  reload-or-restart [NAME...]     Reload one or more units is possible,
                                  otherwise start or restart
  reload-or-try-restart [NAME...] Reload one or more units is possible,
                                  otherwise restart if active
  isolate [NAME]                  Start one unit and stop all others
  kill [NAME...]                  Send signal to processes of a unit
  is-active [NAME...]             Check whether units are active
  status [NAME...|PID...]         Show runtime status of one or more units
  show [NAME...|JOB...]           Show properties of one or more
                                  units/jobs or the manager
  reset-failed [NAME...]          Reset failed state for all, one, or more
                                  units
  load [NAME...]                  Load one or more units

Unit File Commands:
  list-unit-files                 List installed unit files
  enable [NAME...]                Enable one or more unit files
  disable [NAME...]               Disable one or more unit files
  reenable [NAME...]              Reenable one or more unit files
  preset [NAME...]                Enable/disable one or more unit files
                                  based on preset configuration
  mask [NAME...]                  Mask one or more units
  unmask [NAME...]                Unmask one or more units
  link [PATH...]                  Link one or more units files into
                                  the search path
  is-enabled [NAME...]            Check whether unit files are enabled

Job Commands:
  list-jobs                       List jobs
  cancel [JOB...]                 Cancel all, one, or more jobs

Status Commands:
  dump                            Dump server status
  dot                             Dump dependency graph for dot(1)


Retrieved from http://www.itmission.org/Main/Systemctl-Control-the-systemd-system-and-service-manager
Page last modified on October 07, 2012, at 01:12 PM