DEV Community

Cover image for How to remove a file in Linux?
MELVIN GEORGE
MELVIN GEORGE

Posted on • Originally published at melvingeorge.me

How to remove a file in Linux?

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 😃.


Top comments (0)