Operating System - HP-UX
1838614 Members
4288 Online
110128 Solutions
New Discussion

owner field replaced by number in the output of $ls -l

 
SOLVED
Go to solution
Shivkumar
Super Advisor

owner field replaced by number in the output of $ls -l

Hi,

I have noticed sometimes in the output of $ll or $ls -l command the owner field is replaced by some number instead of owner name.

I have observed this on sun solaris also.

Appreciate if someone can clarify this.

Thanks,
Shiv
4 REPLIES 4
Hemmetter
Esteemed Contributor
Solution

Re: owner field replaced by number in the output of $ls -l

Hi Shiv,

There is no user in /etc/passwd with the uid the file has. The corresponding user may have been deleted and some files left over.

Otherwise the file came via tar-file/backup from another machine to the system.

Or the filesystem may be nfs mounted and the server file owner has now corresponding user (uid) on the client.

Or in some environments may "ls" may be aliased to have an -n option.


rgds
HGH

sajeer_2
Regular Advisor

Re: owner field replaced by number in the output of $ls -l



As Hemmetter mentioned,when you do a NFS mount or untar files in to the system,same User ID and Group ID of the file or directory may not be there in the /etc/passwd of your system (for any of the user).In that case it is showing the numerical user ID and Group ID instead of username and group name.


Bill Hassell
Honored Contributor

Re: owner field replaced by number in the output of $ls -l

All files and directories have two numbers for ownership, the userID and the groupID. This is all there is for ownership, but the ls command will make the information more usefr friendly by searching through the passwd and group files to replace the number with a name. You can turn off this feature with ls -ln or ll -n. Note that numbers can be used with chown and chgrp but as you might expect, it is a bit inconvenient. As mentioned, shared filesystems will have 'foreign' numbers (they were not assigned on the local system) so the user/group names will not be meaningful. Similarly, if you install a (poorly designed) package, it may assign user/group numbers that are not meaningful. You can change these to more useful IDs.


Bill Hassell, sysadmin
James R. Ferguson
Acclaimed Contributor

Re: owner field replaced by number in the output of $ls -l

Hi Shiv:

As mentioned, the absence of a mapping of the numeric id (uid or gid) means that the raw numeric value is reported by 'ls' by default.

If you would like to find all "foreign" files, you can do:

# cd /path -xdev && find . -nouser -o -nogroup | xargs ls -l

...this will report all files and directories in /path that lack a "valid" user or group identification

Regards!

...JRF...