Showing posts with label CentOS. Show all posts
Showing posts with label CentOS. Show all posts

Kickstart Installation on RHEL/CentOS

Kickstart Installation

Hello readers, In this article I am going to walk you through kickstart installation, an automated installation method on RHEL based systems. I tested this on a CentOS 6.5 virtual machine. The process should be the same on other RHEL distro variations.

Kickstart

It is an automated way of installing the operating system. You set all the options in a config file which is then read by all the machine during installation. So you don’t have to manually answer all the questions that are generally asked during installation.
Here is a good explanation of kickstart from RedHat documentation.
Many system administrators would prefer to use an automated installation method to install Red Hat Enterprise Linux on their machines. To answer this need, Red Hat created the kickstart installation method. Using kickstart, a system administrator can create a single file containing the answers to all the questions that would normally be asked during a typical installation.
Kickstart files can be kept on a single server system and read by individual computers during the installation. This installation method can support the use of a single kickstart file to install Red Hat Enterprise Linux on multiple machines, making it ideal for network and system administrators.
Kickstart provides a way for users to automate a Red Hat Enterprise Linux installation.

Steps for kickstart installation

Here is a brief outline of the steps involved in automating installation using Kickstart
  • Create kickstart file that has all the installation options set
  • Create a boot disk with kickstart file
  • Or create a boot disk and have the kickstart file in the network
  • Make the OS installation tree available somewhere in the network (ftp, http, nfs)
  • Start the kickstart installation on new machines.

Kickstart configurator

Kickstart files are plain text files which can either be created by hand if you are an advanced user or using a GUI tool. I would reccommend going the GUI way if you are just starting. RedHat provides a kickstart configurator tool which can be installed as follows
# yum install system-config-kickstart
If you want to see how a kickstart file looks, take a look at anaconda-ks.cfg in /root directory of any RHEL/CentOS systems. This file gets generated and placed in /root directory on a newly installed machine.
Start the GUI tool using the system menu or from the terminal as follows
# system-config-kickstart
You will be welcomed with this screen
Kickstart Installation Scren 1
Most of the options are self-explanatory and fill in all the details as you would while installing the OS. You will also be able to select the packages that you want.
In the below installation option screen, select the one that suits your need. In this article I will show you how to do it via ftp and http.
Kickstart Installation Screen 2
When you select ftp or http method, the tool will ask you for ftp/http server url, password and path. Continue reading this article and you will find what to fill in this section. Once all the details are filled, save the file as ks.cfg or whatever you want it to be called, but remember it.

Creating bootdisk

You can either use your OS install disk or create a boot disk if you want by following the below process. You will be using this boot disk to boot the machine and then point it to the kickstart file later.
mkisofs is a tool provided by genisoimage package. Using this tool we can build iso files. Install it as follows.
# yum install genisoimage
Mount your RHEL/CentOS install DVD and copy isolinux directory
# mkdir /tmp/installdvd
# cp -R /path/to/mounted/dvd/isolinux /tmp/installdvd
# cd /tmp/installdvd
# chmod u+w isolinux/*
Create the iso image now
# cd /tmp/installdvd
# mkisofs -o file.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T isolinux/
This will create an iso image named file.iso. Burn it to a dvd and now you have got a boot disk!

Kickstart via FTP

I am going to assume here that you have got a working ftp server (vsftpd) and anonymous access is allowed.

Copying install tree to ftp:

Now we are going to copy the install disk to our ftp root. Lets assume you have got an iso file of the CentOS install disk downloaded from the internet. Mount it and copy to ftp as follows.
# mkdir /mnt/centosdvd
# mount -o loop /path/to/centos-6.5-x86_64-dvd.iso /mnt/centosdvd
# mkdir /var/ftp/pub/centos65
# cp -aR /mnt/centosdvd/* /var/ftp/pub/centos65/

Copying kickstart file to ftp:

