Removing a file from the command line

In my last post I talked about the 3 main ways of creating files from the command line. Today I will look at how to remove a file. Generally, to remove anything you would use the following command.

rm myfile.text

This is a very simple command, although by using some flags we can make it both safer and easier to use. -I gives a prompt before removing three or more files or when removing recursively, -v (or –verbose) prints everything that has been removed. You can also use the sudo command to remove a file from a folder where you do not have permissions to write.

sudo rm -Iv myfile.text

Using the -I command forces you to give another input to remove more than 3 files, this can be very useful in making sure that you do not delete a file by mistake.

The rm command can also remove folders and all of its contents. To do this you simple need to name the folder and use the -r flag.

rm -rIv myfoler

You can also specify a file or folder location in the form of /path/to/location in order to remove from another location.


Hopefully this helps someone, I know how long learning the command line commands can take, and often you use commands for a long time before you understand how they work.

Leave a comment


  1. Great Post keep it coming I just grabbed your feed

  2. I found this post to be very interesting. I have went through and read many of your articles. They are amazing!

  3. lol a couple of the comments bloggers write are just silly and unrelated, sometimes i wonder whether they at all read the post before writing or whether they merely look at the subject of the post and write the very first thought that comes to their minds. But it is nice to find a fresh commentary every now and then in contrast to the exact same, traditional blog garbage which I oftentimes notice on the blogs. Cheers

  4. This is an amazing post! I just have one thought. How do you do it? Every little thing on this website is so good.

    Keep up the nice work!

  5. I don’t ordinarily comment but I gotta say appreciate it for the post on this amazing one : D.

  6. I love when you talk about this type of stuff in your posts. Perhaps could you continue this?

  7. Strange this post is totaly unrelated to what I was searching google for, but it was listed on the first page. I guess your doing something right if Google likes you enough to put you on the first page of a non related search. 🙂

  8. Hi! I found your blog on Bing.It’s really well written and it helped me a lot.

    Continue the good work!

  9. Sweet site, I hadn’t noticed before in my searches!
    Keep up the great work!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: