Hosting or Servers Logo
Delete a File Using Linux Command Line

This is the directory containing the file 'test1.txt' which we want to delete.

ls After mkdir Command

We will use the Linux command rm (remove) to erase the file. Enter the following.

rm test1.txt

Replace 'test1.txt' with the name of the file you want to delete.

rm Command

To erase multiple files place them in a line with a space between each filename. e.g. rm test1.txt test2.txt

You can also use the * wildcard. The command rm *.txt will delete all files in the current directory that end with .txt

Use rm -i filename(s) to individually confirm each file to delete.

Other options include: -

-v Verbose mode

-f Force a deletion even if a file is write protected.

You Are Leaving Us

This link is being provided as a convenience and for informational purposes only it is not an endorsement or an approval of any of the products, services or opinions of the corporation or organization or individual.

Hostingorservers.com bears no responsibility for the accuracy, legality or content of the external site or for that of subsequent links.