Delete files and directories are common operations on ubuntu. In this tutorial, we will introdue how to delete them for ubuntu beginners.
How to delete files and directories on ubuntu?
The simplest way is to use rm command.
How to use rm command
rm command likes:
rm -option files_or_directories
option can be:
-d or –directory | delete a directory |
-f or –force | force to delete a file or directory |
-i or –interactive | delete file or directory with a interactive way |
-r or -R or –recursive | delete files and directories recursively |
For example:
Delete a file
rm -f 1.cpp
Delete all files and subdirectories in a directory
rm -rf code