It is quite simple to use terminal to remove files and folders.
Deleting files (Removing)
The command to delete a file (remove it) is "rm".
Thus, to erase the file "test.txt", just do the following:
You don't need to be in the same folder of a file in order to erase it.
If you type it's full address you can delete it without the need to navigate there.
In order to remove the test.ogg file which is in the "music" folder within my home directory, I can use the following code::
Did you notice that tilde simbol (~)? It represents your home folder. You don't need to type "/home/myname/". Use tilde instead.
There is a little trick here though.
In command line the space has a very important meaning: it separates commands.
There can be no space in the file and folder names you are moving. If there are, you must use quotation marks to let the computer know you mean a single name, and not a sequence of commands.
You can also use a \ before a space to indicate that you do not mean to separate commands with that particular space
Here are the examples:
rm "test one.ogg"rm ~/my\ music/one.ogg
Removing directories (folders)
Folders and directories are just the same thing.
If you try to remove a directory with the rm command, it will fail.
That is because the computer does not know if you want to remove the whole folder content altogether.
You will need to tell the computer that you want to recursively remove that folder, that is, to remove it and all it's content, including folders and their contents.
Thus, to remove the "test" folder, Para remover a pasta "teste" e todo o seu conteúdo, digite o seguinte comando:
rm teste/ -R
Thata "R" is from "recursive" and with this argument all folders and files within them will be removed.