Answers:
您可以这样做:第一种方式:
ls -l /path/to/file
* ls -l输出中的第三个字段是用户,第四个字段是组
第二种方式:
stat /路径/到/文件
$ stat py
  File: `py'
  Size: 32              Blocks: 8          IO Block: 4096   regular file
Device: 801h/2049d      Inode: 429064      Links: 1
Access: (0777/-rwxrwxrwx)  Uid: ( 1000/  razvan)   Gid: ( 1000/  razvan)
Access: 2012-07-27 17:49:05.682143441 +0300
Modify: 2012-07-01 03:58:02.848540175 +0300
Change: 2012-08-01 21:12:57.129819212 +0300
Uid字段中的razvan是所有者/用户,Gid字段中的razvan是组。8 |
第三种方式:仅使用stat获取用户和组:
stat -c "%U %G" /path/to/file
stat -f "%u %g" /path/to/file
                    运行ls与-l标志,以显示文件和目录的当前目录的所有者和组所有者(或特定命名的目录)。
~$ ls -l
drwxr-xr-x  2 owner group 4096 Aug 12 19:12 Desktop
...~$ ls -l /home/username
drwxr-xr-x  2 owner group 4096 Aug 12 19:12 Desktop
...ls使用-l和-d标志运行以显示有关当前目录本身(或有关特定命名目录)的信息:
~$ ls -ld
drwxr-xr-x  2 owner group 4096 Aug 12 19:12 .~$ ls -ld ~/Desktop
drwxr-xr-x  2 owner group 4096 Aug 12 19:12 Desktop
ll为ls -l