Show current folder permission from /, useful for debugging ssh key permission

awk 'BEGIN{dir=DIR?DIR:ENVIRON["PWD"];l=split(dir,parts,"/");last="";for(i=1;i<l+1;i++){d=last"/"parts[i];gsub("//","/",d);system("ls -ld \""d"\"");last=d}}'
Handled all within awk. Takes the value from $PWD and constructs directory structures and runs commands against them. The gsub() call is not necessary, but added for better visibility. If a variable DIR is given on the awk command-line, then that directory is used instead: awk -vDIR=$HOME/.ssh 'BEGIN{dir=DIR?...}'
Sample Output
drwxr-xr-x 22 root root 4096 2009-10-21 23:30 /
drwxr-xr-x 3 root root 4096 2009-10-20 13:33 /home
drwxr-xr-x 54 luser luser 4096 2009-10-22 09:48 /home/luser

By: arcege
2009-10-22 16:28:07

1 Alternatives + Submit Alt

What Others Think

As far as I can tell, command as given is missing a few essentials: the awk command and a set of enclosing single quotes.
bsussman · 631 weeks and 1 day ago
Doh! What happens when you copy and paste the wrong parts. I also modified the system call to quote the directory in case of special characters, like spaces.
arcege · 631 weeks and 1 day ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: