Saturday , December 21 2024

Delete Files In Linux

In today’s article I will tell you how to Delete Files In Linux with (rm command).

We use the rm command to delete a file or directory. We need to think carefully when using this command because when it is deleted, it can be a little difficult to restore. For this, you should think carefully before deleting something.

General usage:

rm directory or file

Example Usage:

In the above example, we used it to delete the text file under the /home/farukerdem directory.

How do we do when we want to delete a file in the directory?

If you do as above, you will receive an error message like the one below. This is because you didn’t use the -r parameter when you wanted to delete the files.

We use the -r parameter to delete the file in the directory.

At the beginning of my article, I said that you should think carefully before deleting. I recommend using the rm command with the -i parameter until you know the Linux commands and the linux file structure well.

What does the “-i” parameter do? Before doing a deletion, it asks you if you want to delete this file, you can think of it as your last chance to check before deleting and before you go wrong.

Let’s delete our text file named textfile in the directory below.

When we run the command it asks as follows.

To delete, we type “y” and press enter to perform the deletion process. If you don’t want to delete it, typing “n” and pressing enter will cancel the deletion. If you want to delete in the directory, you can delete it using two parameters as follows.

-f parameter : -f parameter means force. It is used to mean force to delete.

Example usage:

To delete a file

Loading

About Faruk Erdem

Leave a Reply

Your email address will not be published. Required fields are marked *