I understand os.unlink() is like os.remove() in python as pointed out here. My question is: does it actually remove the file itself? My guess is not. Can I then undo this action?
-
3`os.unlink()` does delete the file. It's like using `rm`. Depending on your OS, you might have another directory entry linked to the same data, but that is the exception rather than the rule. – khelwood Jan 23 '20 at 08:53
-
1did you read the question you linked to? "They are identical" – Chris_Rands Jan 23 '20 at 08:56
-
don't guess -- try it! – anthony sottile Jan 23 '20 at 08:59
1 Answers
Unlink / remove and more other functions that delete file usually delete only the file system information not the content itself. This is done for performance considerations. But that means that the space occupied by the content is free to be written over, so if you want to recover try and don't write too much to that partition (if it's a HDD) or the disk itself (if it's a SSD or flash based storage)/
That the way the recovery programs are able to recover a lot of files. Depending of the file system (if it journaled aka saves what operations have been made) you can recover more or less information about the file.
In some cases (special programs / settings or other situations i might not think about now) the content is written over for security pourpuses.

- 453
- 1
- 4
- 11