Copy the kickstart file that you created earlier using system-config-kickstart to the ftp root.
# cp /path/to/ks.cfg /var/ftp/pub/

Adjusting SELinux:

If you have SELinux enabled, you need to set proper context to the newly copied directories. We shall use semanage tool to make our changes persistent. If you haven’t already got policycoreutils-python package installed, install it now.
# yum install policycoreutils-python
# semanage fcontext -a -t public_content_t "/var/ftp/pub/centos65(/.*)?"
# restorecon -R /var/ftp/pub/centos65
That’ it. Lets assume our server’s ip address is 10.0.3.100. This is going to be our kickstart server serving ks.cfg and OS install files.
On your kickstart configurator tool, select ftp and enter ftp://10.0.3.100/pub/centos65 as the ftp url.

Kickstart via HTTP

I am going to assume here that you have a web server set up already.

Copying install tree to web server:

Lets copy the OS install disk to web root so that all new machines can download packages from this server. Assuming you still have the disk mounted from earlier tasks,
# mkdir /var/www/html/centos65
# cp -aR /mnt/centosdvd/* /var/www/html/centos65/

Copy kickstart file to web server:

# cp /path/to/ks.cfg /var/www/html/

Adjusting SELinux:

# semanage fcontext -a -t httpd_sys_content_t "/var/www/html/centos65(/.*)?"
# restorecon -R /var/www/html/centos65

Performing Kickstart installation

Alright, we have come to the final bit. Lets perform an automated installation on one of our new machine. Boot the machine with either the boot disk that you created earlier or using the OS install DVD. When you see the boot menu press TAB key to edit the boot option. Append the ks.cfg location as below,

For ftp setup

> vmlinuz initrd=initrd.img console=ttyS0 ks=ftp://10.0.3.100/pub/ks.cfg

For http setup

> vmlinuz initrd=initrd.img console=ttyS0 ks=http://10.0.3.100/ks.cfg
That’s it. Unattended kickstart installation will proceed. Enjoy a cup of coffee!
Hope you learnt something new today. Thanks for reading this article.

Install PostgreSQL on CentOS 6

Install PostgreSQL on CentOS 6

Hi readers, I recently started playing with Postgresql database on CentOS machine and wanted to share the installation & set up process with you all. In this article I will show you how to install Postgresql on CentOS 6.5 machine.

PostgreSQL

From PostgreSQL site:
PostgreSQL is a powerful, open source object-relational database system. It has more than 15 years of active development and a proven architecture that has earned it a strong reputation for reliability, data integrity, and correctness. It runs on all major operating systems, including Linux, UNIX (AIX, BSD, HP-UX, SGI IRIX, Mac OS X, Solaris, Tru64), and Windows. It is fully ACID compliant, has full support for foreign keys, joins, views, triggers, and stored procedures (in multiple languages).

Install PostgreSQL

You can either install the packages provided by the default repositories or go for the Postgresql repository for the latest version. Here I will go with the default respository.
Install the following packages
  • postgresql – includes client programs and libraries needed to access a PostgreSQL server
  • postgresql-server - main server package which includes programs needed to create and run a postgresql server
  • postgresql-contrib – contains contributed packages that are included in the PostgreSQL distribution
Use the following command to install all of them
# yum install postgresql postgresql-server postgresql-contrib
Installing postgresql will create a user and group named postgres. Verify it with the below commands.
# grep postgres /etc/{passwd,group}
/etc/passwd:postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash
/etc/group:postgres:x:26:

Initialize Databases

We have got the server installed but before we can start using the server, the default databases needs to be initialized.
Use the following command to initialize the database
# service postgresql initdb

Set up services

