rm is the Linux Posix command to remove and delete files or directories.

learn more… | top users | synonyms

40
votes
12answers
95k views

How to recover a removed file under Linux?

By accident, I used rm on a file I didn't want to delete. Is there a way that I can get it back under Linux?
76
votes
11answers
44k views

Undo an “rm -rf ~” command?

I had a folder I didn't want named '~', so from the command line I typed rm -rf ~ and accidentally deleted my home folder (since ~ resolved to /home/username). Is there any way back or do I ...
16
votes
3answers
78k views

undo Linux's rm? [duplicate]

Possible Duplicate: UNDO LINUX Trash Command Hi, Is there any simple way to undo an rm command? The question is purely theoretical; I have NEVER deleted the log of a benchmark queue who ...
83
votes
16answers
43k views

How to delete all files in a directory except some?

I need to delete all files in a directory, but exclude some of them. For example, in a directory with the files a b c ... z, I need to delete all except for u and p. Is there an easy way to do this?
8
votes
1answer
1k views

Remove all files but one with rm

Is there any way to remove all of the files in a directory except for one with a certain filename? For instance, if I had a directory containing the files file1, file2, and dontdelete. Would there be ...
7
votes
6answers
4k views

Best practices to alias the rm command and make it safer

Some time ago I erroneously deleted my home folder because I ran a rm -rf * on the wrong terminal, whose working directory was the home folder! I wish I had an alias for the rm command, but it was ...
6
votes
3answers
7k views

How to delete file with this name on linux: -]???????q

Somehow a file named -]???????q got created on my terminal. I tried rm -f "-]???????q" (in double quotes), but it did not get deleted. (Error:: rm: invalid option -- ]). How do I delete it?
2
votes
4answers
1k views

Mac keyboard shortcut to rm file [duplicate]

Possible Duplicate: Permanently deleting files on Mac OS What's the Mac keyboard shortcut to rm a file? I know command + delete sends it to trash, but I want to permanently delete it, say ...
4
votes
3answers
1k views

Removing file with strange characters in filename in OS X

After a memory error in my program, I am stuck with a file with a strange filename. It's proving quite resistant to all normal methods to remove files with strange names. The filename is: ...
8
votes
3answers
15k views

Can files deleted with rm -rf be recovered?

When I delete folders or files in through osx terminal using the rm -rf, where do they go? I heard that some say they are deleted directly, but some also say it only "remove the link to the file ...
178
votes
8answers
9k views

How far will you get with an 'rm -rf /' command?

I've often wondered how far the system will actually get if you run rm -rf /. I doubt the OS would be able to erase itself (?) Bonus Question: After the command has been executed, will rm have ...
10
votes
4answers
3k views

`alias rm=“rm -i”` considered harmful?

I have read some time ago (can't find the reference) that using such an alias as alias rm="rm -i" was very bad. Is there historical evidence or common sense explanation for that fact? I would ...
10
votes
6answers
11k views

How to delete all but one file in Unix? [duplicate]

Possible Duplicate: How to delete all files in a directory except some? How to delete all but one(or some) file in Unix? Something like rm -rf -ignore myfile.txt *
4
votes
1answer
6k views

Deleting files doesn't free space

I've got a disk formatted as ext3, which was filled completely. I'm attempting to free up some space on it by deleting files, but it's not working. I can rm the files, and they don't show up in the ...
3
votes
2answers
575 views

When does rm remove open files?

Particularly, I want to know what happens when I rm an open file and don't explicitly kill the process holding the file descriptor to that file. Will the file be removed when the system is shut down?
3
votes
2answers
282 views

How to limit CPU and disk usage of rm to allow other programs to remain functional

When deleting a large file, rm seems to be hogging all the available CPU and disk resources so that other program are hanging. Is there a way to limit a programs - specifically a CPU or disk ...
2
votes
1answer
795 views

Undeletable file in RedHat Linux

There is a file under my home area that I cannot delete. When I do an ls -al on the directory, the permissions are ?--------- and there is a ? for user, group, size and date columns. When I attempt to ...
2
votes
4answers
9k views

Remove all files except for a few, from a folder in Unix [duplicate]

Possible Duplicate: How to delete all files in a directory except some? I often face this problem. I have a set of files in a folder and would like to delete all of them except a few. For ...
1
vote
4answers
1k views

Where do files and directories go when I run 'rm -rf folder_or_file_name' in Ubuntu 10.04?

When I delete folders or files in the Nautilus GUI, those folders/files go to Trash but where do folders/files go when I run rm -rf folder_or_file_name in terminal in Ubuntu 10.04?
1
vote
1answer
89 views

rm'd dirs in Users/home/ reappear in OSX [duplicate]

Possible Duplicate: Stop Mac OS from re-creating ~/Pictures, ~/Music, or ~/Public Hi, I su'd to root and deleted some stock directories in my home folder such as Documents, Music, Pictures ...
1
vote
1answer
206 views

Can I list file names (or their parent directories) that were recently deleted using rm in OS X?

Is it possible to find out which files and directories have recently been deleted by rm in OS X? Or failing that, is it possible to find which parent directories have had files or directories within ...
0
votes
2answers
301 views

How can I recover from mistaken 'rm *'?

I just typed rm * in the wrong directory by mistake. I had the wrong terminal window highlighted. What are my options?