Do I really need that stuff running on my Linux machine?

Guide to what's what, under Linux.

Regardless of what distribution you install, when you run a Linux installer you tend to pick one, or other, of the "standard" installations. This generally means that when you boot up for the first time, you'll end up with stuff running that you didn't want. There are a couple of good reasons why you wouldn't want this to happen: first, anything that's running unnecessarily takes memory and processor cycles; second, and more importantly, a lot of Linux packages are network-related and to have them sitting listening for incoming connections may give you a security hole. What's running?
The first place to look to see what's running is the boot-up screen. As Linux starts, you see a bunch of text floating up the screen, most of which comprises lines that say: "Starting XXX". So have a scan and see if there's anything that strikes you as unwanted (if you're not using database services, for instance, you might spot that "Starting MySQL" is telling you that there's a database system running that you don't want). Where to look
When it starts up, Linux looks at its startup directories to see what services to fire up. All Unix family operating systems have the concept of a "runlevel", which is the state to which the system boots. The two most common runlevels are 3 (standard multi-user mode with a command line prompt on the console screen) and 5 (multi-user mode with a graphical X-Windows user interface). You can see which runlevel your system is operating in by looking in /etc/inittab; you'll see an "initdefault" line that looks something like: id:5:initdefault … which in this case tells us that the system will run at level 5 – multi-user with X-Windows. Linux's startup files live in a set of directories under /etc/rc.d. The actual startup scripts themselves live in /etc/rc.d/init.d, and the directories that relate to the various runlevels have symbolic links (like Windows shortcuts) to these main scripts. Each runlevel has a directory within /etc/rc.d – these are called rc1.d, rc2.d, and so on – the number relates to the runlevel. So for runlevel 5, we care about the contents of /etc/rc.d/rc5.d. Within each directory are a set of "stop" links (labelled Kxxxxx) and a set of "start" links (Sxxxxx). When Linux moves to a given runlevel, it starts all the services that start with an S, and stops those that start with a K (if they're running). So if you have an item "S80sendmail" in /etc/rc.d/rc5.d, this means that it'll start the Sendmail email transport service when Linux boots. Services are started and stopped in ascending lexicographic order of their link name in the startup directory. So S80sendmail would be started before S80spamassassin, because this is the order they'd appear in an alphabetic list. If you compare the runlevel 5 directory with, say, the runlevel 1 (single user with little running) you'll see that the "K" entries in the level 1 directory are ordered, to a large extent, in reverse order from the "S" entries in level 5. This makes sense – if you start X after Y because X can't run unless Y's already going, it makes sense to stop X before you stop Y when the time comes to turn things off. If you want to disable something in your current runlevel, you'll need to change its "S" script to a "K" script. The trick here is to figure out what you need to change the ordering to – for instance, Sendmail starts up as S80sendmail, but stops as S30sendmail. The trick is to look in the runlevel 0 (halt) directory, as this shuts down pretty well everything, for a "K" script from which you can crib the appropriate number. So let's assume we want to stop the CUPS (printing) service from running. Its startup script in /etc/rc.d/rc5.d is called S90cups, so let's do a quick scan for items in /etc/rc.d/rc0.d that are called K??cups: [root@piii-600 rc5.d]# ls /etc/rc.d/rc0.d/K*cups /etc/rc.d/rc0.d/K10cups This gives us the clue that we should use 10 as our ordering. The trick now is to realise that the start and stop entries in the runlevel startup directories are just links to the real scripts, which live in /etc/rc.d/init.d, and that the script deals with both startup and shutdown items. So all we need to do to disable our service is to rename the "S" script in /etc/rc.d/rc5.d to the right "K" filename: [root@piii-600 rc5.d]# mv S90cups K10cups One other quick hint: the name of the startup item often makes it hard to guess what the script does. If this is the case, find the script with the appropriate name in /etc/init.d, because there are usually loads of comments at the top of each script describing what the package does. Pretty GUI
Under most Linuxes, you don't have to muck about with these files – assuming you're running the GUI runlevel (5) you'll get a pretty application that lets you just tick the things you want to start. In Red Hat 9, you'd go to System Settings->Server Settings->Services to run this tool. The GUI tool is quite nice, because as well as letting you easily tell it which services you do and don't want, it has a nice description for each item so you don't have to guess what it's for from its (usually cryptic) name. The GUI-based system doesn't do anything that you wouldn't be able to do by hand (it just manipulates links in the same way as we've discussed) but it does make life easier.

Comment

What are your views on this subject? Use the form below to post a comment on this article up to 500 characters.

Characters remaining: 500

Related Operating Systems news

Oracle releases Solaris 9/10 update with virtualisation enhancements

Former Sun Unix platform gets minor upgrade

Samsung Galaxy Tab root protection broken before release

Android developers crack tablet PC security for root access

Open source projects under microscope

Open world forum to pick best

Apple iOS devices outnumber Android 6 to 1 on web

Apple boots Linux from number 3 spot online



Send to a friend

Email this article to a friend or colleague:

PLEASE NOTE: Your name is used only to let the recipient know who sent the story, and in case of transmission error. Both your name and the recipient's name and address will not be used for any other purpose.

Techworld White Papers

IT Manager's guide to buying an anti-spam solution

With these ten critical questions as your guide, you can cut through the marketing hype and zero in on the key features and benefits that should guide your decision.

Download Whitepaper

Unleashing cloud performance

While cloud services aim to eliminate cost and complexity from the world of enterprise IT, the unintended consequences of these services may do exactly the opposite if not carefully planned for.

Download Whitepaper

Online PC backup

This paper looks at the need for laptop and desktop data protection and, based upon recent IDC research, the key requirements firms should consider in evaluating enterprise-level online PC backup solutions.

Download Whitepaper

Protecting your business, customers, and the bottom line

Download this whitepaper to find out more about how you can protect your business from malware.

Download Whitepaper

Techworld UK - Technology - Business

Oracle Video

Enabling agile and intelligent businesses

 Changing markets, competitive pressures and evolving customer needs are placing increasing pressure on IT to deliver greater flexibility and speed. Explore truly flexible SOA foundations with this Oracle video.

Watch
AMD LGF

AMD Opteron™ Resource Centre

Set the foundations for higher speed processing, low energy consumption whilst delivering flexibility and value to your organisation.

Learn More

Win an iPad

How do you view and share technology related content and information? Tell us in our 2010 Media Usage Survey and you could win an iPad.

Complete the survey here

Site Map

IDG Network

* *