You can use Linux rm command to delete files and directories.
Delete a single file in Linux:
1 2 |
## Delete a file rm /some/path/to/file |
Delete a single empty directory in Linux:
1 2 |
## Delete empty directory rm -d /some/path/to/directory |
Delete a single directory along with its content in Linux:
1 2 |
## Delete directory with contents rm -r /some/path/to/directory |
Delete multiple files or directories at once in Linux:
1 2 |
## Delete multiples files/directories at once rm -r /path1/file1 /path2/file2 /path3/dir3 |
Delete a file or directory forcefully in Linux:
1 2 |
## Delete nonexistent files or write protected files rm -f /path/to/file |
Prompt before deleting a file or directory in Linux:
1 2 |
## Prompt before delete rm -i /path/to/file |
Print messages while deleting a file or directory in Linux:
1 2 |
## Print message while deleting rm -v /path/to/file |