Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm very new to Ubuntu.

If I do:

rm removeText

The terminal is doing it silently. Why can't it say:

removeText removed

or something similar? I'd like this so that every time I remove a file, I don't have to execute ls to see if the file has been removed or not.

Is there any way to change this behavior?

share|improve this question
1  
usually the terminal will only return text if something went wrong. btw just to be pedantic (or provide un-asked-for info) this isn't an ubuntu behaviour, it's a unix/linux behaviour, ie is shared by all unix derived OSs, of which ubuntu is just one example. The "rm -i" command @slhck mentions is actually an override added by bash, which is the standard shell, ie input handling program. The unix-basic rm doesn't have an "-i" option. Just saying in case you're one of those people who likes to read around the subject a bit :) –  Max Williams Aug 8 '12 at 9:39
    
@MaxWilliams On my Ubuntu system, rm is /bin/rm from Coreutils and not a shell builtin, and it offers rm -i. Am I missing something? –  slhck Aug 8 '12 at 9:53
    
As is already said but maybe not as clearly, to directly address your last question: you don't have to use ls to see if the file has been removed, since it will be removed unless you are told otherwise by rm. –  Daniel Andersson Aug 8 '12 at 10:20
    
@DanielAndersson True, that somehow didn't come across as clearly as I wanted. Added that to my answer. –  slhck Aug 8 '12 at 10:36

1 Answer 1

up vote 7 down vote accepted

Because it trusts you to know what you're doing. Normally, Unix and Linux commands only tell you if something went wrong, and will stay quiet otherwise. This makes the commands so easy to use in scripts or when chained together – you will have to tell them that you want a specific output.

So, if there had been a problem removing a file, you would have received an error.

Getting a confirmation dialog:

If you want a confirmation dialog before removing a file, use rm -i or rm -I (the latter is available on GNU/Linux, and not on OS X or any BSD-derived systems):

   -i     prompt before every removal

   -I     prompt once before removing more than three files, or when removing recursively.  Less intrusive than -i, while still giv‐
          ing protection against most mistakes

Knowing what was removed:

If you just want to see which file was removed, use rm -v (v for "verbose", a flag present in many command-line tools). You can also alias your rm to use rm -v instead by adding the following line to your ~/.bashrc file (see here on how to do that).

alias rm='rm -v'

The alias will "replace" the built-in command with the one on the right hand of the expression.

A word of caution:

Note that aliasing built-in commands is often considered bad practice. Why? If you find yourself getting used to getting confirmation dialogs, and suddenly you are on another system, type rm /some/important/file, you'll end up removing a file you didn't want to, and it'll be gone. Forever.

I'd suggest you learn to live with the defaults unless you absolutely feel confident around the Linux shell.

Also, always read man rm – or generally the manpages of commands you want to use. They often provide additional information about common mistakes, further flags, and other caveats.

share|improve this answer
    
+1 for your word of caution. Years ago as a fledgling sysadmin, I was bitten by this exact thing, having aliased "dangerous" commands for my own user account. The first week I had true root access, I botched a shell glob and deleted a year's worth of system logs. I didn't double-check that the command was going to do what I wanted since I was used to the remove /path/to/file? [y/N] prompts being a safety net. Fortunately the lesson was learned with just the one mistake :) –  Justin ᚅᚔᚈᚄᚒᚔ Aug 8 '12 at 14:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.