Do you know what happens internally, when a file is deleted???

Sukhad Anand
2 min readDec 5, 2021

--

To know the answer to this question, some background is required.

Photo by Markus Spiske on Unsplash

1. Every operating system, be it Unix-based, windows or Mac OS has its own type of file system. The file system determines the way to store files/directories in the system.

2. All these file systems have mechanisms to link the file’s actual storage location to a table(map) which is a kind of a pointer to the actual file location containing the data. This map is required because the file is stored in chunks in different memory locations and not as contiguous blocks in memory.

3. When you delete a file, the file system marks at the first block of the stored file that this file has been deleted and makes the pointer available for other files.

4. When a new file comes, then the actual data of the file is overridden and the pointer now points to this new file, and the old file is completely removed. But until then, the file remains as it is on its location with all the data intact.

5. In Unix, a single pointer(I-Node) can be used for multiple files each being the copy of the other and the data just stored at one single location. To completely remove the file, all the copies have to be removed, so that this I-Node can be deleted.

Why this article?
I am trying to go deep into concepts of software development and computer programming. I will be going from basic concepts like OS/DBMS to complex system designs. I am doing this just to refresh my memory and be a better software developer.

I will attempt this for the next 40 days and post important insights and resources which I used. Will be creating a youtube video too for the things I learn. If you like you can follow along.

Today was file systems.
A rough set of resources: https://lnkd.in/eztTH_AZ

--

--

Sukhad Anand
Sukhad Anand

Written by Sukhad Anand

Addicted to 007 movies and music of all genres and all generations. A bit of philosophy with a pinch of music and a handful of coding.

Responses (1)