Sponsored Content
Top Forums Shell Programming and Scripting Question on file owner name representation Post 302425559 by Corona688 on Friday 28th of May 2010 12:25:54 PM
Old 05-28-2010
Quote:
Originally Posted by Arunprasad
I thought the same but in my case, all user s are LDAP and not maintained locally. So how system determines that this user has been deleted and let represent the userid as number. And for your information, still many user directories/files are showing properly with userid/owner name in its properties.

Thanks a lot for your time! Please advise.
It's abstracted behind the getpwent() call and its related calls, looks like:
Code:
GETPWENT(3)                Linux Programmer's Manual               GETPWENT(3)



NAME
       getpwent, setpwent, endpwent - get password file entry

SYNOPSIS
       #include <sys/types.h>
       #include <pwd.h>

       struct passwd *getpwent(void);

       void setpwent(void);

       void endpwent(void);

   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

       getpwent(), setpwent(), endpwent(): _BSD_SOURCE || _SVID_SOURCE ||
       _XOPEN_SOURCE > = 500

DESCRIPTION
       The getpwent() function returns a pointer to a structure containing the
       broken-out  fields  of  a  record from the password database (e.g., the
       local password file /etc/passwd, NIS, and LDAP).  The first time it  is
       called  it  returns  the first entry; thereafter, it returns successive
       entries.

...

So ls doesn't reach in and grab login names from /etc/passwd manually, it just calls getpwent() from glibc, which is capable of getting login info from any valid sources. Finding no corresponding UID in either, ls just prints the UID/GID.

Didn't know getpwent() did that. That's a pretty good reason to use these functions instead of just parsing /etc/passwd yourself!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to change the owner of the file?

How to change the owner of the file? Can I change the owner of file/ files? I am user and not admin.(not logged as root) (1 Reply)
Discussion started by: redlotus72
1 Replies

2. UNIX for Dummies Questions & Answers

change owner of a file

im running into changing the ownership of a file. I am trying to change the ownership to "system", but it doesn't want to work. I sudo chown system /preferences.plist Password: chown: system: Invalid argument is there a way to read the ownership of a file, something like read chown... (3 Replies)
Discussion started by: CBarraford
3 Replies

3. Solaris

Owner of file gets 'not owner' error for chgrp

Hi Folks, I know that changing users and groups is pretty basic admin, but this one has got me stumped. When I try to change the group of a file for which I am the owner for, it still gives me a 'Not owner' error. For example, when I am logged in as 'webadmin', I have the following file: ... (4 Replies)
Discussion started by: brizrobbo
4 Replies

4. Shell Programming and Scripting

determine owner of a file

Hello, I am on a mission to determine the user of file. I have used the ls -l command but it displays permission, link, user, group, etc, but I just want to display just the name of user of a specified file. Many thanks (4 Replies)
Discussion started by: unibboy
4 Replies

5. UNIX for Advanced & Expert Users

Is there a command to get the owner of a file?

At the moment I'm just using `ls -o` (with `cut`), but `ls` is obviously giving me a lot more output than just the file owner. (9 Replies)
Discussion started by: Bilge
9 Replies

6. Shell Programming and Scripting

getting file owner in perl

hi, how can I get the owner of the file ( not uid) on windows plaform. "getpwuid" is not working on windows. I knw it works on unix. Thanks. (2 Replies)
Discussion started by: shellwell
2 Replies

7. UNIX for Advanced & Expert Users

How UNIX admin set up this? how files of 744 of other owner can be removed by another owner?

Hi all, We have some files are under 744 permissions and the the owner is say owner1 and group1. Now we have another user owner2 of group2, owner2 can remove files of the owner1 and the permission of those files are 744, unix admin told us he did some config at his side so we can do that. ... (14 Replies)
Discussion started by: TheGunMan
14 Replies

8. Cybersecurity

Change file owner

What i did: - logged in with acc1 and created a new user acc2 commands used: useradd and passwd. - Then i logged in acc2. but all the files are owned by acc1. Issue: I try to change the owner of the files using chown command . But it gives me a error message. All i want to do is... (13 Replies)
Discussion started by: TotallyConfused
13 Replies

9. Solaris

Privileges : modify dir/file owner by other that's not owner

i need to do the following operations in solaris 10: 1.change owner and group owner for files which are not owned by the current user and user group 2.to can delete files in the /tmp directory which are not of the current user 3. allow to a standard user the deletion of files in the /tmp... (1 Reply)
Discussion started by: sirmark
1 Replies

10. UNIX and Linux Applications

Graphical Representation of mpstat.out file

hi everyone, We've generated mpstat.out file monitoring cpu utilization and the file is ready now.Wanted to generate graphical charts for the same output data. Can anyone pleas suggest tool for the same.? (1 Reply)
Discussion started by: Kathraji
1 Replies
GETPWENT(3)						     Linux Programmer's Manual						       GETPWENT(3)

NAME
getpwent, setpwent, endpwent - get password file entry SYNOPSIS
#include <pwd.h> #include <sys/types.h> struct passwd *getpwent(void); void setpwent(void); void endpwent(void); DESCRIPTION
The getpwent() function returns a pointer to a structure containing the broken out fields of a line from /etc/passwd. The first time it is called it returns the first entry; thereafter, it returns successive entries. The setpwent() function rewinds the file pointer to the beginning of the /etc/passwd file. The endpwent() function closes the /etc/passwd file. The passwd structure is defined in <pwd.h> as follows: struct passwd { char *pw_name; /* user name */ char *pw_passwd; /* user password */ uid_t pw_uid; /* user id */ gid_t pw_gid; /* group id */ char *pw_gecos; /* real name */ char *pw_dir; /* home directory */ char *pw_shell; /* shell program */ }; RETURN VALUE
The getpwent() function returns the passwd structure, or NULL if there are no more entries or an error occurs. ERRORS
ENOMEM Insufficient memory to allocate passwd structure. FILES
/etc/passwd password database file CONFORMING TO
SVID 3, BSD 4.3 SEE ALSO
fgetpwent(3), getpwnam(3), getpwuid(3), getpw(3), putpwent(3), passwd(5) GNU
1996-05-27 GETPWENT(3)
All times are GMT -4. The time now is 04:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy