Monday, 19 August 2013

Protecting Files and Directories

 Restrict users from accessing Files

Problem: You want to prevent other users on your machine from reading your files,

Solution: To protect existing files and directories,
# chmod 600 file_name
# chmod 700 directory_name

To protect future files and directories
# umask 077

Prohibiting Directory Listing

Problem: You want to prohibit directory listing for a particular directory, yet still permit the file within to be accessed by name,

Solution: Use a directory that has read permission disabled, but execute permission enabled,

# mkdir dir
# chmod 0111 dir
# ls -ld dir
# ls dir
/bin/ls : dir: permission denied

To permit only yourself to list a directory owned by you
# chmod 0711 dir
# ls -ld dir

No comments:

Post a Comment