Questions tagged [rm]
75 questions
177
votes
31 answers
How do I prevent accidental rm -rf /*?
I just ran rm -rf /* accidentally, but I meant rm -rf ./* (notice the star after the slash).
alias rm='rm -i' and --preserve-root by default didn't save me, so are there any automatic safeguards for this?
I wasn't root and cancelled the command…
Valentin Nemcev
- 1,965
- 2
- 13
- 12
119
votes
24 answers
rm on a directory with millions of files
Background: physical server, about two years old, 7200-RPM SATA drives connected to a 3Ware RAID card, ext3 FS mounted noatime and data=ordered, not under crazy load, kernel 2.6.18-92.1.22.el5, uptime 545 days. Directory doesn't contain any…
BMDan
- 7,129
- 2
- 22
- 34
35
votes
5 answers
Could `rm -rf / --no-preserve-root` mess up the bios?
In order to see approximate speeds for tarballing an entire system, and then restoring that system when if it was foobar'd, I partially cloned one of our primary systems onto a workstation that, while not integral to our company systems, would be…
MirroredFate
- 467
- 5
- 8
32
votes
11 answers
How to make `rm` faster on ext3/linux?
I have ext3 filesystem mounted with default options. On it I have some ~ 100GB files.
Removal of any of such files takes long time (8 minutes) and causes a lot of io traffic, which increases load on server.
Is there any way to make the rm not as…
user13185
26
votes
3 answers
Cannot delete folder with rm -rf. Error: device or resource busy
I'm trying to delete /var/www/html but I'm getting this error:
rm: cannot remove `html': Device or resource busy
Hugo
- 261
- 1
- 3
- 3
23
votes
2 answers
Will Ansible prevent the execution of 'rm -rf /' in a shell script
This is based upon this hoax question here. The problem described is having a bash script which contains something to the effect of:
rm -rf {pattern1}/{pattern2}
...which if both patterns include one or more empty elements will expand to at least…
aroth
- 393
- 3
- 9
11
votes
3 answers
Unix magic, delete all .pyc files from a tree of directories?
Is there a quick way of deleting all the .pyc files from a tree of directories?
interstar
- 1,231
- 4
- 18
- 23
9
votes
1 answer
cannot remove file, Device or resource busy
I tried removing a file. The most relevant answer can be found here, but I found no luck. Here is the original problem:
maxgitt@mgpc:~$ sudo rm -rf /var/lib/docker/
rm: cannot remove '/var/lib/docker/aufs': Device or resource busy
To locate the…
Max
- 227
- 2
- 4
- 7
9
votes
3 answers
Is there a way to delete 100GB file on Linux without thrashing IO / load?
I have a huge log file I need to delete on a production web server. I'm worried it'll bring the system to a crawl if I rm it on Linux. Any brilliant ideas?
Update:
Filesystem: ext3
Partition: /var (mostly logs and MySQL data)
Log file is no longer…
objectoriented
- 133
- 1
- 1
- 5
9
votes
10 answers
Best practices to prevent 'rm -rf /' in bash scripts
It's well known fact that extra space in env.variable can lead to deletion of / directory in bash script.
#!/bin/bash
...
rm -rf /$MYPATH
if $MYPATH contains values like " dir" or "dir /" it will lead to "rm -rf / dir" or "rm -rf dir /". And will…
igorp1024
- 228
- 3
- 8
8
votes
3 answers
How to keep subtree removal (`rm -rf`) from starving other processes for Disk I/O?
We have a very large (multi-GB) Nginx cache directory for a busy site, which we occasionally need to clear all at once. I've solved this in the past by moving the cache folder to a new path, making a new cache folder at the old path, and then rm…
David Eyk
- 667
- 1
- 7
- 17
6
votes
3 answers
Difficult to Delete Files in Linux
There's a lot of stuff about this on the Internet, but most of the examples there are contrived. How does one delete files that are really stubborn? e.g.,
$ find ./ -inum 167794
./àKÈÿÿÿÿ@
$ find ./ -inum 167794 -exec rm \"{}\" \;
rm: cannot…
mgjk
- 854
- 3
- 9
- 19
5
votes
3 answers
How to Fix Directory with all Question Marks as Permissions
I'm using CentOS 7 and trying to list a directory's contents but can't. When I try to list the contents, I get the following output:
[entpnerd@myhost ~]$ ls -ali /data/sharedlogs/otherhost/
ls: cannot access /data/sharedlogs/otherhost/vcs: Not a…
entpnerd
- 155
- 1
- 6
5
votes
3 answers
directories with two one dot (.) entries
I'm trying to clean up my lost and found, and I've managed to remove most things, but I'm left with "almost" empty directories, like:
lost+found/#14042862:
total 1324
dr---wx--- 2 76040 43010 4096 2011-04-29 07:56 .
dr---wx--- 2 76040 43010 …
Jayen
- 1,827
- 3
- 16
- 27
5
votes
2 answers
can't git rm a directory
I accidentally added a directory to the list of items i'm supposed to git commit. Now when I try to run a git rm dirname, I get the error
rm 'dirname'
fatal: git rm: 'dirname': Is a directory
I tried the following commands git rm -rf dirname and…
John
- 7,153
- 22
- 61
- 86