By default the postgresql service will be stopped and not enabled. Check this using the below commands.
# chkconfig postgresql --list
postgresql      0:off   1:off   2:off   3:off   4:off   5:off   6:off
# service postgresql status
postmaster is stopped
Start the service and enable it on boot time using the below commands
# service postgresql start
# chkconfig postgresql on
# chkconfig postgresql --list
postgresql      0:off   1:off   2:on   3:on   4:on   5:on   6:off
Verify the service using netstat command as shown below
# netstat -nltp | grep post
tcp   0      0 0.0.0.0:5432     0.0.0.0:*    LISTEN      2022/postmaster
tcp   0      0 :::5432          :::*         LISTEN      2022/postmaster

Lets play with the database

First we will switch to postgres user account to connect to the database.
# su - postgres
Now type psql to connect to the postgresql server
[postgres@cent1: ~] $ psql
psql (8.4.20)
Type "help" for help.

postgres=#
We are now within psql prompt. Lets try some commands.

Create a database:

postgres=# create database demodb;
New database is created and you can list all databases using the \l command. For help type \? to see list of commands.
postgres=# \l
Note: You can also create database from the terminal using createdb command without logging into psql prompt. Check man createdb for more information

Create a user/role:

postgres=# create role testuser;
This will just create a new role but won’t allow login and doesn’t have a password. Check list of users with \du command
postgres=# \du
To create a user with login rights and password set, use below form
postgres=# create role testuser login password 'secret-password';
Note: You can also create a new user from the terminal using the createuser command without logging into psql prompt. Check man createuser for more information

Changing user password

You can use the \password command to change user password.
postgres=# \password testuser
Enter new password:
Enter it again:
postgres=#

Simple tweak

To be able to log into postgresql server using the new user/role that we created earlier, we also need the equivalent unix system account. So you need to create a new user account named testuser.
There is a workaround or alternate way of logging into postgresql server without having system user account. Use the below command instead.
# psql -U postgres -h localhost -W
You will see an error. Don’t panic. There is one more step to do. Open /var/lib/pgsql/data/pg_hba.conf
# vi /var/lib/pgsql/data/pg_hba.conf
Look for the below lines
local   all      all                    ident
host    all      all    127.0.0.1/32    ident
host    all      all    ::1/128         ident
Change ident to trust on all these lines so that it looks like below.
local   all      all                    trust
host    all      all    127.0.0.1/32    trust
host    all      all    ::1/128         trust
Restart the postgresql server
# service postgresql restart
Now you should be able to use the above command to login.

Enable remote connections

By default the postgresql server will listen on 127.0.0.1 and will only accept connections from localhost. To enable remote connections, you need to do few configuration changes.

Step #1: Update postgresql.conf

Find the main configuration file and open it for editing using the below command
# vi $(find / -iname postgresql.conf)
Look for the below line
#listen_addresses = 'localhost'
Uncomment and change it as follows
listen_addresses = '*'

Step #2: Update pg_hba.conf

Find and open this file for editing
# vi $(find / -iname pg_hba.conf)
Append the following line to it. Change the network address range as per your need.
host    all     all     192.168.122.0/24    trust

Step #3: Adjust firewall rules

If you want to access this postgresql server from other machines and you have firewall enabled,  you need to add the following rule to allow connections.
# iptables -I INPUT -m tcp -p tcp --dport 5432 -j ACCEPT

Step #4: Restart services

# service iptables save
# service postgresql restart
Now from any of the client machine you can access this postgresql server using the following command. Note that you need to install postgresql to be able to use psql command on client machines.
# psql -U postgres -h [postgresql-server-ip] -W
That’s it for this tutorial. Thanks for reading.

Set up OpenLDAP server on CentOS 6.5

Set up OpenLDAP on CentOS 6.5

Hi readers, hope you are learning Linux and gaining more knowledge every day. In this tutorial I am going to show you how to set up an OpenLDAP server on CentOS 6.5 server. Follow along to get a better understanding.

This is going to be a two part tutorial/article as shown below
  • Set up OpenLDAP server on CentOS 6.5
  • Enable LDAP authentication on client machines
    • LDAP Authentication on Ubuntu 14.04
    • LDAP Authentication on CentOS 6.5

