查看路径所有中间目录的权限?

发布于 2024-12-14 07:53:00 字数 38 浏览 0 评论 0原文

是否有任何单个命令可以查看路径的所有中间目录的文件/目录权限?

Is there any single command to see the file/directory permissions of all the intermediate directories of a path?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

南街九尾狐 2024-12-21 07:53:00

您可以运行此代码:

lsd() { local v="$1"; while :; do v="${v%/*}"; [[ "$v" && ! -f "$v" ]] || break; ls -ld "$v"; done; }


lsd /usr/share/doc/acl/README
drwxr-xr-x 2 root root 4096 14 mai   12:28 /usr/share/doc/acl/
drwxr-xr-x 145 root root 4096  4 nov.  06:23 /usr/share/doc/
drwxr-xr-x 263 root root 12288  4 nov.  06:23 /usr/share/
drwxr-xr-x 14 root root 4096 28 oct.  22:47 /usr/

编辑:添加本地关键字

编辑2:最后一项错误已解决

You can run this code :

lsd() { local v="$1"; while :; do v="${v%/*}"; [[ "$v" && ! -f "$v" ]] || break; ls -ld "$v"; done; }


lsd /usr/share/doc/acl/README
drwxr-xr-x 2 root root 4096 14 mai   12:28 /usr/share/doc/acl/
drwxr-xr-x 145 root root 4096  4 nov.  06:23 /usr/share/doc/
drwxr-xr-x 263 root root 12288  4 nov.  06:23 /usr/share/
drwxr-xr-x 14 root root 4096 28 oct.  22:47 /usr/

Edit: added local keyword

Edit2: The last item error is resolved

素手挽清风 2024-12-21 07:53:00

这是一个完成这项工作的简单 while 循环:

f="$PWD"
while [ "$f" != "/" ]
do
    ls -ld "$f"
    f=$(dirname "$f")
done

Here is a simple while-loop which does the job:

f="$PWD"
while [ "$f" != "/" ]
do
    ls -ld "$f"
    f=$(dirname "$f")
done
绿光 2024-12-21 07:53:00

我知道有一个这样的命令,虽然它仍然工作得很好,但它已经有近 30 年的历史了。它应该用 sh 或 perl 重写,但这可行:

#!/bin/csh -f
# pup - print all dir perms from here up to root

