LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-12-2010, 10:12 PM   #1
Phoebe77
LQ Newbie
 
Registered: Apr 2010
Posts: 6

Rep: Reputation: 0
Question Port 80 - Stopping Services?


Hey all, I'm trying to stop all the services on port 80 by I'm not entirely sure how.

Infact, I don't really know what's running on port 80... I tried throwing a netstat -a in a prompt but I don't see port numbers anywhere so I can't figure out which PID to kill.

Any ideas on how I can figure out what's running on port 80, and stop it?

Thanks,

Phoebe
 
Old 04-12-2010, 10:15 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,689

Rep: Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972
Quote:
Originally Posted by Phoebe77 View Post
Hey all, I'm trying to stop all the services on port 80 by I'm not entirely sure how.

Infact, I don't really know what's running on port 80... I tried throwing a netstat -a in a prompt but I don't see port numbers anywhere so I can't figure out which PID to kill.

Any ideas on how I can figure out what's running on port 80, and stop it?

Thanks,

Phoebe
Port 80 is usually HTTP, as in Apache or web services. Since you don't say what version/distro of Linux you're using, we'll have to guess as to how to stop it. Normally /etc/init.d/apache2 stop, as root.
 
Old 04-12-2010, 10:41 PM   #3
modprob
Member
 
Registered: Jul 2009
Location: Montreal
Distribution: Slackware
Posts: 35

Rep: Reputation: 17
You can see all tcp and udp connections with the pid using them with

Code:
netstat -tupn
 
Old 04-12-2010, 11:13 PM   #4
Phoebe77
LQ Newbie
 
Registered: Apr 2010
Posts: 6

Original Poster
Rep: Reputation: 0
Question

I tried,

Quote:
/etc/init.d/apache2 stop
And I get,

"Stopping web server: apache2apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName."

Running netstat -tupn, I get the following:

Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.194.128:48544 69.63.189.39:80 TIME_WAIT -
tcp 0 0 127.0.0.1:41402 127.0.0.1:80 TIME_WAIT -

I'm not sure what to kill, are the PID's 48544 and 41402?

Thanks again,

Phoebe
 
Old 04-12-2010, 11:19 PM   #5
modprob
Member
 
Registered: Jul 2009
Location: Montreal
Distribution: Slackware
Posts: 35

Rep: Reputation: 17
The TIME_WAIT status means that those connections are shutting down (because you shut down the apache server). If you run the netstat command again, they should disappear.
 
Old 04-12-2010, 11:27 PM   #6
Phoebe77
LQ Newbie
 
Registered: Apr 2010
Posts: 6

Original Poster
Rep: Reputation: 0
Question

Quote:
The TIME_WAIT status means that those connections are shutting down (because you shut down the apache server). If you run the netstat command again, they should disappear.
I checked it again and got the following:

Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name

So it looks like it did disappear. However, when I tried to run the program which wasn't working in the first place (since port 80 was in use) it still gave me an error. After recieveing the error, I threw another netstat -tupn command out and it looks like it came back:

"Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.194.128:48544 69.63.189.39:80 TIME_WAIT -
tcp 0 0 127.0.0.1:41402 127.0.0.1:80 TIME_WAIT -"

Any ideas what's going on here?
 
Old 04-12-2010, 11:42 PM   #7
modprob
Member
 
Registered: Jul 2009
Location: Montreal
Distribution: Slackware
Posts: 35

Rep: Reputation: 17
I suggest that you check your log file (/var/log/syslog or /var/log/messages;the location depends on your distribution) and the kernel messages (dmesg) to see if the failing program is giving any indication about the failure.
 
Old 04-12-2010, 11:57 PM   #8
Sayan Acharjee
Member
 
Registered: Feb 2010
Location: Chennai, India
Distribution: Manjaro
Posts: 624

Rep: Reputation: 64
Quote:
Originally Posted by Phoebe77 View Post
Hey all, I'm trying to stop all the services on port 80 by I'm not entirely sure how.

