Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
09-26-2012, 11:31 AM
|
#1
|
LQ Newbie
Registered: Sep 2012
Posts: 4
Rep: 
|
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 ?
|
|
|
09-27-2012, 04:57 AM
|
#2
|
Member
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 558
Rep: 
|
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 .
|
|
|
09-27-2012, 06:34 AM
|
#3
|
Member
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 558
Rep: 
|
@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.)
|
|
|
09-27-2012, 10:51 AM
|
#4
|
LQ Newbie
Registered: Sep 2012
Posts: 4
Original Poster
Rep: 
|
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
|
|
|
09-27-2012, 08:05 PM
|
#5
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,430
|
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.
|
|
|
11-17-2015, 08:22 AM
|
#6
|
LQ Newbie
Registered: Nov 2015
Posts: 1
Rep: 
|
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.
|
11-17-2015, 08:26 AM
|
#7
|
LQ Addict
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316
|
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)
|
|
|
12-09-2020, 03:51 AM
|
#8
|
Member
Registered: Aug 2011
Location: Croatia
Distribution: Debian 10/Ubuntu 20.04
Posts: 64
Rep:
|
Quote:
Originally Posted by krappdirk
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
|
|
|
All times are GMT -5. The time now is 09:52 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|