Operating System/O.S(Arif Butt)

Managing Services using systemd (Lec 28)

Tony Lim 2021. 3. 3. 21:42
728x90

/sbin/init still exist for compatibility and both systemd ,init is soft link.

systemctl == control the systemd system and service manager

target == group units together , simliar to runlevel in order unix system

one must not change /lib/systemd/system files if need it we can edit on /etc/systemd/system directory 

 

Runlevels are an obsolete way to start and stop gorups of services used in Sys init. 

target has dependencies. in this exmaple we need many other taget to enable graphical.target

enable == service start automatically in boot time

disable == service doesn't start automatically in boot time

static == service cannot run automatically in boot time

mask == service is completely disabled you cannot enable until you unmask it

since it is enabled it will be automatically start once we boot the system. once you enable it you can see the description like below

Created symlink /etc/systemd/system/sshd.service -> /lib/systemd/system/ssh.service
notice it is /etc directory not /lib 

once you disable it it will remove from /etc/systemd/system/sshd.service

exampel of selfmade service. want to managed by systemd as daemon

i compile it 
root@server:~# gcc tonysvc1.c -o /usr/local/bin/tony1

root@server:~# cp /lib/systemd/system/ssh.service /etc/systemd/system/tony1.service
by doing this we can safely not touch /lib directory and work on /etc

ExectStart is same directory where our object file is when compiled 
and now let me check status of this system

and then i start the service

and check my log file

and stop the system

728x90