Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

See permissions of all intermediate directories of a path?

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

like image 523
xyz Avatar asked Oct 28 '25 03:10

xyz


2 Answers

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

like image 194
Gilles Quenot Avatar answered Oct 30 '25 02:10

Gilles Quenot


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

f="$PWD"
while [ "$f" != "/" ]
do
    ls -ld "$f"
    f=$(dirname "$f")
done
like image 24
dogbane Avatar answered Oct 30 '25 02:10

dogbane



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!