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, |
Does user vivek exist? You can check by
Code:
grep '^vivek:' /etc/passwd |
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, |
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 (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.) |
Quote:
|
Thanks. Does the output from find above show no log file in that?
|
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. |
All times are GMT -5. The time now is 11:09 AM. |