Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Tip] Protect/ Unprotect a folder

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Post Reply
Message
Author
User avatar
bester69
Posts: 2072
Joined: 2015-04-02 13:15
Has thanked: 24 times
Been thanked: 14 times

[Tip] Protect/ Unprotect a folder

#1 Post by bester69 »

Hi,
It locks a directory recursively, protecting it against deletion or writing (ntfs not supported).
I think these two scripts might be usefull to keep. (Using chattr)

lock.sh ~/myfolder

Code: Select all

#!/bin/bash
#
sudo chattr -R +i $1
unlock.sh ~/myfolder

Code: Select all

#!/bin/bash
#
sudo chattr -R -i $1
--------------------------------------------
A second approach solution only protects as long as live system. (Using mount/unmount) (ntfs supported)

lock.sh ~/myfolder

Code: Select all

#!/bin/bash
#
sudo mount --bind -o  ro $(readlink -f "$1") $(readlink -f "$1")
unlock.sh ~/myfolder

Code: Select all

#!/bin/bash
#
sudo umount $(readlink -f "$1")
Last edited by bester69 on 2018-06-12 17:11, edited 1 time in total.
bester69 wrote:STOP 2030 globalists demons, keep the fight for humanity freedom against NWO...

User avatar
bester69
Posts: 2072
Joined: 2015-04-02 13:15
Has thanked: 24 times
Been thanked: 14 times

Re: [Tip] Protect/ Unprotect a folder

#2 Post by bester69 »

Reading Protection Version.:

>> It replaces the folder with an encryption zip file.

elock.sh

Code: Select all

#!/bin/bash
#
dd=$(basename $1)
zip -0 -e -r -m $dd $dd
unelock.sh

Code: Select all

#!/bin/bash
#
dd=$(basename $1)
7z x $dd
#Sends deleted file to Trash folder
gvfs-trash $dd
bester69 wrote:STOP 2030 globalists demons, keep the fight for humanity freedom against NWO...

Post Reply