To delete a file or folder in Ubuntu, you can use the
rm (remove) command. Here are the steps:
- Open the terminal by pressing Ctrl + Alt + T or by searching for "terminal" in the applications menu.
- Navigate to the directory where the file or folder is located using the cd (change directory) command. For example, if the file is located in the Downloads folder, you can use the command cd Downloads.
- To delete a file, use the rm command followed by the filename. For example, to delete a file named "example.txt", you can use the command rm example.txt. Be careful when using this command, as it will permanently delete the file and cannot be undone.
- To delete a folder and all its contents, use the rm command followed by the -r (recursive) option and the folder name. For example, to delete a folder named "example_folder", you can use the command rm -r example_folder. Again, be careful when using this command, as it will permanently delete the folder and all its contents.
- If the file or folder is owned by another user, you may need to use the sudo (superuser do) command before the rm command to gain permission. For example, sudo rm example.txt