Infact, I don't really know what's running on port 80... I tried throwing a netstat -a in a prompt but I don't see port numbers anywhere so I can't figure out which PID to kill.

Any ideas on how I can figure out what's running on port 80, and stop it?

Thanks,

Phoebe
Why don't you block all services on 80 with iptables.
 
Old 04-13-2010, 01:14 AM   #9
bakdong
Member
 
Registered: Apr 2009
Posts: 214

Rep: Reputation: 44
the command you are looking for is

Code:
netstat -pan
-p shows program info
-a shows all listening sockets, not just open ones
-n shows port numbers instead of service names

for future reference, info is a very useful command:

Code:
info netstat
gives a lot of assistance. I know, I've just used it!

So

Code:
netstat -pan | grep :80
gives me this:

Code:
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      1470/httpd
which tells me that it is the httpd process that is running listening to port 80 (any IP to any IP) and it's that that I would need to shut down.

Code:
service httpd stop
 
Old 04-13-2010, 12:34 PM   #10
Phoebe77
LQ Newbie
 
Registered: Apr 2010
Posts: 6

Original Poster
Rep: Reputation: 0
Question

Here's what I get:

"root@bt:~# netstat -pan | grep :80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 6216/python
root@bt:~# service python stop
python: unrecognized service"

How come it sees python as an unrecognized service?
 
Old 04-13-2010, 12:48 PM   #11
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,689

Rep: Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972
Quote:
Originally Posted by Phoebe77 View Post
Here's what I get:

"root@bt:~# netstat -pan | grep :80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 6216/python
root@bt:~# service python stop
python: unrecognized service"

How come it sees python as an unrecognized service?
Because python is a programming language not a service. Chances are you've got some other sort of program running on this box, that's using port 80, and it's written in Python.
 
Old 04-13-2010, 12:56 PM   #12
Phoebe77
LQ Newbie
 
Registered: Apr 2010
Posts: 6

Original Poster
Rep: Reputation: 0
Question

EDIT: Figured it out!

Thanks alot guys.

Last edited by Phoebe77; 04-13-2010 at 02:03 PM.
 
Old 04-13-2010, 02:04 PM   #13
modprob
Member
 
Registered: Jul 2009
Location: Montreal
Distribution: Slackware
Posts: 35

Rep: Reputation: 17
Execute the following command as root. It might help you track down who launched the Python application. You can decide from there if you want to kill it.

Code:
pstree -p
 
Old 04-13-2010, 09:46 PM   #14
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,689

Rep: Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972Reputation: 7972
Quote:
Originally Posted by Phoebe77 View Post
EDIT: Figured it out!

Thanks alot guys.
What was the solution?? If you post it, everyone in the community can benefit.
 
Old 04-13-2010, 10:48 PM   #15
bakdong
Member
 
Registered: Apr 2009
Posts: 214

Rep: Reputation: 44
Quote:
Originally Posted by Phoebe77 View Post
Here's what I get:

"root@bt:~# netstat -pan | grep :80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 6216/python
root@bt:~# service python stop
python: unrecognized service"

How come it sees python as an unrecognized service?
Yes, sorry, I should have made it clearer that the output wouldn't necessarily be a service. The number appearing before that (6216 in this case) would be the process id, so you probably found out that you could just
Code:
kill 6216
to stop the program from running.

Code:
ps axu | grep 6216
would have shown the process and the user under which it was running
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Stopping Services rubadub Linux - Software 3 01-05-2007 12:39 PM
using iptable to close port instead of stopping services Emmanuel_uk Linux - Newbie 1 07-07-2005 03:54 AM
stopping services not in xinetd.d branden_burger Linux - Security 2 04-12-2005 08:34 PM
disabling stopping services ganxteh Fedora 6 12-17-2004 10:24 PM
stopping services? piglingz Linux - Software 3 06-24-2003 04:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration