Is there a way I can password protect a folder without encrypting/compressing?

22,330

Solution 1

You can just change the directories permissions to 700 (which equals to rwx------ which means no access at all for everybody, except full access for the owner).

That way, no normal user (except your user account!) can enter the directory. They will still be able to see the folder from the outside, but they neither can open it to list its content nor can anybody open files inside it, even if they know the full path and name.

However, when you are logged in and walk away, there is no protection, as this does not affect your own account. You can also decline your own account any permission (set to 000 then), but this can be reverted from your account without password, if one knows how to do so.

So the best option is to change the permissions to 700 (only owner has access) and additionally change the owner to be root. That way, nobody can enter the directory, not even you. And you can not change the permissions of the directory back.

To access your folder anyway, you would then have to be root, which requires one to be logged in with an admin account and to use gksu/gksudo to open a file manager or media viewers like Nautilus and VLC. This however prompts you again for your admin account password, so you are protected from anybody who is no admin and can not become root.

So how to set this up is ridiculously simple. Let's assume the folder you want to protect is /home/MYUSERNAME/Videos/private.

  • Option 1: Full access for owner (you), but no access for other accounts.

    chmod 700 /home/MYUSERNAME/Videos/private
    

    This setting can be undone from your account without password by typing

    chmod 775 /home/MYUSERNAME/Videos/private
    
  • Option 2: No access for any user including you, so you need to become root to enter the directory.

    chmod 000 /home/MYUSERNAME/Videos/private
    

    This can also be reverted from your account without password by

    chmod 775 /home/MYUSERNAME/Videos/private
    
  • Option 3: No access for any user including you and no chance to revert it from your account, so every action can only be performed as root.

    chmod 700 /home/MYUSERNAME/Videos/private
    sudo chown root: /home/MYUSERNAME/Videos/private
    

    To revert this setting, you have to do the following (which needs sudo and therefore requires your account password):

    sudo chown MYUSERNAME: /home/MYUSERNAME/Videos/private
    chmod 775 /home/MYUSERNAME/Videos/private
    

Note that options 2 recommends and 3 requires you to have an admin account and that all options only can protect you from users without admin accounts and passwords!

Additionally I should mention that one with enough experience and physical access to the machine can also boot it in recovery mode and be root user without having to enter any password. But there is no more secure way unless you use encryption, which you explicitly said you do not want.

Solution 2

you can use steganography method its not also protect your files it also hide your files

https://scottlinux.com/2014/08/12/steganography-in-linux-from-the-command-line/

first install steghide

sudo apt-get install steghide

2nd

steghide embed -cf tux.jpg -ef mytext.txt 
Enter passphrase: 
Re-Enter passphrase: 
embedding "mytext.txt" in "tux.jpg"... done

to extract

steghide extract -sf tux.jpg
Enter passphrase: 
wrote extracted data to "mytext.txt".
Share:
22,330

Related videos on Youtube

Yu Kwan Chau
Author by

Yu Kwan Chau

Updated on September 18, 2022

Comments

  • Yu Kwan Chau
    Yu Kwan Chau almost 2 years

    I have got a folder that contains private stuff and I don't want others to be able to see its content. I will frequently open it and the folder is quite large. I know I can password protect it by encrypting or compressing, but then the loading time is quite long and it is inconvenient. I don't care the content being disclose, so there is no point in encrypting it. All I need is just to hide it.

    Is there a way I can password protect it without encrypting or compressing the folder?

    • Byte Commander
      Byte Commander about 9 years
      Please note that everything you write here is written for eternity unless your question gets deleted. So for the next time: keep private stuff private. We don't want to know what you do at home.
    • hmayag
      hmayag about 9 years
      To hide a folder you just need to rename it to something starting with a . (dot). It will still be visible via command line ls and in graphic mode if you enable showing hidden files in your file browser.
    • Yu Kwan Chau
      Yu Kwan Chau about 9 years
      @ByteCommander I know, and therefore the account I used to ask this question is not the account I usually use. It is a fake account that made to ask this question only. Don't you think without saying what the private stuff is, it is hard to understand why I only want to hide it but don't mind the content being disclose? Some smart reader may be able to guess what that is though.
  • A.B.
    A.B. about 9 years
    ACL could be another option.
  • Byte Commander
    Byte Commander about 9 years
    @A.B. But ACLs do not provide more security or more obfuscation than the given options while they are more complicated to set up and need additional packages to be installed.
  • A.B.
    A.B. about 9 years
    More complicated is the point :)
  • Byte Commander
    Byte Commander about 9 years
    Steghide also encrypts files. And it is probably even slower than normal encryption. You also need some not-important and big enough files (images or videos most likely) that can take all the information without looking modified. Unfortunately, this makes your solution unusable for the mentioned "quite large folder", although your method definitely even hides the existence of any private data while mine leaves a visible but inaccessible folder...
  • Yu Kwan Chau
    Yu Kwan Chau about 9 years
    This is the best answer I have ever seen not only to under this post but also in the entire Internet. (well, maybe not later, but at least for this moment)
  • Byte Commander
    Byte Commander about 9 years
    @YuKwanChau Thanks! Nice to hear I could help you. :D