By default, most Linux distributions automatically enable a number of services. However, this is counterintuitive when it comes to security. You can rectify this after booting into your newly installed Linux system—prior to connecting to a local network or the Internet.
A number of Linux distributions, including Mandrake Linux and Red Hat, use the chkconfig tool to control what services are running. It's also used to enable or disable a service by an associated run-level. To determine what services are enabled at boot, when you boot into runlevel 5 (typically used to start a multiuser GUI), execute the following:
# /sbin/chkconfig —list|grep '5:on'
If you see services that you don't want to run, such as smb, nfs, or portmap, enter this command:
# /sbin/chkconfig smb off
Replace smb with the service name that you want to disable. Similarly, you can enable services by ending the command with the argument 'on'.
Other distributions use similar tools, so check the documentation for your particular distribution. One tool that works on all Linux systems is Netstat. Here's an example:
# netstat -l —tcp -p
# netstat -l —udp -p
This allows you to see what services are running and listening to TCP or UDP sockets, what binary program has opened the socket to listen, and what ports they're listening to. You can then use this information to determine what services to disable.