[Tip] Protect/ Unprotect a folder

Share your own howto's etc. Not for support questions!

[Tip] Protect/ Unprotect a folder

Postby bester69 » 2018-06-10 20:32

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:There is nothing to install in linux, from time to time i go to google searching for something fresh to install in linux, but, there is nothing
User avatar
bester69
 
Posts: 1145
Joined: 2015-04-02 13:15

Re: [Tip] Protect/ Unprotect a folder

Postby bester69 » 2018-06-12 17:09

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:There is nothing to install in linux, from time to time i go to google searching for something fresh to install in linux, but, there is nothing
User avatar
bester69
 
Posts: 1145
Joined: 2015-04-02 13:15


Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 3 guests

fashionable