{
	"id": "59c59f3e-bfd6-448e-8a66-d1c835de6a7a",
	"created_at": "2026-04-06T00:06:48.357845Z",
	"updated_at": "2026-04-10T03:21:10.109172Z",
	"deleted_at": null,
	"sha1_hash": "5faa4d8c83b8062faba7043a61ef6b255beafec8",
	"title": "An introduction to services, runlevels, and rc.d scripts - Linux.com",
	"llm_title": "",
	"authors": "",
	"file_creation_date": "0001-01-01T00:00:00Z",
	"file_modification_date": "0001-01-01T00:00:00Z",
	"file_size": 68049,
	"plain_text": "An introduction to services, runlevels, and rc.d scripts - Linux.com\r\nBy The Linux Foundation\r\nPublished: 2006-01-12 · Archived: 2026-04-05 18:23:26 UTC\r\nA Linux service is an application (or set of applications) that runs in the background waiting to be used, or\r\ncarrying out essential tasks. I’ve already mentioned a couple of typical ones (Apache and MySQL). You will\r\ngenerally be unaware of services until you need them.\r\nHow can you tell what services are running, and more importantly, how can you set up your own?\r\nSystem V vs. BSD\r\nIn this article I’m dealing with System V (derived from AT\u0026T System V) based distributions. This is the most\r\ncommon Linux init system. Another is based on BSD (Berkeley Software Distribution). What’s the difference\r\nbetween the two? Basically BSD doesn’t have any runlevels. This means that System V gives a lot more\r\nflexibility to a system administrator.\r\nMost Linux distros put startup scripts in the rc subdirectories (rc1.d, rc2.d, etc.), whereas BSD systems house\r\nthe system scripts in /etc/rc.d. Slackware’s init setup is similar to BSD systems, though Slackware does have\r\nrunlevels and has had System V compatibility since Slackware 7.\r\nLet’s start by looking at how the system is set up, and in particular at the directory /etc/rc.d. Here you will find\r\neither a set of files named rc.0, rc.1, rc.2, rc.3, rc.4, rc.5, and rc.6, or a set of directories named rc0.d, rc1.d, rc2.d,\r\nrc3.d, rc4.d, rc5.d, and rc6.d. You will also find a file named /etc/inittab. The system uses these files (and/or\r\ndirectories) to control the services to be started.\r\nIf you look in the file /etc/inittab you will see something like:\r\nid:4:initdefault:l\r\n0:0:wait:/etc/rc.d/rc.0l\r\n6:6:wait:/etc/rc.d/rc.6x\r\n1:4:wait:/etc/rc.d/rc.4\r\nThe boot process uses these parameters to identify the default runlevel and the files that will be used by that\r\nrunlevel. In this example, runlevel 4 is the default and the scripts that define runlevel 4 can be found in\r\nhttps://www.linux.com/news/introduction-services-runlevels-and-rcd-scripts/\r\nPage 1 of 5\n\n/etc/rc.d/rc.4.\r\nAnd what is a runlevel? You might assume that this refers to different levels that the system goes through during a\r\nboot up. Instead, think of the runlevel as the point at which the system is entered. Runlevel 1 is the most basic\r\nconfiguration (simple single user access using an text interface), while runlevel 5 is the most advanced (multi-user, networking, and a GUI front end). Runlevels 0 and 6 are used for halting and rebooting the system.\r\nThere are, however, differences between Linux distributions. For instance, Fedora uses runlevel 5 for X-based\r\nlogins, whereas Slackware uses runlevel 4 to do the same job. Therefore, you should check your documentation\r\nbefore making any changes. This table shows a generic list of configurations (and some examples of different\r\ndistros) taken from Linux – The Complete Reference (R.Peterson, Osbourne/McGraw-Hill).\r\nRun\r\nLevel\r\nGeneric Fedora Core Slackware Debian\r\n0 Halt Halt Halt Halt\r\n1 Single-user mode Single-user mode Single-user mode\r\nSingle-user mode\r\n2\r\nBasic multi-user\r\nmode (without\r\nnetworking)\r\nUser definable (Unused)\r\nUser definable – configured\r\nthe same as runlevel 3\r\nMulti-user\r\nmode\r\n3\r\nFull (text based)\r\nmulti-user mode\r\nMulti-user mode\r\nMulti-user mode – default\r\nSlackware runlevel\r\n4 Not used Not used\r\nX11 with\r\nKDM/GDM/XDM (session\r\nmanagers)\r\nMulti-user\r\nmode\r\n5\r\nFull (GUI based)\r\nmulti-user mode\r\nFull multi-user mode (with\r\nan X-based login screen) –\r\ndefault runlevel\r\nUser definable – configured\r\nthe same as runlevel 3\r\nMulti-user\r\nmode\r\n6 Reboot Reboot Reboot Reboot\r\nAs you can see there are slight (but important) differences between Linux distributions. One thing is common\r\nbetween them — if you want to change the default level, you must edit /etc/initab. You will need to be root or use\r\nsudo to edit this file, naturally.\r\nWhy would you want to change the runlevel? Normally you will only use full GUI or text multi-user mode —\r\nrunlevels 4 or 5. You’d only want runlevels 1 or 2 if you have some system problems and you want the most basic\r\naccess. Runlevels 0 and 6 should never be used as a default (for obvious reasons — you don’t want the system to\r\nhttps://www.linux.com/news/introduction-services-runlevels-and-rcd-scripts/\r\nPage 2 of 5\n\nshutdown or reboot as soon as you turn it on). You can, of course, change mode whilst the system is running. Type\r\ninit followed by the required runlevel e.g.:\r\ninit 6\r\nThis will reboot the system.\r\nThe boot process, or to be more accurate the init command, will decide the runlevel to select (in the example\r\nabove it’s 4) and from that will decide the rc.d script files to be run. In this case either the file /etc/rc.d/rc.4 or any\r\nfiles in the directory /etc/rc.d/rc4.d. Let’s look at an example rc.d script file. Here’s the default rc.4 file for\r\nSlackware 10.2:\r\n# Try to use GNOME's gdm session manager:\r\nif [ -x /usr/bin/gdm ];\r\nthen exec /usr/bin/gdm -nodaemonfi\r\n# Not there? OK, try to use KDE's KDM session manager:\r\nif [ -x /opt/kde/bin/kdm ];\r\n then exec /opt/kde/bin/kdm -nodaemonfi\r\n# If all you have is XDM, I guess it will have to do:\r\nif [ -x /usr/X11R6/bin/xdm ];\r\n then exec /usr/X11R6/bin/xdm -nodaemonfi\r\nA quick guide to the boot process\r\nWhen you boot your computer, the first thing that it will do is load the bootloader — either GRUB or LILO in\r\nmost cases. The bootloader will then load the Linux kernel — the core operating system. Next, a process\r\ncalled init starts. This process reads the file /etc/inittab to establish the runlevel to use. The runlevel is the start\r\nmode for the computer.\r\nOnce init knows the runlevel it will look for the appropriate files or directories as defined in /etc/initab.\r\nhttps://www.linux.com/news/introduction-services-runlevels-and-rcd-scripts/\r\nPage 3 of 5\n\nInit will then either run the script files defined by /etc/initab, or run the script files in the directories defined by\r\n/etc/initab (depending on the set up of your system).\r\nFinally, init will present you with the logon mode that you’ve selected.\r\nAs you would expect, since runlevel 4 is the Slackware X11 mode, the commands are all concerned with the\r\nsetting up of the graphical interface.\r\nIn the other distros (such as Fedora and Debian) you’ll find that the scripts to be run are actually symbolic links to\r\nfiles in the directory /etc/init.d — the central repository for all startup scripts. So all you have to do is to write\r\nyour startup script, place it in /etc/init.d, and then create a symbolic link to it from the appropriate runlevel\r\ndirectory (or runlevel file, if that’s what your system uses).\r\nFor example, runlevel 2 is the default runlevel for Debian in non-GUI mode. If you’re running Apache 2 on\r\nDebian, you’d find an init script for Apache 2 under /etc/init.d called apache2. A symlink, S91apache2, points to\r\n/etc/init.d/apache2 from /etc/rc2.d — this tells init to start Apache 2 in runlevel 2, but only after other services\r\nwith lower S numbers.\r\nWhen the system is shut down, there is another symlink in the /etc/rc0.d and /etc/rc6.d directories (halt and reboot,\r\nrespectively) that starts with a K instead of an S, which tells init to shut down the process.\r\nIf this all still sounds a bit too complicated, you can instead simply make use of the /etc/rc.d/rc.local file. This\r\nscript file is run once, before all other scripts have run but before the logon prompt appears. By default it looks\r\nsomething like:\r\n#!/bin/bash## /etc/rc.local - run once at boot time\r\n# Put any local setup commands in here:\r\nYou can append your instructions onto the end of the file by defining another script to be run:\r\n/root/bin/start_bb\r\nOr you can modify rc.local by adding the commands themselves:\r\nmodprobe -r uhcimodprobe usb-uhcieciadsl-startiptable -Fiptables -A\r\nINPUT -i ppp0 -p tcp --syb -j DROPnetdate time.nist.gov\r\nHere a USB modem is initialized, a connection set up to a broadband network, some basic security is set up, and\r\nthen the local time is synchronized with a time server. You can also start Apache or MySQL:\r\nhttps://www.linux.com/news/introduction-services-runlevels-and-rcd-scripts/\r\nPage 4 of 5\n\napachectl startecho \"/usr/bin/mysqld_safe \u0026\" | su mysql\r\nNote that some distros, such as Debian, do not use rc.local for startup scripts. See the Debian FAQ if you’d like to\r\nadd startup scripts for Debian or Debian-derived distros.\r\nOne final thought — in addition to startup scripts (for rc.local), try to remember to write close-down scripts to be\r\nadded to rc.0 and rc.6. This ensures that your services are shut down neatly and not left in strange states when the\r\nsystem halts.\r\nAbout shutting down — how do you stop a service from starting when you reboot? It’s just the reverse of what\r\nwe’ve already looked at. Either edit the relevant runlevel file (comment the lines out rather than removing them)\r\nor remove the link from the runlevel directory. Note that it may not be necessary to do this manually, as many\r\ndistros include tools to manage services. For example, Red Hat and Fedora use chkconfig, while Debian uses\r\nupdate-rc.d.\r\nFrom this brief discussion, I hope you can see how useful rc.d scripts can be when it comes to controlling the\r\nservices to be run on your PC. You can now add your own as required, as well as look at existing ones that you\r\nmay not require and which are slowing down your logon or overloading your PC.\r\nSource: https://www.linux.com/news/introduction-services-runlevels-and-rcd-scripts/\r\nhttps://www.linux.com/news/introduction-services-runlevels-and-rcd-scripts/\r\nPage 5 of 5",
	"extraction_quality": 1,
	"language": "EN",
	"sources": [
		"MITRE"
	],
	"references": [
		"https://www.linux.com/news/introduction-services-runlevels-and-rcd-scripts/"
	],
	"report_names": [
		"introduction-services-runlevels-and-rcd-scripts"
	],
	"threat_actors": [],
	"ts_created_at": 1775434008,
	"ts_updated_at": 1775791270,
	"ts_creation_date": 0,
	"ts_modification_date": 0,
	"files": {
		"pdf": "https://archive.orkl.eu/5faa4d8c83b8062faba7043a61ef6b255beafec8.pdf",
		"text": "https://archive.orkl.eu/5faa4d8c83b8062faba7043a61ef6b255beafec8.txt",
		"img": "https://archive.orkl.eu/5faa4d8c83b8062faba7043a61ef6b255beafec8.jpg"
	}
}