What my set up will look like ?

I have an Ubuntu machine which will be my host and has KVM set up in it. All demonstrations will be done in the KVM virtual machines. I have three virtual machines.
  • Cent1 – CentOS 6.5 minimal server (This will be the ldap server)
  • Cent2 – CentOS 6.5 minimal server (users will be authenticated using ldap server cent1)
  • Ubunt1 – Ubuntu 14.04 minimal server (Users will be authenticated using ldap server cent1)

Tasks we will be doing

  • Install software packages for OpenLDAP
  • Configure LDAP & logging
  • Set up firewall rules
  • Do a first import of an ldif file
  • Verify our first import
  • Create ldap users
  • Query ldap for users we added in the previous step

Install OpenLDAP

The basic installation requires the following three packages
  1. openldap – installed by default on CentOS 6.5
  2. openldap-servers – provides slapd ldap server
  3. openldap-clients – provides client utilities like ldapadd, ldapsearch, ldapmodify
Lets install all the required packages using the below command.
# yum install openldap openldap-servers openldap-clients
Verify the installation using the below command
# rpm -qa | grep openldap
openldap-servers-2.4.23-34.el6_5.1.x86_64
openldap-clients-2.4.23-34.el6_5.1.x86_64
openldap-2.4.23-34.el6_5.1.x86_64
Ldap service is called slapd in CentOS/RHEL. By default, the service will be stopped and disabled. Once we complete all our configurations we shall enable and start it.

Configure LDAP

Note that you won’t have any configuration named slapd.conf under /etc/openldap. All the configuration files are located under /etc/openldap/slapd.d

Change the default domain:

The first thing you need to do is change the default domain in few config files. The default domain will be my-domain. Change this to your domain. In my case I will be using junglegeek.com as my domain throughout this article.
# cd /etc/openldap/slapd.d/cn\=config
Find out which files you need to update using the below grep command.
# grep my-domain *
Usually it will be the following two files
  • olcDatabase={1}monitor.ldif
  • olcDatabase={2}bdb.ldif
Open these two files in vi editor and change all occurrences of my-domain to junglegeek. I opened them and changed it with the following vi command
:%s/my-domain/junglegeek/

Set up admin password:

Now lets generate the admin password hash using slappasswd utility provided by the openldap-servers package.
# slappasswd
New password: 
Re-enter new password:
{SSHA}PlOJU60HjF+WTt9/8L10fjPyTugQ79V
Copy the above password hash. We need to add it to couple of config files. Open up the following two files
  • olcDatabase={2}bdb.ldif
  • olcDatabase={0}config.ldif
Look for line that starts with olcRootDN. Add the following line next to this line in the above two files
olcRootPW: {SSHA}PlOJU60HjF+WTt9/8L10fjPyTugQ79V

Copy database config file

Copy DB_CONFIG.example from /usr/share/openldap-servers to /var/lib/ldap and set correct permissions as shown below
# cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
# chown -R ldap.ldap /var/lib/ldap

Configure LDAP Logging

Now lets set up logging. Open /etc/rsyslog.conf
# vi /etc/rsyslog.conf
Add the below line
local4.*                         /var/log/slapd/slapd.log
Set up permissions appropriately
# mkdir /var/log/slapd
# chmod 755 /var/log/slapd
# chown ldap.ldap /var/log/slapd

Set up iptables

Ldap server uses the following ports. We need to add iptables rules to allow connections on port 389.
Port Description
389 LDAP
636 LDAPS
Add the below IPTable rule
# iptables -I INPUT -m tcp -p tcp --dport 389 -j ACCEPT

Restart services

All set and now start/restart all the services as below
# chkconfig slapd on
# service slapd start
# service rsyslog restart
# service iptables save
Verify slapd service using below commands
# netstat -nltp | grep slapd
# tail -f /var/log/slapd/slapd.log

Set up first import using ldapadd

