Autostart: Difference between revisions
m Text replacement - "<(\/?)source" to "<$1syntaxhighlight" Tags: Mobile edit Mobile web edit |
No edit summary |
||
| 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 === | ||
| Line 146: | Line 146: | ||
systemctl enable|disable|start|stop|status <servicename>.service | systemctl enable|disable|start|stop|status <servicename>.service | ||
</syntaxhighlight> | </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 == | ||
Latest revision as of 05:47, 3 July 2025
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 init and the rc.d run levels, you can use either chkconfig[1] (RedHat and derivatives) or sysv-rc-conf or update-rc.d[2]for Debian variants to make that permanent. The old SysV style init has now largely been replaced by systemd, so this article is just to guide you through some of the equivalents across multiple ways of doing init.
List services
So what are the services controlled by init[3][4] scripts?
# the easy way (if somewhat non-specific)
ls -l /etc/rc.d/init.d/
# On Ubuntu 14.04 you'll have the 'service' command
# service --status-all runs all init scripts, in alphabetical order, with the status command. This option only calls status for sysvinit jobs
service --status-all
# upstart jobs can be queried in a similar manner with initctl list
initctl list
# on older Ubuntu like 14.04, you probably also have update-rc.d, but that doesn't have a 'list' command
# You could 'manually' search all the init scripts for the right runlevel
grep -i 'runlevel' /etc/init/*| awk '!/#/ && /start on/ && /2/ {gsub("/"," "); print $0 }' | cut -d ' ' -f4-
# or
grep -i 'runlevel' /etc/init/* | awk '/start on/ && /2/ {gsub("/"," "); gsub(":", " ");gsub(".conf"," "); print $3 }'
# the RedHat way (using chkconfig)
chkconfig --list
# for newer systemd controlled systems
systemctl list-unitsHere is an example list of the services you might find on your machine:
- NetworkManager
- acpid
- anacron
- atd
- auditd
- autofs
- avahi-daemon
- avahi-dnsconfd
- bluetooth
- capi
- clvmd
- cman
- cmirror
- conman
- cpuspeed
- crashplan
- crond
- cups
- dc_client
- dc_server
- dnsmasq
- dund
- ebtables
- firstboot
- gfs
- gfs2
- gpm
- haldaemon
- hidd
- hplip
- httpd
- ip6tables
- ipmi
- iptables
- irda
- irqbalance
- iscsi
- iscsid
- isdn
- kdump
- kudzu
- libvirt-guests
- libvirtd
- lm_sensors
- luci
- lvm2-monitor
- mcstrans
- mdmonitor
- mdmpd
- messagebus
- modclusterd
- multipathd
- mysql51-mysqld
- mysql55-mysqld
- mysqld
- nagios
- netconsole
- netfs
- netplugd
- network
- networker
- nfs
- nfslock
- nginx
- nrpe
- nscd
- ntop
- ntpd
- nxserver
- oddjobd
- openais
- openwsmand
- pand
- pcscd
- piranha-gui
- portmap
- postfix
- postgresql
- psacct
- pulse
- qdiskd
- rawdevices
- rdisc
- readahead_early
- readahead_later
- restorecond
- rgmanager
- rhnsd
- rhsmcertd
- ricci
- rpcgssd
- rpcidmapd
- rpcsvcgssd
- rsyslog
- saslauthd
- sblim-sfcb
- scsi_reserve
- setroubleshoot
- slinksc
- smartd
- snmpd
- snmptrapd
- squid
- sshd
- svnserve
- syslog
- tomcat5
- tux
- vncserver
- wdaemon
- winbind
- wpa_supplicant
- xfs
- xinetd
- ypbind
- yum-updatesd
Enable/Disable/Start/Stop/Status a service
# for older systems using System V style init
chkconfig apache on|off|start|stop|status
# for newer systemd controlled systems
systemctl enable|disable|start|stop|status <servicename>.serviceSystemD 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:
sudo systemctl isolate rescue.target
courtesy of https://askubuntu.com/questions/788323/how-do-i-change-the-runlevel-on-systemd