LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 09-26-2012, 11:31 AM   #1
sterin501
LQ Newbie
 
Registered: Sep 2012
Posts: 4

Rep: Reputation: Disabled
How to remove warning when netstat -anp used by non-root user ?


Hi ,

Currently I am getting warning when netstat -anp is used by non admin user , how to remove that ?

[sterin@sterin-lap ~]$ netstat -anp | grep 7001
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)


I dont want that warning message . Is there any way to remove it ?
 
Old 09-27-2012, 04:57 AM   #2
jsaravana87
Member
 
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 558
Blog Entries: 5

Rep: Reputation: Disabled
hI

Quote:
Currently I am getting warning when netstat -anp is used by non admin user , how to remove that ?
Enable sudo permission for user sterin .
 
Old 09-27-2012, 06:34 AM   #3
jsaravana87
Member
 
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 558
Blog Entries: 5

Rep: Reputation: Disabled
@Hendri2201 --I read the link you had posted for sterin501.The link you had posted is something unrevelent to these topic.Dont mess the user with irrevelant post


sterin is facing out problem since he does not have root priviledge or (sudo priviledge) to execute the below command .

[sterin@sterin-lap ~]$ netstat -anp | grep 7001
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
 
Old 09-27-2012, 10:51 AM   #4
sterin501
LQ Newbie
 
Registered: Sep 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
arun,

I am running command from script . If i give sudo , I have to enter password for it . Script wont work properly then .

Thanks
Sterin
 
Old 09-27-2012, 08:05 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,430

Rep: Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786Reputation: 2786
If you really need to, you can specify NOPASSWD in sudo, but definitely list the specific cmds you want enabled; don't use 'ALL'.
You could also try adding the user to the group that owns netstat, or try an ACL for a more fine-tuned approach.
 
Old 11-17-2015, 08:22 AM   #6
krappdirk
LQ Newbie
 
Registered: Nov 2015
Posts: 1

Rep: Reputation: Disabled
Probably the only way is to just throw away the std error:

Code:
 netstat -antp 2>/dev/null | grep <port>
Be aware that this suppresses all errors. So be sure you don't expect any ones that might be of interest. For me this is just fine

HTH,

Dirk
 
1 members found this post helpful.
Old 11-17-2015, 08:26 AM   #7
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
You could try setuid for netstat. I don't know if this poses a security risk though.
Code:
chmod u+s /usr/bin/netstat
(might be /bin/netstat, not sure)
 
Old 12-09-2020, 03:51 AM   #8
resolv_25
Member
 
Registered: Aug 2011
Location: Croatia
Distribution: Debian 10/Ubuntu 20.04
Posts: 64

Rep: Reputation: 15
Quote:
Originally Posted by krappdirk View Post
Probably the only way is to just throw away the std error:

Code:
 netstat -antp 2>/dev/null | grep <port>
Be aware that this suppresses all errors. So be sure you don't expect any ones that might be of interest. For me this is just fine

HTH,

Dirk
Thanks, old question but still valid.
For example, I just need to check with non privileged user (zabbix monitor) if some port is open and send data to the main monitor server.
This works just fine (1 is true, 0 is false):
Code:
 netstat -antp 2>/dev/null | grep :443 && echo 1 || echo 0
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
netstat -anp is not giving the pid/process_name! vamsi9042 Linux - Networking 4 05-29-2018 03:38 PM
Remove user from root group JJJCR Linux - Newbie 5 09-05-2011 08:36 PM
Netstat issues 'warning, got duplicate tcp line' English_Man Linux - Networking 5 04-13-2009 03:07 AM
cannot remove netstat SPEEDEX Linux - Newbie 3 08-13-2007 08:20 AM
warning:user mock build doesn't exist-using root ??? IndianMaverick Fedora 1 09-30-2006 07:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 09:52 AM.

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