Managing services on Linux

This article applies to Red Hat, Fedora, CentOS, AWS Linux distros.

For enabling, disabling and listing system services, use the script called chkconfig.

List all services

chkconfig --list

List a specific service

chkconfig --list httpd

Turn a service on for specific levels

chkconfig httpd on --level 2,3,5

Disable a service

chkconfig httpd off

For stopping, starting and restarting a service, use the script called service.

service httpd stop
service httpd start
service httpd restart
Advertisements

AWS EC2 Linux swap file creation

The Amazon EC2 Linux instances come without a swap file. The steps below show how to add a swap file to an EC2 Linux server.

dd if=/dev/zero of=/mnt/swapfile bs=1M count=4096
chown root:root /mnt/swapfile
chmod 600 /mnt/swapfile
mkswap /mnt/swapfile
swapon /mnt/swapfile
swapon -a

To make these changes permanent (reboot proof). Add the following line to /etc/fstab

vi /etc/fstab
/mnt/swapfile swap swap defaults 0 0