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

learn more… | top users | synonyms

0
votes
0answers
19 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
0answers
29 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
44 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
1answer
37 views

How much dangerous rm -rf is?

Does rm -rf dir/ erase filesystems mounted below dir/ (say in dir/a)?
0
votes
2answers
23 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 ...
1
vote
0answers
217 views

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

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 ?
0
votes
1answer
69 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 ...
1
vote
1answer
84 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
135 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
45 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
35 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
50 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
51 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) ...
1
vote
2answers
57 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 ...
3
votes
1answer
269 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
444 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
30 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
50 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, ...
0
votes
1answer
94 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 ...
0
votes
1answer
309 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 ...
1
vote
1answer
183 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 ...
3
votes
4answers
238 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 ...
4
votes
3answers
252 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 ...
1
vote
1answer
146 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 ...
28
votes
5answers
1k views

Deleting millions of files

I had a dir fill up with millions of gif images. Too many for rm command. I have been trying the find command like this: find . -name "*.gif" -print0 | xargs -0 rm Problem is, it bogs down my ...
3
votes
1answer
309 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
42 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 ...
3
votes
1answer
417 views

Fastest way to delete a non empty directory in Linux

I use the command rm -rf directory but i came across the following article : Article That suggests that rsynch to an empty folder is the fastest way? rsync -a –delete empty/ a Why is this the case ? ...
2
votes
2answers
1k views

rm command: remove files with file names containing brackets

I am trying to remove all files in a Windows 7 directory with filenames containing brackets; ( and ): Using MinGW: rm *(*)* I get an error: sh: syntax error near unexpected token '(' I assume ...
2
votes
1answer
52 views

How can rm -rf be slower than delete in nautilus?

I had this very surprising situation recently, while trying to delete folders containing many files (think code repo checkout with some 10 thousands files): When I tried to do this via command line ...
2
votes
1answer
220 views

Delete all file except some in bash, without cd to the directory?

I need to make a daily cleanup in a download directory. I have saw this question and tested the answer rm !("test 1"|"test 4") It work great, but require to have cd to the directory before. Since ...
0
votes
2answers
118 views

Need to delete a file I accidentally labeled in quotes in Linux [duplicate]

I have a file which I wrote and not thinking put the actual filename in single quotes like this: 'filename' When I try to remove it using rm -f 'filename' it does not recognize that it is there I ...
1
vote
1answer
161 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 ...
4
votes
1answer
204 views

How can I remove all files from a directory that have a certain filename length?

I have a tmp directory full of various files that a program has created and not cleaned up properly. Each of these files has a filename that's simply 6 random characters. In addition to these, there ...
5
votes
1answer
499 views

How to delete the contents of a USB Stick in Linux

I'm not looking to format the stick at all, but rather to iterate through the files deleting them all (though after typing 'iterate through' I can sense a Python script coming along. So far I've ...
0
votes
2answers
106 views

`sudo rm -rf /` got interrupted leaving the data partially deleted

I ran sudo rm -rf / to wipe out all data, for some reason the execution got interrupted. Now I am left with a shell that only has cd command!!! (ls, sudo, rm, etc got deleted!) What should I do to ...
0
votes
1answer
498 views

rm -rf does not delete folder contents but instead creates another empty one

I'm currently writing a start script for a minecraft game server. In this script I included a backup script. This backup script works almost perfect but instead of deleting a folders contents it just ...
-1
votes
1answer
274 views

Preventing execution of sudo rm -rf /*

Do any Linux distros prevent the execution of sudo rm -rf /* so that people do not accidentally delete their hard drives if they did not know what they are doing?
1
vote
1answer
368 views

Use 'find' to find and delete large files of a certain type

I am trying to find and rm -rf large files in RHEL, but what I would expect from this command that would give me purely the file directories, feeding them into rm -rf, it is not removing them. My FU ...
-1
votes
2answers
96 views

Behaviour of “rm -r”

Up until now I was using Ubuntu, and the behaviour of rm for directories was the following: rm -r dir would remove dir if it was empty, and give an error otherwise rm -rf dir would remove dir and ...
16
votes
3answers
1k views

How can I remove a file or directory called “\”?

I'm using terminal on a Ubuntu machine and there is a file that I would like to delete. The file's name is \ (just a backslash). Now usually I would just do rm filename However if I do rm \ then ...
3
votes
1answer
1k views

How do I remove a possible hard-link directory to root?

I know hard links to directories aren't supposed to be possible but it I have something odd on my NAS that looks very much like one. This folder originally came from a linux machine and appears to ...
0
votes
1answer
153 views

Does interrupting rm command with keyboard delete any file?

I'm running Fedora 13 (Goddard) and when I was recursively removing a directory I noticed I had some files there I couldn't lose, so I interrupted the process with ctrl+c. Now I don't know if I lost ...
-4
votes
2answers
1k views

“rm -rf /” VS. “mv -r / /dev/null”

Might be a stupid question, but what would be the worst for your system ? (I think both) But to my opinion mv would be the fastest to "delete" it all. Am I wrong ? (don't wana test aniway ^^ )
1
vote
1answer
147 views

Avoiding accidental 'rm' disasters

Today, using sudo -s, I wanted to rm -R ./lib/, but I actually rm -R /lib/. I had to reinstall my OS (Mint 15) and re-download and re-configure all my packages. Not fun. How can I avoid similar ...
0
votes
2answers
303 views

Accidentally “rm -rf /” in OS X [closed]

Some background to maybe help others from making this mistake. I was reading jokes from this Stack Overflow page to my friend ...
3
votes
1answer
244 views

rm -r only files?

Is there an way to remove all the files from the current dir (recursively), keeping the directory structure?
2
votes
1answer
295 views

Removing a directory containing a file using find

I'm searching a list of directories for certain files and I want to delete the directory that the file is in. This is what I'm trying: find /converter/storage/unmatched/ -size -4b -name '*.mp3' ...
1
vote
2answers
954 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: ...