Monday, August 1, 2011

Manage System Services

For steady and reliable system you need to know how to manage services efficiently. In Linux we call them daemons. You need to know how to turn on/off, and restrict for certain run-levels. If a name of a system process that ends d, it is a daemon. e.g. SSH service is sshd and Apache web service is httpd.

1) chkconfig
Here we exploit chkconfig command. it basically updates and queries runlevel information for system services. Syntax and synopsis for the service management command as follows.
chkconfig [options] service_name
usual Options are:
chkconfig [--list] [--type type][name] chkconfig --add name chkconfig --del name chkconfig --override name chkconfig [--level <levels>] [--type type] name
Check the sshd service status/on/off for particular runlevel:
# chkconfig --list sshd sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off # chkconfig sshd off # chkconfig --list sshd sshd 0:off 1:off 2:off 3:off 4:off 5:off 6:off # chkconfig sshd on # chkconfig --list sshd sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off # chkconfig --level 5 sshd off # chkconfig --list sshd sshd 0:off 1:off 2:on 3:on 4:on 5:off 6:off

2) ntsysv
netsysv is a simple interface for configuring runlevel services which are also configurable through chkconfig. By default, it configures the current runlevel. if the user would like to configure other runlevels, those levels can be specified on the command line by listing the kevels after --level, without any spaces. For example, the option --level 235 edits runlevels 2, 3, and 6.
A service is considers to be started in the runlevel set if it is started in any of the runlevels which are being edited.The ntsysv window normally contains a Cancel button. If --back is specified, a Back button appears instead.
SYNOPSIS
# ntsysv [--back] [--level <levels>]
# ntsysv --levels 235

3) Service
Service also can be utilize for start, stop, and check the status of services on the system after it has already up. service runs a System V init script in as predictable environment as possible, removing most environment variables and with current working directory set to /.
SYNOPSIS
service [--status-all] service service_name <{start|stop|status|restart|force-reload}>]
Here, normally service_name located in directory /etc/init.d/ .
# service sshd status openssh-daemon (pid 1880) is running... # service sshd stop Stopping sshd: [ OK ] # service sshd status openssh-daemon is stopped # service sshd start Starting sshd: [ OK ]

4) initctl
initctl allows a system administrator to communicate and interact with the Upstart init daemon.
Syntex: initctl {start|stop|restart|reload|status|list|emit}
Options:
start Starts a job
stop Stops a job
restart Restarts a job
reload Sends a HUP signal to a job
status Queries the status of a job
list Lists known jobs
emit Emits an event
# initctl list rc stop/waiting tty (/dev/tty3) start/running, process 2673 tty (/dev/tty2) start/running, process 2671 tty (/dev/tty6) start/running, process 2679 tty (/dev/tty5) start/running, process 2677 tty (/dev/tty4) start/running, process 2675 plymouth-shutdown stop/waiting control-alt-delete stop/waiting system-setup-keyboard start/running, process 1259 readahead-collector stop/waiting vpnc-cleanup stop/waiting quit-plymouth stop/waiting rcS stop/waiting prefdm start/running, process 2666 init-system-dbus stop/waiting ck-log-system-restart stop/waiting readahead stop/waiting ck-log-system-start stop/waiting splash-manager stop/waiting start-ttys stop/waiting readahead-disable-services stop/waiting ck-log-system-stop stop/waiting rcS-sulogin stop/waiting serial stop/waiting
Please find more about UPSTART in CentOS/RHEL 5.6/6

No comments:

Post a Comment

MABM

Demo: Create MBAM 2.5 users and groups in Active Directory Domain Services Configure MBAM 2.5 Roles for the instance of SQL Server ...