Thursday, November 5, 2009

How to Start and Stop Services

Httpd Service:

service httpd stop
service httpd start

Example:
[root@lnx init.d]# service httpd stop
Stopping httpd: [ OK ]

[root@lnx init.d]# wget http://localhost/index1.html
--23:02:18-- http://localhost/index1.html
=> `index1.html.1'
Resolving localhost... 127.0.0.1
Connecting to localhost[127.0.0.1]:80... failed: Connection refused.

[root@lnx init.d]# service httpd start
Starting httpd: [ OK ]

[root@lnx init.d]# wget http://localhost/index1.html
--23:02:28-- http://localhost/index1.html
=> `index1.html.1'
Resolving localhost... 127.0.0.1
Connecting to localhost[127.0.0.1]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 65 [text/html]

100%[=====================================================================>] 65 --.--K/s

23:02:28 (634.77 KB/s) - `index1.html.1' saved [65/65]

[root@lnx init.d]#

FTP Service:

Used Vsftpd server as FTP server here.
(To start any service using "service start", we should have the corresponding servie
in the /etc/init/d directory. Lets see how to add vsftpd to /etc/init.d later. For now we can
start / stop the vsftpd service using the process spawn / kill method)

To start the vsftpd service as a background process:
/usr/local/sbin/vsftpd &

To stop the vsftpd service, kill the process:
killall vsftpd

Example:

[root@lnx ~]# ftp localhost
Connected to lnx.cisco.com.
220 (vsFTPd 2.0.5)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (localhost:root): root
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/root"
ftp> quit
221 Goodbye.
[root@lnx ~]#


DNS Service

Service "named" is meant for DNS.

[root@lnx ~]# service named restart
Stopping named: [ OK ]
Starting named: [ OK ]
[root@lnx ~]#

Instead of "restart", you can also "stop" and then "start".

Example:

[root@lnx ~]# dig @localhost www3.example.com

; <<>> DiG 9.2.4 <<>> @localhost www3.example.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16182
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;www3.example.com. IN A

;; ANSWER SECTION:
www3.example.com. 1 IN A 3.1.1.2
www3.example.com. 1 IN A 3.1.1.3
www3.example.com. 1 IN A 3.1.1.4

;; AUTHORITY SECTION:
dnsins.com. 1 IN NS ns.dnsins.com.

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(localhost)
;; WHEN: Wed Nov 4 23:35:20 2009
;; MSG SIZE rcvd: 98

[root@lnx ~]#

SIP

No comments:

Post a Comment