8 Protecting files that should be accessed only by root

Some files and folders should be accessible only by root. If the file is executable, use the following commands as root to protect it:

chown root:root filename  
chmod 700 filename  
  

The chown command changes the ownership of the file so that it is now owned by the user root and the group root. The second command changes the permission so that only the owner has full (read/write/execute) access.

If a file is not executable, then substitute 600 for 700 to disable the executable flag. A folder (directory) should always use 700 so that the content of the folder can be displayed.