Junior — Middle
How is file deletion performed in the Linux operating system?
sobes.tech AI
Answer from AI
In Linux, deleting a file is usually done with the rm command. This command removes the link to the file from the filesystem. If the file has no other hard links and is not open by any processes, the space it occupies is freed.
Example of deleting a file:
rm filename.txt
It is important to understand that rm does not move the file to the trash, but deletes it immediately. If the file is open by some process, it will be removed from the directory, but the data will remain on the disk until the process closes the file.
You can also use unlink filename.txt — this is a system call that removes a single link to the file.