Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

X home dir permissions: drwxr-xr-x
Y home dir permissions: drwxr-x--x

So my question is, how can i convert drwxr-x--x to a chmod/chown command so I can put the same permissions that Y has on his home dir, on X's home dir?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

You can use chmod's --referenceoption. From man chmod:

   --reference=RFILE
          use RFILE's mode instead of MODE values

So, for example:

$ l -l
total 8.0K
drwx------ 2 terdon terdon 4.0K Sep 11 20:40 bar
drwxr-xr-x 2 terdon terdon 4.0K Sep 11 20:40 foo
$ chmod --reference foo bar
$ ls -l 
total 8.0K
drwxr-xr-x 2 terdon terdon 4.0K Sep 11 20:40 bar
drwxr-xr-x 2 terdon terdon 4.0K Sep 11 20:40 foo
share|improve this answer
    
Sorry for late response, but thanks! This was what i was looking for! –  qwerty1911 Oct 26 '13 at 9:54
add comment

There is always a way :)

$ ll  | tr 'rwx' 421 | 
       awk '
       {
        split($0,a,""); 
        printf "%d%d%d\n", a[2]+a[3]+a[4], a[5]+a[6]+a[7], a[8]+a[9]+a[10] 
       }' 
020
644
644
755

$ ll
total 2K
-rw-r--r--  1 1K 2013-09-13 03:44 alphabet
-rw-r--r--  1 1K 2013-09-13 03:37 input
drwxr-xr-x+ 1 0K 2013-09-13 04:02 moo
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.