if ( $#argv == 0 ) then
        set args = ( $cwd )
else
        set args = ( $argv )
endif

@ mult = ( $#argv > 1 )

foreach dir ( $args )
        if ( $mult ) echo "${dir}:"
        loop:
                if ( "$dir" == '' ) set dir = '/'
                ls -lLd "$dir"
                if ( "$dir" == '/' ) goto next_for
                set dir = ( `echo "$dir" | sed 's;/[^/]*$;;'` )
                goto loop
next_for:
end

下面是运行它的示例:

% pup /usr/src/usr.bin/vi/vi
drwxr-xr-x  3 root  wsrc  1024 May 29  2008 /usr/src/usr.bin/vi/vi
drwxr-xr-x  13 root  wsrc  512 Aug  7  2008 /usr/src/usr.bin/vi
drwxr-xr-x  229 root  wsrc  4096 Aug  7  2008 /usr/src/usr.bin
drwxrwxr-x  18 root  wsrc  512 Aug  7  2008 /usr/src
drwxr-xr-x  22 root  wheel  512 Jan 28  2010 /usr
drwxr-xr-x  21 root  wheel  1024 Aug 23  2010 /

它默认为 cwd。是的,输出并不漂亮。如果今天早上我有动力的话,也许我会重写它。


编辑

这是使用您的系统 ls 程序的重写。它在处理符号链接方面具有优势:

#!/usr/bin/env perl    
use strict;
use warnings;

use Cwd                qw( getcwd   abs_path );
use File::Basename      qw( dirname  );

sub ls { 0 == system("ls", "-lid", @_) }

@ARGV = getcwd() unless @ARGV;

for my $path (@ARGV) {
    if (-l $path) {
        ls($path);
        $path = abs_path($path);
    }
    while (ls($path) && $path !~ m{ \A /+ \z }x) {
        $path = dirname(abs_path($path));
    }
}

exit;

但我真的很讨厌 ls 格式化事物的方式。例如:

chthon(tchrist)% pup1 /dev/null /dev/zero /dev/tty /dev/stdin /dev/fd/0 ~ Mail
79283 crw-rw-rw-  1 root  wheel    2,   2 Nov  7 07:53 /dev/null
77953 drwxr-xr-x  3 root  wheel  22016 Oct 17 21:15 /dev
2 drwxr-xr-x  21 root  wheel  1024 Aug 23  2010 /
79284 crw-rw-rw-  1 root  wheel    2,  12 Oct 25  2008 /dev/zero
77953 drwxr-xr-x  3 root  wheel  22016 Oct 17 21:15 /dev
2 drwxr-xr-x  21 root  wheel  1024 Aug 23  2010 /
79280 crw-rw-rw-  1 root  wheel    1,   0 Nov  4 15:17 /dev/tty
77953 drwxr-xr-x  3 root  wheel  22016 Oct 17 21:15 /dev
2 drwxr-xr-x  21 root  wheel  1024 Aug 23  2010 /
79285 crw-rw-rw-  1 root  wheel   22,   0 Oct 25  2008 /dev/stdin
77953 drwxr-xr-x  3 root  wheel  22016 Oct 17 21:15 /dev
2 drwxr-xr-x  21 root  wheel  1024 Aug 23  2010 /
79308 crw-rw-rw-  1 root  wheel   22,   0 Oct 25  2008 /dev/fd/0
77954 dr-xr-xr-x  2 root  wheel  1024 Oct 25  2008 /dev/fd
77953 drwxr-xr-x  3 root  wheel  22016 Oct 17 21:15 /dev
2 drwxr-xr-x  21 root  wheel  1024 Aug 23  2010 /
1143296 drwxr-xr-x  197 tchrist  wheel  48128 Nov  7 07:53 /home/tchrist
2 drwxr-xr-x  15 root  wheel  512 Aug 12  2008 /home
2 drwxr-xr-x  21 root  wheel  1024 Aug 23  2010 /
1146538 lrwx------  1 root  wheel  5 Oct 23  2008 Mail -> /mail
2 drwxr-xr-x  134 tchrist  wheel  5120 Nov  7 07:43 /mail
2 drwxr-xr-x  21 root  wheel  1024 Aug 23  2010 /

明白我的意思吗?这是一个完全内置的。

自从我从 find2perl 窃取了 ls 例程以来,我花了很长时间才找到主要/次要宏。除了我测试的系统之外,它可能无法在其他系统上正确执行这些操作。

#!/usr/bin/env perl

use strict;
use warnings;

my $USE_SHELL_LS_PROGRAM = 0;

use Cwd                qw( getcwd   abs_path );
use File::Basename      qw( dirname  );

@ARGV = getcwd() unless @ARGV;

*ls = $USE_SHELL_LS_PROGRAM ? \&your_ls : \&my_ls;

for my $path (@ARGV) {
    if (-l $path) { 
        ls($path);
        $path = abs_path($path);
    }
    while (ls($path) && $path !~ m{ \A /+ \z }x) { 
        $path = dirname(abs_path($path));
    }
} 

exit;

########

sub your_ls {
    0 == system("ls", "-lid", @_);
} 

sub my_ls {

    use POSIX           qw( strftime );

    my $name = shift();

    my @rwx = qw(--- --x -w- -wx r-- r-x rw- rwx);

    my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
        $atime,$mtime,$ctime,$blksize,$blocks) = CORE::lstat($name) 
    or do {
        printf STDERR "$0: cannot lstat $name: $!\n";
        return 0;
    };

    my $pname = $name;

    $blocks
        or $blocks = int(($size + 1023) / 1024);

    my $perms = $rwx[$mode & 7];
    $mode >>= 3;
    $perms = $rwx[$mode & 7] . $perms;
    $mode >>= 3;
    $perms = $rwx[$mode & 7] . $perms;
    substr($perms, 2, 1) =~ tr/-x/Ss/ if -u _;
    substr($perms, 5, 1) =~ tr/-x/Ss/ if -g _;
    substr($perms, 8, 1) =~ tr/-x/Tt/ if -k _;
    if    (-f _) { $perms = '-' . $perms; }
    elsif (-d _) { $perms = 'd' . $perms; }
    elsif (-l _) { $perms = 'l' . $perms; $pname .= ' -> ' . readlink($name); }
    elsif (-c _) { $perms = 'c' . $perms; $size = sizemm($rdev); }
    elsif (-b _) { $perms = 'b' . $perms; $size = sizemm($rdev); }
    elsif (-p _) { $perms = 'p' . $perms; }
    elsif (-S _) { $perms = 's' . $perms; }
    else         { $perms = '?' . $perms; }

    printf "%9u %-10s %4d %-8s %-8s %8s %s %s\n",
            $ino,
                $perms,
                      $nlink,
                          user($uid),
                               group($gid),
                                    $size,
                                       strftime("%F %T", localtime $mtime),
                                            $pname;

    return 1;

}

sub sizemm {
    my $dev = shift;

    # these are almost always wrong:
    my $major = ($dev >> 8) & 0xff;
    my $minor = $dev & 0xff;

    # now fix the ones we know how to
    for ($^O) {

        if (/openbsd/) { 
            $major = ($dev >> 8) & 0xff;
            $minor = ($dev & 0xff) | (($dev & 0xffff0000) >> 8);
        }

        if (/darwin/) { 
            $major = ($dev >> 24) & 0xff;
            $minor = $dev & 0xffffff;
        }

        if (/solaris/) {
            $major = ($dev >> 18) & 0x3fff;
            $minor = $dev & 0x3ffff;
        }

        if (/linux/) {
            $major = (($dev >> 8) & 0xfff) | (($dev >> 32) & ~0xfff);
            $minor = ($dev & 0xff) | (($dev >> 12) & ~0xff);
        } 

    } 

    return sprintf("%3d, %3d", $major, $minor);

}

# cache user number to name conversions
sub user {
    use User::pwent;
    my $uid = shift;
    our %user;
    $user{$uid} = getpwuid($uid)->name || "#$uid"
        unless defined $user{$uid};
    return $user{$uid};
}

# cache group number to name conversions
sub group {
    use User::grent;
    my $gid = shift;
    our %group;
    $group{$gid} = getgrgid($gid)->name || "#$gid"
        unless defined $group{$gid};
    return $group{$gid};
}

例如:

chthon(tchrist)% pup2 /dev/null /dev/zero /dev/tty /dev/stdin /dev/fd/0 ~ Mail
    79283 crw-rw-rw-    1 root     wheel      2,   2 2011-11-07 07:34:47 /dev/null
    77953 drwxr-xr-x    3 root     wheel       22016 2011-10-17 21:15:55 /dev
        2 drwxr-xr-x   21 root     wheel        1024 2010-08-23 11:43:46 /
    79284 crw-rw-rw-    1 root     wheel      2,  12 2008-10-25 08:03:50 /dev/zero
    77953 drwxr-xr-x    3 root     wheel       22016 2011-10-17 21:15:55 /dev
        2 drwxr-xr-x   21 root     wheel        1024 2010-08-23 11:43:46 /
    79280 crw-rw-rw-    1 root     wheel      1,   0 2011-11-04 15:17:35 /dev/tty
    77953 drwxr-xr-x    3 root     wheel       22016 2011-10-17 21:15:55 /dev
        2 drwxr-xr-x   21 root     wheel        1024 2010-08-23 11:43:46 /
    79285 crw-rw-rw-    1 root     wheel     22,   0 2008-10-25 08:03:50 /dev/stdin
    77953 drwxr-xr-x    3 root     wheel       22016 2011-10-17 21:15:55 /dev
        2 drwxr-xr-x   21 root     wheel        1024 2010-08-23 11:43:46 /
    79308 crw-rw-rw-    1 root     wheel     22,   0 2008-10-25 08:03:51 /dev/fd/0
    77954 dr-xr-xr-x    2 root     wheel        1024 2008-10-25 08:03:51 /dev/fd
    77953 drwxr-xr-x    3 root     wheel       22016 2011-10-17 21:15:55 /dev
        2 drwxr-xr-x   21 root     wheel        1024 2010-08-23 11:43:46 /
  1143296 drwxr-xr-x  197 tchrist  wheel       48128 2011-11-07 04:16:49 .
        2 drwxr-xr-x   15 root     wheel         512 2008-08-12 16:51:23 /home
        2 drwxr-xr-x   21 root     wheel        1024 2010-08-23 11:43:46 /
  1146538 lrwx------    1 root     wheel           5 2008-10-23 14:50:24 Mail -> /mail
        2 drwxr-xr-x  134 tchrist  wheel        5120 2011-11-07 07:43:59 /mail
        2 drwxr-xr-x   21 root     wheel        1024 2010-08-23 11:43:46 /

I know of one such command, but it is almost 30 years old although it still works fine. It should be rewritten in sh or perl, but this works:

#!/bin/csh -f
# pup - print all dir perms from here up to root

if ( $#argv == 0 ) then
        set args = ( $cwd )
else
        set args = ( $argv )
endif

@ mult = ( $#argv > 1 )

foreach dir ( $args )
        if ( $mult ) echo "${dir}:"
        loop:
                if ( "$dir" == '' ) set dir = '/'
                ls -lLd "$dir"
                if ( "$dir" == '/' ) goto next_for
                set dir = ( `echo "$dir" | sed 's;/[^/]*$;;'` )
                goto loop
next_for:
end

And here is an example of running it:

% pup /usr/src/usr.bin/vi/vi
drwxr-xr-x  3 root  wsrc  1024 May 29  2008 /usr/src/usr.bin/vi/vi
drwxr-xr-x  13 root  wsrc  512 Aug  7  2008 /usr/src/usr.bin/vi
drwxr-xr-x  229 root  wsrc  4096 Aug  7  2008 /usr/src/usr.bin
drwxrwxr-x  18 root  wsrc  512 Aug  7  2008 /usr/src
drwxr-xr-x  22 root  wheel  512 Jan 28  2010 /usr
drwxr-xr-x  21 root  wheel  1024 Aug 23  2010 /

It default to the cwd. Yes, the output is not pretty. If I get motivated this morning, maybe I’ll rewrite it.


EDIT

Here’s a rewrite that uses your system ls program. It has advantages in how it deals with symlinks:

#!/usr/bin/env perl    
use strict;
use warnings;

use Cwd                qw( getcwd   abs_path );
use File::Basename      qw( dirname  );

sub ls { 0 == system("ls", "-lid", @_) }

@ARGV = getcwd() unless @ARGV;

for my $path (@ARGV) {
    if (-l $path) {
        ls($path);
        $path = abs_path($path);
    }
    while (ls($path) && $path !~ m{ \A /+ \z }x) {
        $path = dirname(abs_path($path));
    }
}

exit;

But I really hate the way ls formats things. For example:

chthon(tchrist)% pup1 /dev/null /dev/zero /dev/tty /dev/stdin /dev/fd/0 ~ Mail
79283 crw-rw-rw-  1 root  wheel    2,   2 Nov  7 07:53 /dev/null
77953 drwxr-xr-x  3 root  wheel  22016 Oct 17 21:15 /dev
2 drwxr-xr-x  21 root  wheel  1024 Aug 23  2010 /
79284 crw-rw-rw-  1 root  wheel    2,  12 Oct 25  2008 /dev/zero
77953 drwxr-xr-x  3 root  wheel  22016 Oct 17 21:15 /dev
2 drwxr-xr-x  21 root  wheel  1024 Aug 23  2010 /
79280 crw-rw-rw-  1 root  wheel    1,   0 Nov  4 15:17 /dev/tty
77953 drwxr-xr-x  3 root  wheel  22016 Oct 17 21:15 /dev
2 drwxr-xr-x  21 root  wheel  1024 Aug 23  2010 /
79285 crw-rw-rw-  1 root  wheel   22,   0 Oct 25  2008 /dev/stdin
77953 drwxr-xr-x  3 root  wheel  22016 Oct 17 21:15 /dev
2 drwxr-xr-x  21 root  wheel  1024 Aug 23  2010 /
79308 crw-rw-rw-  1 root  wheel   22,   0 Oct 25  2008 /dev/fd/0
77954 dr-xr-xr-x  2 root  wheel  1024 Oct 25  2008 /dev/fd
77953 drwxr-xr-x  3 root  wheel  22016 Oct 17 21:15 /dev
2 drwxr-xr-x  21 root  wheel  1024 Aug 23  2010 /
1143296 drwxr-xr-x  197 tchrist  wheel  48128 Nov  7 07:53 /home/tchrist
2 drwxr-xr-x  15 root  wheel  512 Aug 12  2008 /home
2 drwxr-xr-x  21 root  wheel  1024 Aug 23  2010 /
1146538 lrwx------  1 root  wheel  5 Oct 23  2008 Mail -> /mail
2 drwxr-xr-x  134 tchrist  wheel  5120 Nov  7 07:43 /mail
2 drwxr-xr-x  21 root  wheel  1024 Aug 23  2010 /

See what I mean? So here’s one that’s entirely built-in.

Took me forever to track down the major/minor macros, since the ls routine I stole from find2perl. It probably won’t do these right on other systems than the ones I test for.

#!/usr/bin/env perl

use strict;
use warnings;

my $USE_SHELL_LS_PROGRAM = 0;

use Cwd                qw( getcwd   abs_path );
use File::Basename      qw( dirname  );

@ARGV = getcwd() unless @ARGV;

*ls = $USE_SHELL_LS_PROGRAM ? \&your_ls : \&my_ls;

for my $path (@ARGV) {
    if (-l $path) { 
        ls($path);
        $path = abs_path($path);
    }
    while (ls($path) && $path !~ m{ \A /+ \z }x) { 
        $path = dirname(abs_path($path));
    }
} 

exit;

########

sub your_ls {
    0 == system("ls", "-lid", @_);
} 

sub my_ls {

    use POSIX           qw( strftime );

    my $name = shift();

    my @rwx = qw(--- --x -w- -wx r-- r-x rw- rwx);

    my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
        $atime,$mtime,$ctime,$blksize,$blocks) = CORE::lstat($name) 
    or do {
        printf STDERR "$0: cannot lstat $name: $!\n";
        return 0;
    };

    my $pname = $name;

    $blocks
        or $blocks = int(($size + 1023) / 1024);

    my $perms = $rwx[$mode & 7];
    $mode >>= 3;
    $perms = $rwx[$mode & 7] . $perms;
    $mode >>= 3;
    $perms = $rwx[$mode & 7] . $perms;
    substr($perms, 2, 1) =~ tr/-x/Ss/ if -u _;
    substr($perms, 5, 1) =~ tr/-x/Ss/ if -g _;
    substr($perms, 8, 1) =~ tr/-x/Tt/ if -k _;
    if    (-f _) { $perms = '-' . $perms; }
    elsif (-d _) { $perms = 'd' . $perms; }
    elsif (-l _) { $perms = 'l' . $perms; $pname .= ' -> ' . readlink($name); }
    elsif (-c _) { $perms = 'c' . $perms; $size = sizemm($rdev); }
    elsif (-b _) { $perms = 'b' . $perms; $size = sizemm($rdev); }
    elsif (-p _) { $perms = 'p' . $perms; }
    elsif (-S _) { $perms = 's' . $perms; }
    else         { $perms = '?' . $perms; }

    printf "%9u %-10s %4d %-8s %-8s %8s %s %s\n",
            $ino,
                $perms,
                      $nlink,
                          user($uid),
                               group($gid),
                                    $size,
                                       strftime("%F %T", localtime $mtime),
                                            $pname;

    return 1;

}

sub sizemm {
    my $dev = shift;

    # these are almost always wrong:
    my $major = ($dev >> 8) & 0xff;
    my $minor = $dev & 0xff;

    # now fix the ones we know how to
    for ($^O) {

        if (/openbsd/) { 
            $major = ($dev >> 8) & 0xff;
            $minor = ($dev & 0xff) | (($dev & 0xffff0000) >> 8);
        }

        if (/darwin/) { 
            $major = ($dev >> 24) & 0xff;
            $minor = $dev & 0xffffff;
        }

        if (/solaris/) {
            $major = ($dev >> 18) & 0x3fff;
            $minor = $dev & 0x3ffff;
        }

        if (/linux/) {
            $major = (($dev >> 8) & 0xfff) | (($dev >> 32) & ~0xfff);
            $minor = ($dev & 0xff) | (($dev >> 12) & ~0xff);
        } 

    } 

    return sprintf("%3d, %3d", $major, $minor);

}

# cache user number to name conversions
sub user {
    use User::pwent;
    my $uid = shift;
    our %user;
    $user{$uid} = getpwuid($uid)->name || "#$uid"
        unless defined $user{$uid};
    return $user{$uid};
}

# cache group number to name conversions
sub group {
    use User::grent;
    my $gid = shift;
    our %group;
    $group{$gid} = getgrgid($gid)->name || "#$gid"
        unless defined $group{$gid};
    return $group{$gid};
}

For example:

chthon(tchrist)% pup2 /dev/null /dev/zero /dev/tty /dev/stdin /dev/fd/0 ~ Mail
    79283 crw-rw-rw-    1 root     wheel      2,   2 2011-11-07 07:34:47 /dev/null
    77953 drwxr-xr-x    3 root     wheel       22016 2011-10-17 21:15:55 /dev
        2 drwxr-xr-x   21 root     wheel        1024 2010-08-23 11:43:46 /
    79284 crw-rw-rw-    1 root     wheel      2,  12 2008-10-25 08:03:50 /dev/zero
    77953 drwxr-xr-x    3 root     wheel       22016 2011-10-17 21:15:55 /dev
        2 drwxr-xr-x   21 root     wheel        1024 2010-08-23 11:43:46 /
    79280 crw-rw-rw-    1 root     wheel      1,   0 2011-11-04 15:17:35 /dev/tty
    77953 drwxr-xr-x    3 root     wheel       22016 2011-10-17 21:15:55 /dev
        2 drwxr-xr-x   21 root     wheel        1024 2010-08-23 11:43:46 /
    79285 crw-rw-rw-    1 root     wheel     22,   0 2008-10-25 08:03:50 /dev/stdin
    77953 drwxr-xr-x    3 root     wheel       22016 2011-10-17 21:15:55 /dev
        2 drwxr-xr-x   21 root     wheel        1024 2010-08-23 11:43:46 /
    79308 crw-rw-rw-    1 root     wheel     22,   0 2008-10-25 08:03:51 /dev/fd/0
    77954 dr-xr-xr-x    2 root     wheel        1024 2008-10-25 08:03:51 /dev/fd
    77953 drwxr-xr-x    3 root     wheel       22016 2011-10-17 21:15:55 /dev
        2 drwxr-xr-x   21 root     wheel        1024 2010-08-23 11:43:46 /
  1143296 drwxr-xr-x  197 tchrist  wheel       48128 2011-11-07 04:16:49 .
        2 drwxr-xr-x   15 root     wheel         512 2008-08-12 16:51:23 /home
        2 drwxr-xr-x   21 root     wheel        1024 2010-08-23 11:43:46 /
  1146538 lrwx------    1 root     wheel           5 2008-10-23 14:50:24 Mail -> /mail
        2 drwxr-xr-x  134 tchrist  wheel        5120 2011-11-07 07:43:59 /mail
        2 drwxr-xr-x   21 root     wheel        1024 2010-08-23 11:43:46 /
往日情怀 2024-12-21 07:53:00

在 Linux 上,util-linux 软件包包含 namei 命令。

$ namei -l /full/path/to/file

例子:

$ namei -l /var/lib/systemd/catalog/database
f: /var/lib/systemd/catalog/database
drwxr-xr-x root root /
drwxr-xr-x root root var
drwxr-xr-x root root lib
drwxr-xr-x root root systemd
drwxr-xr-x root root catalog
-rw-r--r-- root root database

On linux, the util-linux package contains the namei command.

$ namei -l /full/path/to/file

Example:

$ namei -l /var/lib/systemd/catalog/database
f: /var/lib/systemd/catalog/database
drwxr-xr-x root root /
drwxr-xr-x root root var
drwxr-xr-x root root lib
drwxr-xr-x root root systemd
drwxr-xr-x root root catalog
-rw-r--r-- root root database
茶花眉 2024-12-21 07:53:00

如果用户对正常 ls -l 中未包含的完整 ACL(访问列表)感兴趣,我们可以使用:

   p="/home/marom/downloads/db-derby-10.15.1.3-bin.tar.gz"; while [[ -n "$p" ]]; do getfacl -t  "$p"; p=${p%/*};done; getfacl -t "/"

输出为:
请注意,为 wheel 和 GUID 标志添加了组权限。

# file: /home/marom/downloads/db-derby-10.15.1.3-bin.tar.gz
# owner: marom
# group: marom
# flags: -s-
user::rw-
group::rw-                      #effective:rw-
group:wheel:rw-                 #effective:rw-
mask::rw-
other::r--

# file: /home/marom/downloads
# owner: marom
# group: marom
user::rwx
group::rwx
other::r-x

# file: /home/marom
# owner: marom
# group: marom
user::rwx
group::---
other::---

# file: /home
# owner: root
# group: root
user::rwx
group::r-x
other::r-x

# file: /
# owner: root
# group: root
user::r-x
group::r-x
other::r-x

If the user is interested in the full ACL (access list) not included in the normal ls -l we can use:

   p="/home/marom/downloads/db-derby-10.15.1.3-bin.tar.gz"; while [[ -n "$p" ]]; do getfacl -t  "$p"; p=${p%/*};done; getfacl -t "/"

The output is:
Notice added group permissions to wheel and GUID flag.

# file: /home/marom/downloads/db-derby-10.15.1.3-bin.tar.gz
# owner: marom
# group: marom
# flags: -s-
user::rw-
group::rw-                      #effective:rw-
group:wheel:rw-                 #effective:rw-
mask::rw-
other::r--

# file: /home/marom/downloads
# owner: marom
# group: marom
user::rwx
group::rwx
other::r-x

# file: /home/marom
# owner: marom
# group: marom
user::rwx
group::---
other::---

# file: /home
# owner: root
# group: root
user::rwx
group::r-x
other::r-x

# file: /
# owner: root
# group: root
user::r-x
group::r-x
other::r-x
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文