Hi there, I’m on Bazzite KDE and recently somehow lost a my “gaming” folder…? No idea how but must gave been user faulty, e.g me. Therefore wondering if it’s possible to lock certain folders so that this cannot accidentally happen?

7 points

I think looking into man chattr is a good option for this

permalink
report
reply
2 points
Deleted by creator
permalink
report
parent
reply
6 points

Every modification and deletion is prevented regardless of the method, be it mv, rm or other commands on the terminal or through a GUI, with or without sudo until sudo chattr -R -i /path/to/directory is performed

permalink
report
parent
reply
10 points

Not really afaik, you can make file immutable with chattr +i /path/to/something but that means you cannot write to it either, which will probably cause problems.

permalink
report
reply
1 point
*
Deleted by creator
permalink
report
reply
2 points

Thanks for your input! This is defo something i do need to learn from indeed. This happened on a pretty fresh install too, the only program linked to that specific folder/path, was Bottles, as I need it for running the executeable for the game. No addtional drives or mounts (other than what Bottles is responsible for). However I would still like to be able to “lock” folders just to prevent my own sillyness from deleting it again.

permalink
report
parent
reply
5 points

Sure, regular file permissions can do that. You may need to make the folder owner someone else, and set the sticky bit.

permalink
report
reply
2 points

Yeah actually this was more simple thanI had imagined, I simply changed it so that the owner(me) can only view the folder and not edit. Which totally works in my use case. Thought it would have been more difficult than just changing this tbh, thanks!

permalink
report
parent
reply
22 points

sudo chattr +i (folder) prevents anything to modify/delete folders and files

Add -R for setting the flag for all subdirectory/files

permalink
report
reply
5 points

Thanks I might try this! However does this allow for reads/writes from the system? Considering this is a folder for games, the files are constantly changing, such as the game save files etc…

permalink
report
parent
reply
6 points
*

If you’d like to look into it further. the +i flag in chattr is setting an attribute making the file (everything in Linux is a file, so yes this even means directories) immutable. When a file is immutable, it isn’t possible to change the ownership, group, name, or permissions of the file, nor will you be able to write, append, or truncate the file.

It’s been a while since I’ve used it, but I don’t believe it’s possible to have an immutable directory where you can still modify the contents therein, but I may be misremembering that. It would seem unlikely since adding content to the directory should require that you modify the links for the directory, which shouldn’t be allowable with an immutable object?

It’s possible that the +a chattr attribute may achieve what you’d prefer. I believe that flag will make it so that files (and again, everything in Linux is a file) can be created and modified, but never deleted. I’ve actually never used this one, but I can foresee how this still may not be ideal for your wishes since updates to games may expect to be able to delete old content which would be thwarted here. 🤷

permalink
report
parent
reply
1 point

Thanks for the explanation, I luckily solved this with just “basic” changes of permissions in dolphin actually haha, but defo good to know that chattr has these capabilities for future references. Appriciate it 🌻

permalink
report
parent
reply
3 points
*

I don’t believe it’s possible to have an immutable directory where you can still modify the contents

Not directly under that directory, but you can modify directories under it. Attributes only apply to the directory’s own alocation table and child directories have their own tables.

Also you can modify the content of the files in the directory. The attributes only refer to removing or adding files or other operations that modify the directory’s table.

permalink
report
parent
reply

Linux

!linux@lemmy.ml

Create post

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word “Linux” in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

  • Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
  • No misinformation
  • No NSFW content
  • No hate speech, bigotry, etc

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

Community stats

  • 9.6K

    Monthly active users

  • 5.8K

    Posts

  • 162K

    Comments