LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-31-2012, 09:56 PM   #1
Huamin
Member
 
Registered: May 2011
Posts: 562

Rep: Reputation: 12
To find it out


Good day all,
I want to find out one log file within “/opt/teamviewer”. How?

[root@localhost 5]# find / -user vivek -name "*.log"
find: invalid argument `vivek' to `-user'

Regards,
 
Old 01-31-2012, 10:09 PM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
Does user vivek exist? You can check by
Code:
grep '^vivek:' /etc/passwd
 
1 members found this post helpful.
Old 01-31-2012, 10:59 PM   #3
Huamin
Member
 
Registered: May 2011
Posts: 562

Original Poster
Rep: Reputation: 12
Good day,
thanks. Does this mean there is no .log file inside “/opt/teamviewer”?
[root@localhost teamviewer]# find /opt/teamviewer -user root -name "*.log"
[root@localhost teamviewer]#

Regards,
 
Old 01-31-2012, 11:12 PM   #4
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
Catkin, actually that grep will not work when LDAP is used.

The correct way to find out if a user exists is to run
Code:
id -un username
If the user exists, it will output the username (same!). If the user does not exist, it will report an error.

(There is no group equivalent of id although the C libraries do provide the getgrnam() interface that provides the correct information, so checking if a group exists is trickier in a shell script. The way I'd do it, is create a temporary directory (with no access to anybody, mode 0). Then, if env LANG=C LC_ALL=C chgrp 'group' dir 2>&1 returns something that contains invalid group, then the group does not exist. It may return either nothing or an error, depending on whether the user is a member of that group or not. The directory is obviously removed immediately afterwards, and you do need to do this in a directory where you have write access, of course.)
 
1 members found this post helpful.
Old 02-01-2012, 12:06 AM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198Reputation: 1198
Quote:
Originally Posted by Nominal Animal View Post
Catkin, actually that grep will not work when LDAP is used.
Thanks for pointing it out
 
Old 02-01-2012, 12:12 AM   #6
Huamin
Member
 
Registered: May 2011
Posts: 562

Original Poster
Rep: Reputation: 12
Thanks. Does the output from find above show no log file in that?
 
Old 02-01-2012, 03:06 AM   #7
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
If user vivek exists, then yes, find / -user vivek will report all files owned by user vivek (whose paths are visible to the current user).

If user vivek does not exist, you get an error message, either something like find: `vivek' is not the name of a known user or find: invalid argument `vivek' to `-user' depending on the find implementation (and locale, of course).

In your case, there is no user named vivek on the system you ran the command on.

Last edited by Nominal Animal; 02-01-2012 at 03:07 AM.
 
  


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
[SOLVED] Find URL in Debian package index via awk/sed (=find a line, then search from there) maddes.b Linux - Software 11 06-28-2013 07:37 AM
find hidden files from wild card path using 'find' nagendrar Linux - Newbie 5 10-13-2011 10:48 PM
[GNU find version 4.2.27] find: paths must precede expression mechagojira Linux - Newbie 3 07-06-2011 05:34 AM
Find with -exec argument - not giving proper output..how to find... hinetvenkat Linux - Server 4 01-25-2010 06:19 AM
Find/grep/wc command to find matching files, print filename and word count dbasch Linux - Newbie 10 09-14-2009 05:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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