Home  >  Article  >  Operation and Maintenance  >  Do files deleted using the rm command in Linux still occupy space?

Do files deleted using the rm command in Linux still occupy space?

尊渡假赌尊渡假赌尊渡假赌
尊渡假赌尊渡假赌尊渡假赌Original
2023-07-10 13:58:271057browse

Linux The files deleted using the rm command still occupy space, because although the directory of the file is deleted and the disk space occupied by the file is marked as reusable, the operation will not take place until the space is overwritten by a new file. The system still cannot allocate this space to other files.

Do files deleted using the rm command in Linux still occupy space?

The operating system of this tutorial: Linux5.18.14 system, Dell G3 computer.

In Linux systems, when you use the rm command to delete a file, the directory entry of the file will be deleted, and the disk space occupied by the file will be marked as reusable. However, the operating system still cannot allocate this space to other files until the space is overwritten by a new file. Therefore, although the file's directory entry has been deleted, the space occupied by the file is actually still occupied until it is overwritten.

If you want to immediately release the space occupied by the deleted file, you can use one of the following two methods:

  • Add the -rm parameter when using the rm command. Delete the file and free up the corresponding space immediately. For example: rm -rm filename

  • Use the shred command to overwrite the file contents and delete the file. For example: shred -u filename

It should be noted that before performing any file deletion operation, please make sure that you really want to delete this file, because once deleted, it cannot be recovered.

The above is the detailed content of Do files deleted using the rm command in Linux still occupy space?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn