Questions tagged [rm]
rm is the POSIX command to remove and delete files or directories.
256
questions
1
vote
2
answers
122
views
Recover Partitions deleted by rm
In my PC I have 3 NTFS partitions
1 for Windows Boot Loader, next one is windows installation directory and the last one is for storing my whole data.
They were mounted like this
/dev/sda1 => /mnt/...
0
votes
2
answers
2k
views
What is the command to remove all files and folders, on mac os x terminal?
On Mac OS X terminal, how can we remove all files and folders, including hidden ones, recursively, except one directory?
Thank you.
1
vote
1
answer
127
views
Accidentally deleted all files older than 7 days
A bad written skript located in /etc/cron.daily erroneously executed find * -mtime +7 -exec rm -r {} \; as root user. As a result of this I can no longer login. Beside that the system seems to run ...
2
votes
2
answers
2k
views
How to recursivly delete all JPG files, but keep the ones containing "sample"
How can I find and delete all the .jpg files in a directory tree with the exception of the ones containing "sample" in their filename?
For example :
a.zip -> keep it
b.jpg -...
1
vote
1
answer
1k
views
Can't rm or cd into directory [duplicate]
I found a directory on my machine called "Previous System" that looked old and useless and I tried to delete by dragging to the trash and emptying the trash. That failed to delete the directory, ...
0
votes
2
answers
3k
views
Delete All Files Older Than Specified Time Within A Directory (Ubuntu)
I have a bunch of files in a directory with all different names and I want to delete all that are older than a specified time.
Example:
File1
File2
File3
File1 was made Mar 31 08:00
File2 was made ...
3
votes
1
answer
13k
views
What does rm --preserve-root prevent exactly?
Modern rm by default has the --preserve-root option enabled, but what exactly does this prevent?
I understand it will prevent rm -r / (right?)
but does it prevent
cd /
rm *
or
rm /*
for example?...
2
votes
1
answer
7k
views
Is there any difference in power between sudo rm and sudo rm -f?
Simple question, but I'm not sure I got a complete understanding from man rm. To the best of my knowledge the only difference is that adding the -f will plow through files without prompting and ...
29
votes
11
answers
4k
views
Prevent user typing accidental space between rm and wildcard
Intention:
rm -rf string*
Problem:
rm -rf string *
The first case is a legitimate and common use of rm, a small typo can cause a lot of problems in the second case. Is there a simple way to ...
2
votes
2
answers
3k
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
1
answer
2k
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 ...
0
votes
0
answers
2k
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 started ...
0
votes
2
answers
2k
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
1
answer
132
views
How much dangerous rm -rf is?
Does rm -rf dir/ erase filesystems mounted below dir/ (say in dir/a)?
1
vote
3
answers
16k
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
0
answers
13k
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 ?
0
votes
1
answer
1k
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 ALL=(...
1
vote
1
answer
1k
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 ...
2
votes
2
answers
4k
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 "...
2
votes
1
answer
3k
views
Using Bash, how can I delete all the desktop.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
1
answer
81
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
2
answers
589
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 ...
2
votes
1
answer
4k
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
2
answers
1k
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 nitip/Downloads/...
46
votes
3
answers
88k
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
2
answers
15k
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
1
answer
319
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
2
answers
506
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
2
answers
1k
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
1
answer
4k
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
1
answer
1k
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
4
answers
423
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 ...
6
votes
3
answers
3k
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
1
answer
260
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 ~/.local/share/Steam/...
38
votes
5
answers
13k
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 ...
5
votes
1
answer
2k
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 /local/home/me/...
4
votes
2
answers
55k
views
"rm: descend into directory" - what does it mean?
I am trying to follow instructions here to get emacs going but I am stuck with deleting the .emacs.d folder. What do I do when the command line asks:
rm: descend into directory '.emacs.d'?
a@b:~$ ...
0
votes
1
answer
75
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 ...
5
votes
2
answers
4k
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
2
answers
11k
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
1
answer
199
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
1
answer
3k
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 ...
6
votes
2
answers
11k
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 get ...
2
votes
1
answer
3k
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 -...
6
votes
1
answer
2k
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
1
answer
8k
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
2
answers
352
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
1
answer
2k
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 ...
-3
votes
2
answers
1k
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?
3
votes
1
answer
14k
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 ...