Yes, those lines are what should be copy+pasted.
----------------------- preamble to removing directories
Firstly, I cannot stress enough that removing files/directories with the “rm” command does not put them into a trash bin, but instead removes them permanently. If you later change your mind or make a mistake you cannot get them back… They gone, gone, gone. So:
- be really sure you want to delete something.
- be really sure you have specified that/those thing(s) correctly.
If you have the space currently, I would recommend moving the files/directories first, and go to remove them later. To check your disk space on the terminal, there is:
… and you can navigate to the main “Filesystem” in question (it probably starts with /dev/SOMETHING).
Additionally, it is possible to use the “Files” application in Ubuntu to navigate through a GUI of directories structures (like you would in Windows, for example), you can select a directory name, right-click it, and move it to the trash, and then empty your trash. If you have lots of directories to remove, this can become tedious, though.
Finally, using wildcard characters can speed up the process of selecting files or directories with similar names. Sometimes we use that with listing things, such as listing all files or directories in your home directory that start with “AFNI_data” and might have any other characters after that start, including not having any more characters (the “-d” option means that it will only list items in the base directory, and not recursively lists contents of any directories that might start with “AFNI_data”):
ls -d ~/AFNI_data*
These are useful to select a lot of files/directories systematically and efficiently, but if you use them while removing, you reeeeeally want to be sure you are only selecting exactly what you want. I would not use wildcards in combination with removing unless you are very comfortable with them and shell commands.
Note Linux-wise, Rick has a nice tutorial on getting comfortable with command line (shell) syntax, which I would recommend everyone read and practice with:
Linux commands are really useful, and this is a nice intro to start getting comfortable and practicing with them.
------------------- ok, to the question at hand:
Removing files and directories has slightly different syntax.
To delete a file in the terminal, you would type:
or, if you have several, you can remove more than one at a time:
rm FILE_NAME1 FILE_NAME2 FILE_NAME3 ...
You could use while cards to specify your list of FILE_NAME* values, like “remove all files that start with pineapple”:
… and be sure that you know what exactly files start with pineapple, so that if you just wanted to remove “pineapple_tmp.txt” and “pineapple_old.txt”, but NOT “pineapple_thekeytolife.txt”, that you do not use the wildcard like this, but instead specify individual files…
To remove a directory, you would specify the directory name and provide an option to say to recursively remove everything in it, too.
rm -r DIR_NAME
Note: if you type the wrong directory name, the terminal won’t check with you, and the shell will remove stuff. Sooo, be very careful that DIR_NAME is not mistyped—putting accidental spaces would separate the name into multiple apparent directories, and the shell will try to remove each piece, which could be very bad depending on how the pieces split. You can use wildcards here, too, but I would not recommend that until you are very comfortable with the shell syntax, because it is too easy to remove too much (an accidental space before a wildcard can be catastrophic).
Again, I don’t mean to be scary, and playing around with Linux/shell commands is the only way to get better with them and to feel comfortable. It is just that the “rm” is quite powerful and not forgiving, and so one really just has to be careful and sure of what is being specified to remove in this way. I guess everyone has removed something they reeeeaallly didn’t want to at some time, and been very sad afterward, as part of the learning curve—I know I certainly have :(.