Today's article has you making a file that can't be deleted*...

KGIII

Super Moderator
Staff member
Gold Supporter
Joined
Jul 23, 2020
Messages
11,498
Reaction score
9,992
Credits
95,326
Today, we make a file that can't be deleted*.

Note the asterisk. Of course, it can really be deleted, you just have to work at it. It's more useful for when you want to make it so that you don't mistakenly delete a file, because it takes some extra steps to delete the file. The tool is one that you should have installed already, called 'chattr' - which has nothing to do with chat but has to do with changing attributes.


Again, the file can be deleted - and I show you how. A smart user will realize that you've set the immutable bit and, if they have root/sudo, they'll be able to delete the file. If they do not have elevated permissions, they can't delete it. Well, they could reformat the partition... They could probably use a live instance where they do have root and delete it... But, again, the goal is making it harder to delete the file. Don't think of it as a security tool, think of it as a tool that helps you say 'oops' less often.
 


Also, I will be here sparingly. This is a weekend 'off' for me.

Behave yourselves. Don't hit the report button unless you absolutely must. I'll check in as time allows but it's time for me to have a day off.
 
This is a good tip. However a newbie Linux user could become scared seeing a lock emblem on a file listed by the file manager, for such a file having "immutable" bit set. This was something new to me a while ago with a file I downloaded which was marked read-only for some reason.
 
This is a good tip. However a newbie Linux user could become scared seeing a lock emblem on a file listed by the file manager, for such a file having "immutable" bit set. This was something new to me a while ago with a file I downloaded which was marked read-only for some reason.

LOL Then they shouldn't make it immutable. It's good for 'em.
 
Oh, my favourite immutable function! Nice article KG! Or, as I like to call it - making a file immortal bc that's what it becomes quite literally. Aside from a full device formatting, nothing else can change/replace/destroy the file. I discovered that function about 2 years ago and I've been using it actively ever since.
 
Nice hint. The hint could be improved by showing how to use the "lsattr" command to display the file attributes and see the immutable bit turn on and off.

A brief statement on how to troubleshoot, recognize, and fix a set immutable bit might be helpful, too. The "ls -a" full directory display will not show it.
 
The hint could be improved by showing how to use the "lsattr" command to display the file attributes and see the immutable bit turn on and off.

Small bites. Most of my articles are word-limited (by me) to be long enough for the average user's attention span. This means I'm limited to like 600 words. Trust me, I've monitored it. So, you get 600 words and some fluff to pad the articles to appeal to search engines. If I can get someone to spend more than 2 minutes on an article, I'd probably make money at it. Y'all seriously have attention span issues! (Me too!)

Also, I've done what's known as heat mapping. Man, I did that for about the first year and a half. That was enlightening. Pretty much nobody reads the closure section, for example. I further demonstrated this by putting a contest in one of my closures. Not one person has found it and responded. Not one person...
 
I further demonstrated this by putting a contest in one of my closures. Not one person has found it and responded. Not one person...
I worked at a large company and was assigned to write some long technical papers for one project. The papers were required deliverables for the project, but very very dry. Many hundreds of people worked on that project, but the first paper got no feedback or comments. It was good, but it wasn't that good. :)

About 2/3 of the way through the second paper, I wrote, "The first person to find this sentence and call me wins a dollar." Three weeks later, I got a call from an engineer asking very excitedly, "Did I win the prize? Did I win the prize?!!

With no assist from me at all, the word got out. The trick worked. I got good reviews with good feedback on the remaining papers for that project.
 
Three weeks later, I got a call from an engineer asking very excitedly, "Did I win the prize? Did I win the prize?!!

The software I use is good at weeding out bots and accidental clicks. In fact, when I reconcile it with the data from raw server logs, it's too good - meaning it actually misses some human views.

I just checked. The page has been viewed (by real humans) hundreds of times. Additionally, the article is more than a year old. At one point, I even gave someone a hint in a conversation kind of related to this one.

Ah well...

Today's article is actually longer, but it's full of superfluous fluff because I figured I would more clearly explain how it benefits me to understand these weird terminal commands.

Also, I kinda enjoyed my break. I think I'm going to do the same thing for Le Mans because the race is celebrating its 100th year. I usually don't watch that one straight through the whole thing, but I might as well vicariously celebrate with them. I think I'll drink less for that one.
 

Members online


Latest posts

Top