How to Use RM Command in Unix

In this tutorial, we will show you how to use the unix rm command.
The RM command is used in UNIX based environments to remove directories or files. It can be used with different switches as well.
To understand more about unix commands of rm follow the tutorial steps given below.

Step 1 – List the directory contents

First of all, let’s move to the desktop over here and list the contents of the directory.

View the contents of the directory

Step 2 – Enter a command to delete file

Over here, let’s remove file 1. For that type “rm – i 1” and hit enter. It will prompt you with a confirmation message, whether you want to delete the file or not. Over here, let’s type in “yes” and hit enter.

Insert a command to remove file

Step 3 – View if the file has been deleted

With that done, the file will be deleted as you can see from the directory.

Check if the file has been removed

Step 4 – Enter another command to delete file

Now let’s try another method for deleting the files, type the unix rm command “rm –f 2”.
With this command, you won’t be prompted with a confirmation message, and the file will be deleted straightaway.

Type a separate command to remove file

Step 5 – Confirm if your file has been deleted

Similarly, if you use the “-v” trigger, you will get a confirmation message that the file has been removed.
These are some of the ways in which you can use the unix commands for rm in Linux.

Check if your file has been removed