Score:0

How can I protect my CIFS attached shares from accidential deletion like 'rm -rf /'?

cn flag

I have a Synology NAS and I have 2 folders from it attached in /mnt/nas-XXX via /etc/fstab like so:

//192.168.178.100/BackUps /mnt/nas-backups cifs uid=0,credentials=/home/user/.smb,iocharset=utf8,vers=3.0,noperm    0 0

How can I protect them from accidential deletion like rm -rf / or others.

sudodus avatar
jp flag
**Backup** everything that you cannot afford to lose.
Grumpy ol' Bear avatar
cn flag
Well, yeah, I do that. I just want some extra protection.
sudodus avatar
jp flag
I have an alias for 'remove', `alias rm='rm -i'` which makes it ask for confirmation. The alias can be escaped by `\rm ..`.
sudodus avatar
jp flag
Do as much as possible with your standard user ID. Use sudo only when absolutely necessary and double-check before launching sudo commands.
Score:1
cn flag

You need to be always aware of what you are typing, Although its not a scalable solution but it can help you To protect them from accidental deletion, You can add immutable attribute to files.

chattr +i path_to_files

Grumpy ol' Bear avatar
cn flag
Yea, that's one way, but I was thinking more along the line of applying something like that to `/mnt/nas-backups` no matter what I would do, `/mnt/nas-backups` would never be deleted unless I explicitly say YES or something. I guess you can: https://www.tecmint.com/chattr-command-examples/ not just files, but folders too. But being immutable... does that mean nothing can be done to `/mnt/nas-backups`
zabiullah avatar
cn flag
If you set immutable on dirextory then you can not delete or modify the directory and its files , So, what else do you want?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.