Autostart: Difference between revisions

adds more Ubuntu reference
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
When your machine turns on or reboots, you want certain things to happen automatically.  If the 'machine' is a web server hosting websites defined by [[Apache]] and also a database server running [[MySQL]], then naturally you would want Apache and MySQL to start automatically.  In SysV-style systems that still use <code>init</code> and the rc.d run levels, you can use either <code>chkconfig</code><ref>http://linuxcommand.org/man_pages/chkconfig8.html</ref> (RedHat and derivatives) or <code>sysv-rc-conf</code> or <code>update-rc.d</code><ref>http://manpages.ubuntu.com/manpages/precise/man8/update-rc.d.8.html</ref>for Debian variants to make that permanent.  The old SysV style init has now largely been replaced by <code>systemd</code>, so this article is just to guide you through some of the equivalents across multiple ways of doing init.
When your machine turns on or reboots, you want certain things to happen automatically.  If the 'machine' is a web server hosting websites defined by [[Apache]] and also a database server running [[MySQL]], then naturally you would want Apache and MySQL to start automatically.  In SysV-style systems that still use <code>init</code> and the rc.d run levels, you can use either <code>chkconfig</code><ref>http://linuxcommand.org/man_pages/chkconfig8.html</ref> (RedHat and derivatives) or <code>sysv-rc-conf</code> or <code>update-rc.d</code><ref>http://manpages.ubuntu.com/manpages/precise/man8/update-rc.d.8.html</ref>for Debian variants to make that permanent.  The old SysV style init has now largely been replaced by <code>'''systemd'''</code>, so this article is just to guide you through some of the equivalents across multiple ways of doing init.


=== List services ===
=== List services ===
So what are the services controlled by init<ref>http://manpages.ubuntu.com/manpages/trusty/man5/init.5.html</ref><ref>http://manpages.ubuntu.com/manpages/trusty/man8/init.8.html</ref> scripts?
So what are the services controlled by init<ref>http://manpages.ubuntu.com/manpages/trusty/man5/init.5.html</ref><ref>http://manpages.ubuntu.com/manpages/trusty/man8/init.8.html</ref> scripts?
<source lang="bash">
<syntaxhighlight lang="bash">
# the easy way (if somewhat non-specific)
# the easy way (if somewhat non-specific)
ls -l /etc/rc.d/init.d/
ls -l /etc/rc.d/init.d/
Line 20: Line 20:
# for newer systemd controlled systems
# for newer systemd controlled systems
systemctl list-units
systemctl list-units
</source>
</syntaxhighlight>
Here is an example list of the services you might find on your machine:
Here is an example list of the services you might find on your machine:
# NetworkManager
# NetworkManager
Line 140: Line 140:


=== Enable/Disable/Start/Stop/Status a service ===
=== Enable/Disable/Start/Stop/Status a service ===
<source lang="bash">
<syntaxhighlight lang="bash">
# for older systems using System V style init
# for older systems using System V style init
chkconfig apache on|off|start|stop|status
chkconfig apache on|off|start|stop|status
# for newer systemd controlled systems
# for newer systemd controlled systems
systemctl enable|disable|start|stop|status <servicename>.service
systemctl enable|disable|start|stop|status <servicename>.service
</source>
</syntaxhighlight>
 
== SystemD targets ==
To switch to single-user mode, what used to be called '''runlevel 1''', on a modern Linux running SystemD, you would now use the command:
 
<code>sudo systemctl isolate rescue.target</code>
 
courtesy of https://askubuntu.com/questions/788323/how-do-i-change-the-runlevel-on-systemd


== More ==
== More ==