Interview Question

Software Engineer Interview(Student Candidate)

If you had to change permissions to read/write all

  recursively in the unix terminal, how would you do it?
Answer

Interview Answer

6 Answers

0

chmod -r 777 file/path/here

Interview Candidate on Nov 9, 2009
0

actually, the correct answer is

chmod -R 766 filename

Tom on Nov 21, 2009
5

For crying out loud, people, check your answers:

chmod -R 666 [pathname]

where:

chmod is the command

-R is the flag for recursive

666 is the octal permission for read+write for user/group/other

[pathname] is the item to apply the permission changes to. It should be a directory (not a file) as the recursive option has no meaning on a simple file.

A "7" adds execute permission, which is not what was stated.

Tim on Jan 13, 2010
8

Be careful - chmod -R 666 will remove the execute bit from directories below the one you're in. That will mean that for example the directory listing command will fail.

As stated, the question doesn't ask you to avoid ruining your directory permissions - but it does ask "how you would do it".

I use this, which makes sure to only change the permissions of files:

find . -type f -exec chmod 0666 \{} \;

Sarah on Jan 13, 2010
12

As Sarah commented, you don't want to remove execute permissions from directories, just add read and write for all users. The other way to do this without using the 'find' program is:

chmod -R a+rw /path

Brooks on Jan 18, 2010
0

My answer: use an iphone.

Anonymous on Jan 12, 2011

Add Answers or Comments

To comment on this question, Sign In with Facebook or Sign Up