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

learn more… | top users | synonyms

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 ...
5
votes
2answers
8k views

Trying to delete directory with “rm -rf”, but get message that it's not empty

I've tried deleting a directory using "rm -rf" and I'm getting the message "Directory not empty": Bens-MacBook-Pro:please benjaminhocking$ ls -lart empty_directory/ total 16 drwxr-xr-x 5 ...
84
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?
1
vote
1answer
23 views

Deleting unpacked tar.gz files after unpacking incorrectly

I recently unpacked a set of backup files in RHEL3 - 2.4kernel with tar via: tar -xvf backupfile It started to error out a bunch and I aborted thinking that maybe it was a gzip instead. Unpacking ...
0
votes
1answer
44 views

Filesystem device on a VPS

I did some bullcrap on my VPS and accidentaly deleted wrong files. Now I want to recover them with extundelete but I can't seem to find the filesystem device on my VPS. I tried ls -la /dev | grep ^b ...
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 ...
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 ...
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?
1
vote
0answers
469 views

Ubuntu: How to get my data back after sudo rm -r *? [duplicate]

Given an user made a clean and successfull: sudo rm -r * #erase all folders and files recursively starting from root How to get all the hard drive's data back ?
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?
0
votes
0answers
64 views

Bypass the $Recycle Bin in CygWin?

I'm using a CygWin session to find a large number of directories at a certain level in the file system tree in a loop, compress each directory into 1 archive, then delete the directory This ...
0
votes
2answers
2k views

How can I remove a directory with rm - rf?

I try to remove a folder with rm -rf foldername … but it says rm: cannot remove folder :is a directory. What's wrong?
0
votes
1answer
106 views

How to remove files that start with 2011XXXX

I have a bunch of files i need to delete, they all start with 2011XXXX. How would i delete them. So far i have this command: ls | grep 2011 | xargs rm And it works, but is there a better way to ...
0
votes
0answers
43 views

rm -rf * results in “Killed”

I used PHP to generate about 4,000,000 files in a directory (f/) because I was bored. When I cd .. and use rm -rf f, it simply returns "Killed" about half a second later and does not delete the ...
0
votes
2answers
71 views

Why does `rm -rf`` silently fail?

[EDIT] Please don't waste your time reading my question below. It turns out my colleague is an idiot.. :) On my server I'm trying to remove a folder and all its subfolders with the usual rm -rf ...
0
votes
0answers
379 views

How to delete *.vmdk files?

I can't seem to delete *.vmdk files and related on Mac OS X 10.6.8 with sudo rm: $ sudo rm -rf /Volumes/Temp/vm/ rm: /Volumes/Temp/vm//MarukoVM/nvram: Read-only file system rm: ...
2
votes
1answer
205 views

What command sequence can I use to delete directories but not their files?

How do I delete directories but not the files inside them? I have tried the following: rm -di /Users/arthur/Desktop/MyFolder remove /Users/arthur/Desktop/MyFolder? y rm: ...
0
votes
1answer
42 views

How much dangerous rm -rf is?

Does rm -rf dir/ erase filesystems mounted below dir/ (say in dir/a)?
2
votes
1answer
985 views

Is it possible to remove the root directory?

I noticed in the documentation for rm as obtained by rm --help the following flag: --no-preserve-root do not treat `/' specially What does this mean? Is it actually possible to delete the root ...
1
vote
2answers
1k views

Delete directory and subdirectory - Operation not permitted

There is a folder called Trash-1000 and i want to delete it. There are some folders in it which cannot be deleted (do not even know how they were created). Looks like: ...
0
votes
2answers
233 views

Removing Hidden Files in folder

I am having some trouble removing a particular folder on my harddrive. I have tried the conventional approach of rm -rf req (where req is the filename) however this failed. running ls ...
3
votes
2answers
185 views

What is the point of UNIX's rmdir?

I'm new to UNIX (MAC OS X bourne shell POSIX), I understand rmdir will only remove an empty directory but under what circumstances would you actually want to use rmdir <directory name> and not ...
3
votes
3answers
7k views

OS X Lion: Emptying the trash takes “forever”: is using rm -r safe?

Emptying my Trash in OS X Lion (non securely) is taking about three hours (about 1.5 million files, from a Time Machine backup). I had to stop the process a few times already, because I could not move ...
3
votes
1answer
420 views

What if “rm -rf” does not work, but “ls -a” shows no files?

I have a folder foo in an encfs container (source: /local/home/me/Documents mountpoint: /u/me/Documents) which I cannot delete. > pwd /u/me/Documents > mount [..] encfs on ...
0
votes
1answer
44 views

How can I know what subfolders rm -rf attempted to delete first?

I mistakenly run rm -rf on a wrong folder and than cancel the operation after two seconds. The folder is quite big with many subfolders and maybe 1% was deleted. How can I know what subfolders rm ...
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 *
1
vote
1answer
255 views

Use rmdir to delete lots of empty folders within a folder

I have a folder which should at any time have less than 500k folders. These folders are created dynamically, and when the files (images) inside them are deleted by some script, the folder itself ...
1
vote
2answers
91 views

unable to remove file and directory