Next thing we need to do is create a root entry for ldap. Create a file named firstimport.ldif
# vi firstimport.ldif
And enter the following content
dn: dc=junglegeek,dc=com
dc: junglegeek
o: junglegeek
objectclass: dcObject
objectclass: organization
Now add this entry to ldap using the below command
# ldapadd -x -D "cn=Manager,dc=junglegeek,dc=com" -W -f firstimport.ldif
Enter the admin password that you created earlier when asked. This command will add the root entry to the ldap server.
  • -x     : use simple authentication instead of SASL
  • -D    : binddn, the distinguished name to bind to the ldap directory
  • -W   : prompt for authentication instead of entering password in the command line
  • -f      : read information from the given file instead of the standard input

Verify import using ldapsearch

Now that we have added a single entry, we will verify it by querying the ldap server as below
[root@cent1 ~]# ldapsearch -x -b dc=junglegeek,dc=com
# extended LDIF
#
# LDAPv3
# base <dc=junglegeek,dc=com> with scope subtree
# filter: (objectclass=*)
# requesting: ALL
#

# junglegeek.com
dn: dc=junglegeek,dc=com
dc: junglegeek
o: junglegeek
objectClass: dcObject
objectClass: organization

# search result
search: 2
result: 0 Success

# numResponses: 2
# numEntries: 1
If you want to see the actual query output without comments and ldap version information use -LLL option as shown below.
[root@cent1 ~]# ldapsearch -x -LLL -b dc=junglegeek,dc=com 
dn: dc=junglegeek,dc=com 
dc: junglegeek 
o: junglegeek 
objectClass: dcObject 
objectClass: organization

Create LDAP Users

We have got a root entry dc=junglegeek,dc=com. Now lets add some OUs organizational units and some users.

Add organizational units OU:

Create a file named usersou.ldif and enter the below contents
dn: ou=users,dc=junglegeek,dc=com
ObjectClass: organizationalUnit
ou: users

dn: ou=groups,dc=junglegeek,dc=com
ObjectClass: organizationalUnit
ou: groups
Now add it to LDAP using the below command
[root@cent1 ~]# ldapadd -x -D "cn=Manager,dc=junglegeek,dc=com" -W -f usersou.ldif 
Enter LDAP Password: 
adding new entry "ou=users,dc=junglegeek,dc=com"
adding new entry "ou=groups,dc=junglegeek,dc=com"

Add a user to OU users:

We shall add a user to the newly created users organizational unit. Create a file named users.ldif and enter the below content.
# Section for User's primary group
dn: cn=venkatn,ou=groups,dc=junglegeek,dc=com
cn: venkatn
objectClass: top
objectClass: posixGroup
gidNumber: 5000

# Section for User
dn: uid=venkatn,ou=users,dc=junglegeek,dc=com
cn: Venkat Nagappan
givenName: Venkat
sn: Nagappan
uid: venkatn
uidNumber: 5000
gidNumber: 5000
homeDirectory: /home/venkatn
objectClass: top
objectClass: posixAccount
objectClass: shadowAccount
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: person
loginShell: /bin/bash
userPassword: {CRYPT}*
Add it to LDAP using the below command
# ldapadd -x -D "cn=Manager,dc=junglegeek,dc=com" -W -f users.ldif
Set up password for the newly created user using the below command
# ldappasswd -x -D "cn=Manager,dc=junglegeek,dc=com" -W -S "uid=venkatn,ou=users,dc=junglegeek,dc=com"
We are done adding an user and his primary group.

Query LDAP for users

Lets query the user we created in the previous step. You can use any of the user fields to query ldap. Try the following search commands.
# ldapsearch -x -LLL "uid=venkatn" -b "ou=users,dc=junglegeek,dc=com"
# ldapsearch -x -LLL "cn=Venkat Nagappan" -b "ou=users,dc=junglegeek,dc=com"
That’s it for this tutorial. In my next tutorial I will show you how to set up/enable LDAP authentication on CentOS 6.5 & Ubuntu client machines so that we can use this ldap user venkatn for login.
Hope you enjoyed this article. Thanks for reading.

