Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .