Remove Files and Directories Using Linux CLI

0
3 min read

Using Linux is a bit difficult if you are an absolute beginner. In this article you gonna have a look at how to remove files and directories using rm command in Linux command-line interface.

Remove files and directories in LInux

It is quite easy to use the rm command in Linux CLI. Follow me carefully if you don’t want to face any errors or file loss.

You can use the rm command to delete a specific file or directory in Linux OS. In most Linux system, deleting a file requires admin permission. In this article I have explained about everything. Becareful when you use the command rm cause it doesn’t asks permission to delete a file. Therefore, if you delete a file it will be out of your Linux system permanantely. Linux is multi-user, therefore, it doesn’t allows you even to recover your deleted files. So, once you’ve deleted the files you are fired. If the file is deleted the Linux will use it for else purpose.


Latest:

How to Remove Files Using “rm”?

Let’s learn to use the rm command. It is very command between Linux users. Beware about all your files and directories if you don’t want to lose an important file. To delete your desired file, follow me.

  1. To delete a simple file of name “ANYNAME“.

rm ANYNAME

If it asks that “You want to delete a File?” then you just press “y” and press enter. It usually happens when your file is protected.

2. Delete multiple files using rm.

rm ANYNAME1 ANYNAME2 ANYNAME3 …like this.

3. Force delete any file without any permission.

rm -f ANYNAME

4. Use the rm command combined. This will delete all the files in the particular format, for example, .html, .txt

rm -fv *.html

Remove Directories Using rm command.

  1. Remove any folder[empty] using rm.

rm -d dirname

This will remove an empty folder easily.

2. Remove folder+all files in it.

rm -r dirname

3. Remove multiple folders+all files in them using the rm command.

rm -r dirname1 dirname2 dirname3

Conclusion:

I hope you’ve now understood about the rm command. And most importantly how you can delete a file in linux without any futher hassel. Make sure you do all the above steps very carefully or once a file is deleted you can’t recover it. If you have any problem regarding linux you can contact our team. We will provide the most quick assistance for your problem. Furthermore, if you want any request for any article, you can contact our team on Facebook Page or just leave a message on Instagram to our Admin[ID: @iamsuyash69].

If you are new to Linux you can visit our website

LEAVE A REPLY

Please enter your comment!
Please enter your name here