CentOS 7 Released – Download DVD ISO Image | Download CentOS 7

After three weeks of continuous testing, CentOS project team finally on Mon July 7the 2014 released CentOS Linux 7 for 64 bit x86 compatible systems. This is the first major release for CentOS 7 and actual version is 7.0-1406.

This newly released CentOS 7.0 is an Enterprise-class Linux Distribution built from sources and freely maintained to the public by Red Hat. This release is based on upstream release of EL7 (Enterprise Linux 7) and most of the packages have been built from source and updated to more recent versions.
Download CentOS 7
CentOS 7 Preview
There are countless fundamental changes in this major release, compared to earlier versions of CentOS. Notably the involvement of Gnome3, systemd, and a default XFS filesystem.

CentOS 7 Major Changes

Following are the more notable changes are included in this release are:
  1. Updated Kernel to 3.10.0
  2. Added support for Linux Containers
  3. Open VMware Tools & 3D graphics drivers out of the box
  4. OpenJDK-7 as default JDK
  5. Upgrade from 6.5 to 7.0 using preupg command
  6. LVM-snapshots with ext4 and XFS
  7. Switch to grub2, systemd and firewalld
  8. Default XFS file system
  9. iSCSI and FCoE in kernel space
  10. Support for PTPv2
  11. Support for 40G Ethernet Cards
  12. Supports installations in UEFI (Unified Extensible Firmware Interface) Secure Boot form on compatible hardware
Before you go for CentOS 7.0 after CentOS 6.x, I suggest you to consider following things, because many of things have been changed in this release.
  1. grub is now replaced with grub2
  2. init is now replaced with systemd
  3. Difficultly in understanding and editing grub.conf (grub2)
  4. Difficultly in understanding /etc/init.d
  5. No more text log files for system log (journalctl instead)
  6. No more ext4 filesystem, added XFS as default filesystem
  7. CentOS 6.x will be supported until 2020

Download CentOS 7.0 – Torrent Links

Following are the torrent download links to CentOS 7 iso images, you may need a Linux torrent client to download them.
  1. CentOS-7.0-1406-x86_64-DVD.iso – [Size: 3.8GB]
  2. CentOS-7.0-1406-x86_64-Everything.iso – [Size: 6.5GB]
  3. CentOS-7.0-1406-x86_64-GnomeLive.iso – [Size: 1.3GB]
  4. CentOS-7.0-1406-x86_64-KdeLive.iso – [Size: 1.2GB]
  5. CentOS-7.0-1406-x86_64-livecd.iso – [Size: 687MB]
  6. CentOS-7.0-1406-x86_64-NetInstall.iso – [Size 362MB]
For those, who are looking to upgrade from CentOS 6.x to CentOS 7, there is a supported upgrade only from latest CentOS 6.5 version (at the time of writing this article) to the latest release of CentOS 7. The tool which is going to use for upgrade process is called Preupgrade Assistant (preupg) command which is still under development testing and will be released at a later time, but there is no any estimated time at the moment.

Once, the upgrade tool is released by the CentOS community, will provide a complete step-by-step guide on how to upgrade from CentOS 6.5 to CentOS 7 version. Till then stay tuned for the updates.

Securing CentOS Linux Installations by Disabling Un Needed Services

To ensure that my CentOS machines run as efficiently and securely as possible, I disable a number of services after each installation. The end result is a system that accepts ssh connections on TCP port 22, and on one or more service ports that are in use by the applications hosted on the platform.

To get to this state, I go through and disable numerous services that come enabled by default. Here is the default list of services that are enabled after a CentOS 4.4 installation:

$ chkconfig –list | grep on

