Unix/Linux Go Back    


UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

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

UNIX for Advanced & Expert Users


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 09-13-2008
Bilge Bilge is offline
Registered User
 
Join Date: Sep 2008
Last Activity: 12 July 2009, 7:47 PM EDT
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Sponsored Links
    #2  
Old Unix and Linux 09-13-2008
Franklin52's Unix or Linux Image
Franklin52 Franklin52 is offline Forum Staff  
Moderator
 
Join Date: Feb 2007
Last Activity: 5 May 2017, 7:24 AM EDT
Location: The Netherlands
Posts: 7,746
Thanks: 139
Thanked 558 Times in 520 Posts
Try the stat command:

Code:
stat -c %U file

Regards
Sponsored Links
    #3  
Old Unix and Linux 09-13-2008
Bilge Bilge is offline
Registered User
 
Join Date: Sep 2008
Last Activity: 12 July 2009, 7:47 PM EDT
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks a lot, I didn't know about the `stat` command, but I was sure something like this must exist. The operators of the official Ubuntu support channel told me that parsing `ls` was the only way, haha.
    #4  
Old Unix and Linux 09-13-2008
Franklin52's Unix or Linux Image
Franklin52 Franklin52 is offline Forum Staff  
Moderator
 
Join Date: Feb 2007
Last Activity: 5 May 2017, 7:24 AM EDT
Location: The Netherlands
Posts: 7,746
Thanks: 139
Thanked 558 Times in 520 Posts
Quote:
Originally Posted by Bilge View Post
Thanks a lot, I didn't know about the `stat` command, but I was sure something like this must exist. The operators of the official Ubuntu support channel told me that parsing `ls` was the only way, haha.
So, stay tuned here... Linux
Sponsored Links
    #5  
Old Unix and Linux 09-13-2008
Bilge Bilge is offline
Registered User
 
Join Date: Sep 2008
Last Activity: 12 July 2009, 7:47 PM EDT
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Well yes, I get the impression that people actually know what they're talking about here and are not in the habit of spreading misinformation.
Sponsored Links
    #6  
Old Unix and Linux 09-13-2008
frank_rizzo frank_rizzo is offline Forum Advisor  
Resident BOFH
 
Join Date: Dec 2007
Last Activity: 28 July 2016, 2:18 PM EDT
Posts: 1,152
Thanks: 4
Thanked 92 Times in 89 Posts
Quote:
Originally Posted by Bilge View Post
Well yes, I get the impression that people actually know what they're talking about here and are not in the habit of spreading misinformation.
fyi - the stat command is not standard and does not exist on all UNIX variants. for example - AIX uses the istat command.
Sponsored Links
    #7  
Old Unix and Linux 09-13-2008
Bilge Bilge is offline
Registered User
 
Join Date: Sep 2008
Last Activity: 12 July 2009, 7:47 PM EDT
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Well yes I had noticed that it resided in /usr/bin.
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
rm/mv command - not owner tostay2003 Shell Programming and Scripting 2 03-09-2011 10:06 AM
command to find the owner of a db dvah UNIX for Advanced & Expert Users 2 06-24-2010 03:39 AM
How UNIX admin set up this? how files of 744 of other owner can be removed by another owner? TheGunMan UNIX for Advanced & Expert Users 14 01-18-2010 09:04 AM
How to know owner of a file without ls and find command swat UNIX for Dummies Questions & Answers 1 12-03-2008 06:05 AM
Owner of file gets 'not owner' error for chgrp brizrobbo Solaris 4 12-18-2007 04:30 PM



All times are GMT -4. The time now is 11:46 PM.