Linux – How to password protect a folder on Unix/Linux without encryption

linuxpassword-protectionpermissionsprivacyuser-folders

I've searched a round quite a bit in the past and present for either a builtin feature or program for this, but had no luck. I want to password protect a folder, but do not wish to encrypt it.

The security of the contents of the folder is not important, the password would just act as a deterrent to somebody attempting to access the contents of the folder from my computer. Think of it like a password lock on a computer, if you were to remove the harddrive you could easily take all the files the user had, but the password is still a deterrent so that not everyone passing by can just hop on.

Two main reasons to not use encryption here are:

  • Decreased performance for opening files
  • Encryption prevents the contents from being indexed/searchable

Is anybody aware of a solution?

Best Answer

The easiest way would be to change the permissions of the files to not be readable by anyone other than the owner. Once that is done, a user would have to either log in as you (which should require a password) or sudo as root (which also should require a password). To change the permissions, simply use the following command on any files you don't want others to have access to.

chmod og-rwx filename

This assumes that when you are not on the machine, your screen is locked and there is a password for your account as well as the root account.

Related Question