atd             0:off   1:off   2:off   3:on    4:on    5:on    6:off
messagebus      0:off   1:off   2:off   3:on    4:on    5:on    6:off
smartd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
portmap         0:off   1:off   2:off   3:on    4:on    5:on    6:off
sendmail        0:off   1:off   2:on    3:on    4:on    5:on    6:off
netfs           0:off   1:off   2:off   3:on    4:on    5:on    6:off
cups            0:off   1:off   2:on    3:on    4:on    5:on    6:off
irqbalance      0:off   1:off   2:off   3:on    4:on    5:on    6:off
rpcgssd         0:off   1:off   2:off   3:on    4:on    5:on    6:off
xfs             0:off   1:off   2:on    3:on    4:on    5:on    6:off
isdn            0:off   1:off   2:on    3:on    4:on    5:on    6:off
autofs          0:off   1:off   2:off   3:on    4:on    5:on    6:off
gpm             0:off   1:off   2:on    3:on    4:on    5:on    6:off
apmd            0:off   1:off   2:on    3:on    4:on    5:on    6:off
crond           0:off   1:off   2:on    3:on    4:on    5:on    6:off
acpid           0:off   1:off   2:off   3:on    4:on    5:on    6:off
microcode_ctl   0:off   1:off   2:on    3:on    4:on    5:on    6:off
pcmcia          0:off   1:off   2:on    3:on    4:on    5:on    6:off
cpuspeed        0:off   1:on    2:on    3:on    4:on    5:on    6:off
xinetd          0:off   1:off   2:off   3:on    4:on    5:on    6:off
rpcidmapd       0:off   1:off   2:off   3:on    4:on    5:on    6:off
readahead_early 0:off   1:off   2:off   3:off   4:off   5:on    6:off
readahead       0:off   1:off   2:off   3:off   4:off   5:on    6:off
sshd            0:off   1:off   2:on    3:on    4:on    5:on    6:off
anacron         0:off   1:off   2:on    3:on    4:on    5:on    6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:off
kudzu           0:off   1:off   2:off   3:on    4:on    5:on    6:off
syslog          0:off   1:off   2:on    3:on    4:on    5:on    6:off
nfslock         0:off   1:off   2:off   3:on    4:on    5:on    6:off
rawdevices      0:off   1:off   2:off   3:on    4:on    5:on    6:off
mdmonitor       0:off   1:off   2:on    3:on    4:on    5:on    6:off
haldaemon       0:off   1:off   2:off   3:on    4:on    5:on    6:off

Several of these services are required, but several others serve no purpose in my environment, and use CPU and memory resources that would be better allocated to my applications. Since I don’t use RPC services, autofs or NFS, those are the first to get disabled:

$ /sbin/chkconfig –level 0123456 portmap off
$ /sbin/chkconfig –level 0123456 nfslock off
$ /sbin/chkconfig –level 0123456 netfs off
$ /sbin/chkconfig –level 0123456 rpcgssd off
$ /sbin/chkconfig –level 0123456 rpcidmapd off
$ /sbin/chkconfig –level 0123456 autofs off


I also don’t allow individual hosts to receive mail from the outside world, so sendmail gets nixed next:

$ /sbin/chkconfig –level 0123456 sendmail off

On server platforms, who needs printing?:

$ /sbin/chkconfig –level 0123456 cups off

Now we get to the font server, isdn capabilities, console mouse and pcmcia support. I don’t use these services on my servers, so they get disabled as well:

$ /sbin/chkconfig –level 0123456 xfs off
$ /sbin/chkconfig –level 0123456 isdn off
$ /sbin/chkconfig –level 0123456 gpm off
$ /sbin/chkconfig –level 0123456 pcmcia off


Once these services are disabled (and optionally stopped with the service command or a reboot), my netstat output looks nice and clean:

$ netstat –tcp –udp –listening

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State      
tcp        0      0 *:ssh                       *:*                         LISTEN   

This has served me well over the years, since it reduces boot time (less rc scripts to run), and frees up additional resources for my applications (while this isn’t substantial, every page of memory helps!).