To delete and remove files on Debian Linux, you can use the rm
command in the terminal.
Here are some examples of how to use the rm
command:
-
To delete a single file, use the following syntax:
rm [file]
Replace
[file]
with the name of the file you want to delete. For example:rm myfile.txt
-
To delete multiple files, specify each file separated by a space:
$ rm [file1] [file2] [file3] ...
For example:
rm file1.txt file2.txt file3.txt
-
To delete a directory and all of its contents, use the
-r
(or--recursive
) option:rm -r [directory]
Replace
[directory]
with the name of the directory you want to delete. For example:rm -r mydir
-
To force the deletion of read-only files, use the
-f
(or--force
) option:rm -f [file]
Replace
[file]
with the name of the file you want to delete. For example:rm -f readonlyfile.txt
Note: Be careful when using the rm
command, as it permanently deletes files and there is no undelete option. If you’re unsure whether you want to delete a file, use the ls
command to view its contents first, or use the mv
command to move it to a backup location.