#!/bin/sh #------------------------------------------------------------------------------------------------------------------ # Script: getperms # Usage : ./getperms /var or ./getperms to list current directory permissions. #------------------------------------------------------------------------------------------------------------------ ## getperms :: Shows permission in both format: numeric and alphabetical format: by: Raj D. getperm () { find $dir -exec ls -ld {} + | grep -v total |awk '{print $1" " $9}' |while read PERM FILE do NPERM=$(echo $PERM | sed 'y/rwx/421/' | echo $(fold -w 1) | awk '{U=$2+$3+$4;G=$5+$6+$7;O=$8+$9+$10}{print U G O}') echo "$NPERM $PERM $FILE" done ; } [ -d $1 ] && (echo "OK" ; dir=$1 ; getperm ) || (echo "$1 Not FOUND!! exiting!!.." ; exit 0 ) #------------------------------------------------------------------------------------------------------------------ Example/ output: # ./getperms /etc OK 755 drwxr-xr-x /etc 755 drwxr-xr-x /etc/initramfs-tools 644 -rw-r--r-- /etc/initramfs-tools/modules 755 drwxr-xr-x /etc/initramfs-tools/conf.d 644 -rw-r--r-- /etc/initramfs-tools/conf.d/resume 644 -rw-r--r-- /etc/initramfs-tools/update-initramfs.conf 644 -rw-r--r-- /etc/initramfs-tools/initramfs.conf 755 drwxr-xr-x /etc/initramfs-tools/hooks 755 drwxr-xr-x /etc/initramfs-tools/scripts 755 drwxr-xr-x /etc/initramfs-tools/scripts/init-bottom 755 drwxr-xr-x /etc/initramfs-tools/scripts/local-top --------------------------------------------------------------------------------------------------------------------------