i'm trying to remove directory from my external hard drive that i mounted to the file system i'm using the rm -r command but i got the the strange error : rm: cannot remove `Lundu ...
1
vote
1answer
198 views

Slow directory removal (rm -rf) on Max OS X

Can anyone help me diagnose why removing a directory would be so slow on my Mac? $ du -hs mydir/ 606M mydir/ $ find mydir/ -type f -print | wc -l 12720 $ date Tue Sep 10 10:59:27 PDT 2013 $ rm ...
16
votes
3answers
79k 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 ...
0
votes
1answer
140 views

Permission denied on sudo remove

I have two users userA and userB. userA has permission over a file named cache. I want to give permission to userB to remove the file. I have made following entry in /etc/sudoers file : userB ...
4
votes
2answers
586 views

Safe substitute for OS X `rm`?

I am used to having rm to alias something safer. I have been using osx-trash, but once I upgrade to Ruby 1.9.2, this stops working. I know about trash-cli from Python, but I would much prefer ...
1
vote
1answer
120 views

Unable to delete a file using bash script

I'm having problems removing a file in a bash script. I saw the other post with the same problem but none of those solutions solved my problem. The bash script is an OP5 surveillance check and it ...
0
votes
2answers
203 views

Is it better to check if file exists before deleting it

Sometimes when I want to delete a file (from within a script), I will just delete it rather than checking if it exists first. So I do this: $ rm "temp.txt" 2>/dev/null Instead of this: [ -f ...
1
vote
1answer
53 views

Using Bash, how can i delete all the dektop.ini in my external drive folder tree?

I am using my external HDD to store my music, and now I've installed linux on my pc. I would like to erase all the desktop.ini files in the thousand nested folders on the HDD, how can I accomplish ...
0
votes
1answer
40 views

Recovering a file in Linux

I securely deleted a file in Linux by: 1) First encrypting it with AES (cipher block chaining) 2) Then using srm which does 38 passes (as explained in man srm) Any pointers on how to recover it?
0
votes
2answers
62 views

How to `rm` files in current directory and directories inside current directory

I would like to rm all files that end in ~ in both my current directory and all directories inside my current directory. I was under the impression that the flag -r or -R would do this; however, the ...
1
vote
1answer
105 views

Removing multiple files from directory, as specified by variable in Makefile

I have a Makefile with the following configured for installing man pages MANDIR = /usr/share/man/man1 MANPAGES = exec1.1 exec2.1 make install triggers the following: install: $(MANPAGES) ...
3
votes
1answer
523 views

Is there a scenario where rm -rf -no-preserve-root is needed?

I've seen some questions on here where people accidentally do rm -rf --no-preserve-root or rm -rf *, wiping out most or all of their file system before they can react. Is there ever a reason to use ...
2
votes
2answers
954 views

UNIX command for deleting / removing files on today's date

I want to remove all the files in the directory I am in currently in that were created today. So if today is April 3rd then the UNIX commond I am asking for would remove someFile2, someFile3, ...
0
votes
1answer
42 views

command to delete all files with numbers

How can I delete nay file that has a number in its name from directory /www/ and up? Like, it would delete a1.php a2.php 123213.php asdasd5.php Would this work? ls | grep \([1-9]\) -f | xargs rm ...
1
vote
2answers
52 views

How can I delete this non-existant directory in Linux?

A few weeks ago I mapped/browsed (can't remember) to a network share on my local network. It worked fine at that point. I haven't used the machine since then, until today. As you can see below, ...
11
votes
2answers
20k views

Linux – cannot remove owned file with 777 permissions

I've couple of files that I cannot remove using rf -Rf command. I'm the owner of those file and the group assigned to those files is also a group my user is in. What's even weirder is that I can edit ...
0
votes
1answer
126 views

Stop deletion of files in Linux

I'm looking for a way to stop accidental deletion of some important files in Linux, but with a couple of criteria. The file has to remain writable (so it can of course still be replaced with rubbish ...
3
votes
1answer
862 views

restore /dev after `rm`ing it

during a gentoo install from the livedvd, there's one step to create a dev dir to be used later in the chroot of the target for the instalation it's done like that mount --rbind /dev /mnt/gentoo/dev ...
0
votes
1answer
362 views

I accidentally deleted the home directory on my Amazon Linux EC2. My whole site disappeared. What now?

I was using sudo rm -rf to delete some folders, and accidentally deleted the /Users/ec2-user home directory. I had my EC2 and AWS Route 53 running my site. Now, it just disappeared. I have all the ...
4
votes
3answers
271 views

How to remove a file with name starting with “-r” using cli [duplicate]

I have been creating odd-named files every once in a while, e.g. $ls -rthl $-rw-r--r-- 1 shamil hep 290 Aug 13 11:58 -rf And interestingly it is impossible to remove this file with rm -f -rf I ...
3
votes
4answers
246 views

Remove all *.foo in directory tree

How do I remove all *.foo in a directory tree? rm -r *.foo does not work. I could try a loop, but that needs recursive expansion: for x in */*/.../*.foo do rm $x done Which is not possible ...
0
votes
0answers
25 views

Fast removal of millions of files on a remote compute cluster [duplicate]

I would like to know what's the fastest way to remove massive number of files on a remote compute cluster (linux). I have 1000 folders to delete permanently - each containing about 200k files with ...
1
vote
1answer
161 views

Why is `rm` seemingly ignoring escapes?

I'm trying to rm a directory and its contents, however for whatever reason rm is ignoring escape characters. In this example, I'm trying to remove the folder Team Fortress 2 from ...