9

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?

terdon
  • 54,564

2 Answers2

16

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.

R Schultz
  • 3,101
9

Create a new user (with password) for this protected files/directories.

Then log in / sudo to root and give this commands (replace $newuser with the new user account name ;):

chown $newuser filename directoryname
chmod og-rwx filename directoryname

This way, the files and directories are even save when you don't log out and have your screen not locked for some reason.

This assumes, that a) you are not constantly logged in as root or any other account with special administrative rights, b) root (and any other user account with administrative rights) has a password set, c) sudo is not configured to skip password test (or in more general: entering the password is required for all log-in operations). d) every one with administrative access logs out when she leaves the terminal - even if only for a short time like 2 minutes.

/edit to reflect R Schultz'es comment