Delete Comand In Ubuntu
Command To Delete File and Folder Ubuntu Terminal – To become a Linuxer, we must learn how to manipulate the data in the hard drive. One way to manipulate data is to delete files or folders.
In this article, the linux that I use is a derivative of Debian > Ubuntu, Elementary OS. This can also use on linux with other Debian or Ubuntu variants.
There are at least 3 commands that are used to delete data, both files and folders on Linux using the terminal, namely rm, unlink and rmdir.
- rm or unlink is used to delete files
- rm or rmdir is used to delete a folder

A. How to Delete Files Using Terminal?
Delete 1 file
To delete a file in linux use the rm and unlink commands followed by the file name:
rm fileName.extension
or
unlink fileName.extension
For example we want to delete the zoom software with the file name zoom_amd64.deb. So to delete the file is to use the command:
rm zoom_amd64.deb
or
unlink zoom_amd64.deb
Delete Multiple File
What kind of delete method do you want?
If you want to delete only some files use the command:
$ rm fileName1.extension fileName2.extension fileName3.extension
or
$ unlink fileName1.extension fileName2.extension fileName3.extension
Don’t forget every filename and other files are separated by a space ‘ ‘.
For example, we want to delete the files zoom_amd64.deb, learn_linux.jpg and guide_linux.pdf. So the command we use is:
$ rm zoom_amd64.deb learn_linux.jpg guide_linux.pdf
or
$ unlink zoom_amd64.deb learn_linux.jpg guide_linux.pdf
To delete multiple or any files, use to add a star character (*).
If you want to delete the entire file in the same file extension type use the command:
rm *.extension
For example we want to delete all pdf files, then the command is:
rm *.pdf
If you want to delete all files, all of them use the command:
rm *
Warning!! using the rm * command will delete any files!
B. How to Delete Folders Using Terminal?
How To delete a folder that does not have a file in it
The command used is:
rm -d folderName
or
rmdir folderName
How To delete a folder that contains files
The command used is:
rm -r folderName
How To delete multiple folders
Use a command like the sequence number 2 above, but by adding the folder name and separated by a space ‘ ‘, as follows:
rm -r folderName1 folderName2 folderName3
To delete all folders entirely
Use the asterisk character (*) in the following command:
rm -r *
Warning!! using the $rm -r * command will remove whatever it is!
If you think this Delete File and Folder Ubuntu Article is useful, please share it with others using the share button below.