
To remove the file using its inode, use the find command as shown in the syntax below. In addition, you can pass the -i flag in the ls command when listing files inside a directory. You can find out a file’s inode number using the stat command as shown.

Delete Files With Inode Number in Linuxįor example, you can delete a file using its inode number.

Therefore, when the rm command is issued, only the reference to the files is removed, which frees up the storage blocks in the filesystem.Īs such, there exist several avenues to delete files in Linux. When the rm command is executed, the filesystem only removes the link to the file, which makes the file unavailable to the user, but in the real sense, the file’s data itself remains intact on the disk. To delete or remove an empty directory use the rmdir command, which comes in handy when you want to remove an empty directory called test_directory as shown: $ rmdir test_directoryĭelete a Large Directory with Tons of Files The -r option recursively deletes the directory alongside all the subdirectories and files contained therein.

To remove or delete a directory called sample_directory, run the following command: $ rm -rf sample_directory
