fro*_*boo 228
你可以这样做:第一种方式:
ls -l /path/to/file
Run Code Online (Sandbox Code Playgroud)
*ls -l 输出中的第三个字段是用户,第四个字段是组
方式二:
统计/路径/到/文件
$ 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
Run Code Online (Sandbox Code Playgroud)
Uid 字段中的 razvan 是所有者/用户,Gid 字段中的 razvan 是组。8-|
第三种方式:仅获取具有 stat 的用户和组:
stat -c "%U %G" /path/to/file
Run Code Online (Sandbox Code Playgroud)
Ora*_*Tux 26
ls使用-l标志运行以显示当前目录(或特定命名目录)中文件和目录的所有者和组所有者。
~$ ls -l
drwxr-xr-x 2 owner group 4096 Aug 12 19:12 Desktop
...Run Code Online (Sandbox Code Playgroud)
~$ ls -l /home/username
drwxr-xr-x 2 owner group 4096 Aug 12 19:12 Desktop
...Run Code Online (Sandbox Code Playgroud)
ls使用-l和-d标志运行以显示有关当前目录本身(或有关特定命名目录)的信息:
~$ ls -ld
drwxr-xr-x 2 owner group 4096 Aug 12 19:12 .Run Code Online (Sandbox Code Playgroud)
~$ ls -ld ~/Desktop
drwxr-xr-x 2 owner group 4096 Aug 12 19:12 DesktopRun Code Online (Sandbox Code Playgroud)
Sta*_*mer 23
要获取您需要的目录的所有者和组
ls -ld /path/to/folder
Run Code Online (Sandbox Code Playgroud)
否则,您将获得目录内容的属性。