Removing files in terminal


#1

Hi, everyone,

I’m currently in Command Line Basics lesson, and in the exercise I am told to delete the test directory. I used rm -R (though in the Conquering the Command Line, rm was not mentioned with the flag -R, I added it because it was used with cp to denote folder) and it worked.

However, I went to Google and found there is also command rmdir to remove folders.

My question is: is there any difference between the two commands?


#2

For rmdir, you can only remove empty folder. For non-empty folder, you need to use rm -r.
Linux is weird… Non intuitive. :slight_smile:


#3

What @finalmatrix said is correct. Something you will want to add to your toolbox is being able to access and read the ‘man’ pages from within the terminal as well. When you have the terminal open, simply type
man <command>
and it will pull up a detailed explanation of the program and its available arguments. There are also a few really useful online man pages from various websites, for example https://explainshell.com/explain/1/rm and https://tldr.sh/


#4

Also possibly a more ‘authoritative’ source for online man pages, directly from Debian. https://manpages.debian.org/


#5

Thank you all so much for replies!