×
UNIX.COM Login
Username:
Password:  
Show Password






👤


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?

👤 Login to reply

 
Thread Tools Search this Thread Display Modes
    #1  
Old 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 09-13-2008
Franklin52's Unix or Linux Image
Franklin52 Franklin52 is offline
Registered User
 
Join Date: Feb 2007
Last Activity: 5 June 2018, 9:29 AM EDT
Location: The Netherlands
Posts: 7,747
Thanks: 139
Thanked 558 Times in 520 Posts
Try the stat command:


Code:
stat -c %U file

Regards
Sponsored Links
    #3  
Old 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 09-13-2008
Franklin52's Unix or Linux Image
Franklin52 Franklin52 is offline
Registered User
 
Join Date: Feb 2007
Last Activity: 5 June 2018, 9:29 AM EDT
Location: The Netherlands
Posts: 7,747
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...
Sponsored Links
    #5  
Old 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 09-13-2008
frank_rizzo frank_rizzo is offline Forum Advisor  
Resident BOFH
 
Join Date: Dec 2007
Last Activity: 20 January 2018, 4:18 PM EST
Posts: 1,155
Thanks: 5
Thanked 93 Times in 90 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 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
👤 Login to reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 02:30 PM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.