LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-11-2020, 12:21 PM   #1
postcd
Member
 
Registered: Oct 2013
Posts: 527

Rep: Reputation: Disabled
iptables –uid-owner , how to discover this ID?


Hello,

a general question. If iptables manual page (man iptables) shows –uid-owner parameter:

Quote:
–uid-owner { USERNAME } : Matches if the packet was created by a process with the given effective USERNAME
How do i discover this UID?

I tried "id -u debian-tor", it shows an ID. I also tried third string/column from the "grep debian-tor /etc/group" output.

Which one is correct or if none, is there any command that returns the ID?

Or i am totally wrong and the parameter expect debian-tor instead of some number? (even if that is so, it may be interesting for some on how to discover ID behind the username)

Last edited by postcd; 01-11-2020 at 12:24 PM.
 
Old 01-11-2020, 12:30 PM   #2
jsbjsb001
Senior Member
 
Registered: Mar 2009
Location: Earth, unfortunately...
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881

Rep: Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063Reputation: 2063
Quote:
Originally Posted by postcd View Post
Hello,

a general question. If iptables manual page (man iptables) shows –uid-owner parameter:



How do i discover this UID?

I tried "id -u debian-tor", it shows an ID. I also tried third string/column from the "grep debian-tor /etc/group" output.

Which one is correct or if none, is there any command that returns the ID?

Or i am totally wrong and the parameter expect debian-tor instead of some number? (even if that is so, it may be interesting for some on how to discover ID behind the username)
/etc/passwd for one, the same command you posted, if you're talking about getting a UID for a user.

You could also do a Google search too...
 
Old 01-11-2020, 12:40 PM   #3
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,763

Rep: Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225Reputation: 2225
Quote:
–uid-owner { USERNAME } : Matches if the packet was created by a process with the given effective USERNAME
Emphasis added. The parameter wants a USERNAME, not a UID.
The first column returned by
Code:
ps aux
is the USERNAME running the process.
 
2 members found this post helpful.
Old 01-11-2020, 03:42 PM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,799

Rep: Reputation: 8002Reputation: 8002Reputation: 8002Reputation: 8002Reputation: 8002Reputation: 8002Reputation: 8002Reputation: 8002Reputation: 8002Reputation: 8002Reputation: 8002
Quote:
Originally Posted by postcd View Post
Hello,
a general question. If iptables manual page (man iptables) shows –uid-owner parameter:
Code:
–uid-owner { USERNAME } : Matches if the packet was created by a process with the given effective USERNAME
How do i discover this UID?

I tried "id -u debian-tor", it shows an ID. I also tried third string/column from the "grep debian-tor /etc/group" output. Which one is correct or if none, is there any command that returns the ID?

Or i am totally wrong and the parameter expect debian-tor instead of some number? (even if that is so, it may be interesting for some on how to discover ID behind the username)
After working with iptables for **SIX YEARS** now, why can you not apply what you've been told/learned to make any progress on your own? It took you longer to log in here and post a question, than it would have taken you to TRY IT, and see what happened and if it worked.

You AGAIN show no effort into looking up a solution, since just putting "linux iptables uid-owner example" into Google pulls up over 96,000 hits, with samples and explanations. VERY FIRST HIT:
https://www.linuxjournal.com/article/6091

Samples; examples; explanations, showing how both a match and non-match can be used. Why are you not able to do these things, despite being asked so many times? Or put "how to find UID in linux" into Google?

Last edited by TB0ne; 01-11-2020 at 03:44 PM.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] iptables "-m owner --uid-owner" option Besl621 Linux - Security 4 09-25-2015 10:13 AM
Effective UID and Real UID Milosevic Linux - Newbie 1 01-06-2007 10:41 AM
Changing the UID of a Physical Volume to a specific UID jambraun Linux - Newbie 2 02-09-2006 02:34 PM
FREEBSD5.3 platform: PHP setcookie() successful, but $uid = $_COOKIE['uid']; fail tclwp Programming 1 03-30-2005 08:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:24 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