“Hey Linux, can you just delete this file please?”
“Sure thing bud, a program is using it, it’s ok, I will just unlink the inode anyway, the program can still access it until it closes the file”
Hmm. So are the blocks freed up for overwriting on file close, then?
Yes. On Linux/Unix you don’t delete the file, you just delete it’s name, which is merely a link to the actual file. That’s also the reason why the syscalls name is actually
unlink
and notdelete
. As soon as there’s nothing pointing to a file anymore, it is deleted.As long as a process holds a file handle, there’s still a reference to said file, so it won’t be deleted. That saved me once, when I accidentally deleted a file I wanted to keep: As there still was some process keeping it alive, I could just go to
/proc/[process id]/fd/[file descriptor id]
and copy it to a safe location.Good to know, and helps me understand code dealing with filesystems a little better. I’m curious how the kernel keeps track of it all, just a counter maybe?
On Linux/Unix you don’t delete the file, you just delete it’s name, which is merely a link to the actual file.
Is that different on other systems?
I don’t know how NTFS does it, but on FAT filesystems the directory table contains the filename along with all the other file metadata (access rights, creation date, size, etc). Only the list of sectors containing the actual data is separate. That means that you can’t have two filenames for the same file on FAT filesystems.
If you want to learn more about this, the data structure UNIX filesystems use, and FAT filesystems lack is called inode.
In case anyone is interested, there’s a powertoy called file locksmith that will show what’s using it and let you kill it: https://learn.microsoft.com/en-us/windows/powertoys/file-locksmith
Powertoys seems to be the only thing keeping windows somewhat usable, I have no idea why they don’t include it in the build.
I discovered powertoys only recently, and it’s a pretty cool set of tools. From color picker, tiling window manager to regex file renames or copy/paste tools, it has a lot of QoL features.
If you have to be on windows, i.e due ro work, I recommend not sleeping on it.
The performance view thing that comes with windows also allows searching for file handles but it’s not very user friendly. Also not possible without admin rights if I remember correctly
You can use the built-in tool resmon.exe to do the same
Now the question is if I can install it on my work computer without IT getting pissy
Why isn’t this in their OS instead of unwanted AI
Sysinternals handle is lightweight unitasker for this too, better option for servers.
back in the XP days, I used a software called “Unlocker” just for this problem. It probably still exists, I don’t know, because since Windows 7, the easiest way to find out what process locks a file is to open Resource Monitor (Start search: resmon) and on the CPU tab, using the “Associated handles” list, you can search for the file name and see the process in question (and kill it).
So yeah, Resource Monitor is a useful tool on Windows.
There’s a collection of free little utilities called Microsoft PowerToys, including the file unlocker thing. Why would they not include these into base kit Windows is beyond me.
not including PowerToys inside basic package is a fucking choice. Win11 is literally unusable without it in many aspects.
I would argue windows 11 is pretty much unusable regardless
LTSC is probably usable but if the base is so broken - i wonder if LTSC is still as good as Win10 LTSC.
It works you just have to launch outlook 3 times for it to take.
I suspect it’s in line with big tech policies to coddle end users instead of educating or trusting them. I assert (particularly since the introduction of the iPhone in 2007) that learned helplessness is built into the game plan.
100%! Like with major setups and upgrades now just being throbbing circles and a pulsing blue light with the creepy “We’re doing stuff on your behalf behind this screen.” messaging.
I say computers (and the Internet) are for anybody, but not everybody. Learning to use a tool will always be a requirement of useful tools.
There used to be a time when most people using a computer implicitly understood how files and folders worked, for instance. But now even such a simple abstraction is considered advanced esoteric lost arcana.
I’m deeply saddened by how the tech industry has deliberately pushed understanding backwards so hard in order to foster more obedient consumers.
It’s actually wild to see how many people who were at the very least, young adults during the computer boom of the late 80’s/early 90’s, can’t handle anything without a touch screen and don’t comprehend email.
Ignorance is sold as the future.
My dad used to say Apple is evil exactly because of that - they make stuff for people who want fancy shit but have little to no interest in actual tech.
Sysinternals is also a great tool. Not as vital for the average user though.
gotta check it out. thanks for the tip
Why would they not include these into base kit Windows is beyond me.
Some of them felt a bit buggy when I last time used Windows, maybe they aren’t fully ready to ship (like Samsung’s Good Lock apps?). And most features didn’t do quite what I imagined it to do, but that’s probably a “me problem”.
That’s a fair point, but, let’s be honest, the built in Windows features often have the same issues
Not recently copilot and AI implementation has made the OS beyond shitty recently and a lot of broken shit. That’s why I need to move to Linux they’re basically sinking their ship with broken AI code.
The telemetry is overbearing too lately.
Bill Gates secret hotline.
probably.
I feel like it’s a testing ground for new features for them, but not sure why some aren’t yet integrated. Best guess: the PowerToys team has less red tape and checks to go through than the Windows team to allow for faster iteration, but that means that integrating the features wouldn’t be just the click of a button since they’d have to adapt it to fit the Windows style. But this is just a wild guess.
I think you’re right on the money. There seems to be a component of enticing power users to stick with Windows as well. The app is still “in beta” despite the first release being in 1996 (!). I had to look that up, because I’d only heard about it in the early windows 10 days.
The first version of PowerToys was released for Windows 95 on 17 November, 1996 as a download on Microsoft’s FTP server at the time.
Well wadaya knows?
I like that it wasn’t a proper installed thing, just a bunch of executables in a zip file.
Because they want to include things with ads now - i.e. the ad-supported Outlook in the place of Mail.
The bugs and horribly slow hardware that caused the locks in NT/XP have slowly disappeared, by win 10, I rarely had any files I couldn’t delete if I, worst case, made explorer reload. It used to happent o be every other day in the late 90s
What gets me is when I’m not allowed to remove an external drive. Deleting a file can be delayed until later but here I am with a physical object that I need to detach from my computer and first I need to play hide and seek with the OS.
If this happens often, you can disable write caching for that drive. It’ll feel slightly slower (since it’s actually operating at the speed of the hardware instead of caching operations in RAM and gradually writing them to disk in the background), but you’ll be able to remove the drive almost instantly.
I used to find it had something to do with the explorer thumbnailer finishing up but sort of not letting go. It would happen if I had pictures or videos on the USB drive, and if I got the error I could go to another folder like my documents, drag a picture into another folder, go look at the pretty new thumbnail, then I could remove the USB drive because the thumbnailer was ‘parked’ back on the C drive. Sounds like I’m making it up but I swear it worked.
Shouldn’t that happen automatically if the drive is identified as removable? And the real solution should be to tell the OS that it’s removable?
I was having terrible performance problems in Windows a while back, and it turned out it had marked every drive as removable and the write cache was filling up due to an extremely slow external HDD, causing even the internal SSDs to grind to a halt until the buffer was flushed whenever a large amounts of writes were made to the HDD. Which, since the external drive was used for backups and large Steam games, was almost every other day.
You can use this performance view thing that comes with windows to search for file handles and the processes that own them
Meanwhile on Linux: /boot successfully deleted
I once deleted /dev/null Do not recommend. You’d be surprised how much of the system needs it.
I once deleted /dev/urandom. I didn’t want uncertainty in my life.
Well, I was on for a surprise.
well, i guess your pc got into a pretty certain state of being, at least for that evening, so technically it worked:)
How? I could’ve sworn it wasn’t even a “real” file. I thought the file system just had special rules for interacting with that name.
Actually on windows 7 I found out how to get which process is locking one file.
You open the resources manager (task manager has a link to it)
Inside you can see how much each process uses on cpu, network and stuff.
And there is a tab where all used files for each process is listed. You can search for specific files.
Yeah there’s a Microsoft sysinternals utility where you can drag a file into to fetch that info for you.
Makes zero sense there isn’t a >Details in the error notification that tells you the damned process in Windows.
Not only that, but you can actually search all active processes to see which handles they keep references to. Just search the name of your file and it will show you the processes which use it
Gawd forbid users get some transparency.
Right? I get that it’s “alarming” to users to see weird stuff, but just hide it under a little expandable thing.
Linux fuser for the win
I’ve never fused Linux before, is it difficult?
fuser is an easy command just point it at the file and it tells you the process ids that using that file.
Not anymore. Many distribution will have most of what you need out of the box depending on what your needs are. They mostly feel like windows XP or 7.
where do i get linux xp 7?
Either a distribution with KdE Plasma (Kubuntu for example), or something like Zorin OS works really well.
I barely know er!
Or stay with the basics and use lsof.
Either way, not coming with that tool by default and forcing every usage of the file to lock it is a really stupid pair of mistakes.
Well duh, Microsoft respects privacy
Same thing whenever I try to unplug a USB, Win10, on my desktop. There have been times where I plugged in one, opened a file, closed it within seconds, did the safely remove thing, and then I get the whole quick song and dance about some program still using it because of how sluggish it is to actually end what’s using it in the background.
Also, my phone’s keyboard software was bugging out and replaced “song” with “incest” for no discernable and wanted to replace the next word “and” with “rape incest”. Not related, but fuck Gboard and that weird glitch where it’ll replace words with random shit for no reason.
Doesn’t gboard try to promote words you’ve used more prior more often than ones you’ve used less…?
Yeah, dude really needs to atop looking up hentai, or at least start reading more wholesome ones.
Or get FUTO keyboard and disable autosuggest
The crazy part about that is I don’t look up hentai. Just yiff and even then, I’m a vanilla kinda guy.
I may occasionally joke about Alabama and incest out loud, but never really type it.
Also, I would switch to something like FUTO but I have yet to find a FOSS keyboard that can handle Japanese or Chinese.
There are good keyboard apps on F-Droid…
I have yet to find one that can properly do Chinese and/or Japanese and I’m too dumb to make one. That’s the only thing holding me back.
OK, WTAF on those word replacements. I’d be freaking out about malware.
That’s what happens when they train it on bad porn sites.
I cannot remember what it’s done in the past, but I’ve definitely had much more tame occurrences of this. Same with holding the delete key and having the thing think that the first letter of a word doesn’t exist from time to time.
Probably a couple of minor bugs that g••gle doesn’t care to fix.
It’s one of the things that made me prefer using Linux a long long time ago. It’s nice to be able to rename, move, and delete files while they are used.
Reason 3756 why Windows is slopware
“Hey Microsoft, i want to safely remove this hard drive so i don’t corrupt my data”
“Nope, it’s being used by another program”
“I shut down every program, nothing is open, please eject my Hard drive”
“Nope, It’s being used by another program”
**Proceed to just yank the cord out of the computer and flick off the screen.
Mac does the same thing (as others have said) and you can at least
sudo lsof
and find it, but somehow filesystem access now is worse than Windows 95 era Excel spreadsheet file handles that never worked.Here’s what an operating system is peeps: Something that handles files and programs that live on top of it. That’s it.
How is it none of them can’t do their basic function anymore?
Same command works on Linux. Its a real saver sometimes.
You can also specify a path.
Files, hardware / peripherals and programs. The distinction can get a bit blurry what with drivers and the fact that Linux exposes most of the hardware via the filesystem.
Process explorer, threads and handles tool, search the file name.
Kill the process or at least you know who now.
Same on Mac except it’s an external drive that some mystery program is using.