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.

I'm thinking of doing 'chmod 700 -R ~'. Can it be dangerous? What can happen what I don't expect? Also, is there any way to keep all files on $HOME to be -rwx------?

share|improve this question
    
Why not just chmod go-rx ~? No need to recurse. (FWIW, some systems might not like it, e.g. when users publish web sites using ~/Sites or ~/www or something like that -- then the http server needs access to ~ -- but you'd know it if you did that). –  Daniel Beck Oct 30 '13 at 22:05
    
Of course, if somebody made a copy of one of Anon’s world-readable files yesterday, there’s no way of recovering it. But what if somebody made a hard link to one of his files? chmoding the home directory won’t affect that; he needs recursion to make the linked file private. –  Scott Oct 30 '13 at 22:33
add comment

1 Answer

The main problem I can think of is that that command will set the execute bit on all files, even those that aren’t executable.  So, if you have a file called foo, and someday you want to do cat foo or print foo and you accidentally type just foo, the shell will try to execute foo; i.e., interpret it as a shell script.  This will probably just explode in your face harmlessly, but if foo contains anything that looks like a shell command, you could get harmful results.

A lesser issue is that if you have a file that you want to preserve, and last year you did a chmod 444 to protect it from yourself, the chmod 700 will restore your write bit, and make it easier for you to clobber the file accidentally.

The solution to both issues is to do chmod go= -R ~ or chmod go-rwx -R ~, which will turn off all bits for group and others, but leave your access alone.

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.