DEV Community

loading...
Cover image for How to remove a file in Linux?

How to remove a file in Linux?

MELVIN GEORGE
Hi, I'm Melvin George, A web developer, and a blogger.
Originally published at melvingeorge.me ・1 min read

Originally posted here!

To remove a file in Linux, you can use the rm command followed by a space and the name of the file in the Linux terminal.

For example, let's say you have a file called myFile.txt and wants to delete it. You can use the rm command like this in the terminal,

# Delete a file in Linux
rm myFile.txt
Enter fullscreen mode Exit fullscreen mode

Executing the above command will delete the myFile.txt file from the directory.

See the execution of the above command live in repl.it.

To delete more than 1 file at once, you can pass the name of the files with space in between them like this,

# Delete more than 1 file in Linux
rm myFile.txt myFile2.txt myFile3.txt
Enter fullscreen mode Exit fullscreen mode

That's it 😃!

Feel free to share if you found this useful 😃.


Discussion (0)