1

Can anyone tell me how to set a directory only in read/write mode as below?

-rw-rw-r--

I tried with 640,644 but I am able to achieve...

  • 3
    Usually, one does not set a directory to a permission that does not include the appropriate execute bit(s) set. "Execute" on a directory means approximately "access the contents"; "read" on a directory likewise means "enumerate the contents". If anything, on directories, execute without read is a lot more common than read without execute. – a CVn Jul 27 '13 at 11:13
1

Here,

r - 4
w - 2
x - 1

For setting it as -rw-rw-r--, you need to run,

$ chmod 0664 <dir-name>
0

If you need -rw-rw-r--try to set mode 664.

  • No if set 664 i am getting drw-rwSr-- – user1660325 Jul 27 '13 at 10:45
  • @user1660325 rw-rwSr-- is 2664. Are you absolutely sure that you are using exactly 644? If so, you may want to try 0644 instead. (Note that 2664 doesn't have any execute bits set.) – a CVn Jul 27 '13 at 11:17
  • 0644 also no luck its giving drw-r-Sr--. – user1660325 Jul 27 '13 at 12:07
  • @user1660325: Try chmod ug=rw,o=r <directory>. – user26112 Jul 27 '13 at 15:58
0

Here, you can use this technique to change the access mode of directory/file.

4 - read
2 - write
1 - execute

So, if you want only read and write permission the you can go for 4+2 = 6 (read/write) According to you question the command is

# chmod 664 <file/directory-name>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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