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

learn more… | top users | synonyms

0
votes
3answers
4k 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 ...
0
votes
0answers
22 views

How to make a busy file not busy so it can be deleted. rm: filename: Resource busy

I have somehow generated a file on a network mounted volume that is in the busy state, and I have no knowledge of what could be using it. I want the file gone, and am not really concerned about ...
3
votes
1answer
3k 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 ...
15
votes
4answers
36k 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 ...
12
votes
7answers
8k 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 ...
0
votes
1answer
19 views

Delete all the folders and file except one folder

I want to remove all the folders and files but except one. I have a Ubuntu server and I tried several methods and none of them worked. This is my folder structure. app app/public app/public/uploads ...
1
vote
2answers
30 views

Root user can't remove folder

There is a folder /mnt/shared which root user can't access/modify or remove. # ls -lai /mnt total 4 16662 drwxr-xr-x 3 root root 0 Mar 27 14:30 . 2 drwxr-xr-x 23 root root 4096 Mar 27 14:26 ...
9
votes
4answers
17k 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 ...
0
votes
0answers
25 views

Have I messed up Time Machine backup?

I recently had a full power outage which happened in the middle of a Time-Machine backup to a Time Capsule on my network over WiFi. I've only recently got and started using the TimeCapsule device but ...
0
votes
2answers
288 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 ...
1
vote
1answer
33 views

unable to remove symbolic links of rsync copy of /bin and /dev

I accidentally made a rsync copy of my root directory, "/" using the -a option, as follows: user@mycomputer:~$ rsync -a / /backup-dir user@mycomputer:~$ ls -l /backup-dir/ total 10102784 drwxrwxrwx 1 ...
-4
votes
2answers
3k 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 ^^ )
38
votes
3answers
19k views

Does rm -f follow symbolic links?

I have a directory like this: $ ls -l total 899166 drwxr-xr-x 12 me scicomp 324 Jan 24 13:47 data -rw-r--r-- 1 me scicomp 84188 Jan 24 13:47 lod-thin-1.000000-0.010000-0.030000.rda ...
0
votes
0answers
41 views

Remove backups older than 7 days except first of every month

I want to delete backups older than 7 days but keep the first of every month. The name of the files is name_$(date +\%d\%m\%Y).tar.gz I want to keep name_$(date +\01\%m\%Y).tar.gz I want something ...
1
vote
1answer
21 views

Recursive removal, preserve directories in Linux

In a Linux command line is it possible to - without prompting - recursively remove files (like with rm -r [path]), but preserve directories under [path]? EDIT: For the interested, I've used Paul's ...
24
votes
3answers
114k 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
44 views

User can't delete file owned by user with w permission

I've a backup system based on rsync. Get a problem when try delete one file srv106@storage10:~$ rm -vf /srv/storage/homes/srv106/daily/files/daily.32/root/.my.cnf rm: cannot remove ...
-1
votes
3answers
48 views

Remove all files but one folder with rm

I want to use rm -rf to remove files/folders inside a folder, but skip or ignore a specific folder. It has been suggested as duplicated to another quesiton, but that is not the case. The other ...
5
votes
5answers
2k 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: ...
0
votes
0answers
93 views

10.11 rm -rf Facetime

I try to get rid of Facetime (then auto call link on random number is annoying me too much) I've try rm -rf /Applications/FaceTime.app/ but never have enough privilege (operation denied) Sudo is ...
0
votes
1answer
124 views

How to kill/rm pipe by inode number only?

EDIT: I originally cut and pasted a question I'd asked earlier on stackoverflow that got closed: http://stackoverflow.com/questions/32622224/how-to-kill-pipe-by-inode-number-only I've now run into ...
50
votes
13answers
148k 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?
-3
votes
1answer
190 views

Couldn't remove a directory, already tried rmdir -rf

I kept on trying to remove a folder in the server, but I kept on getting a same error. Please help me. I used this post as a reference ...
4
votes
3answers
10k views

Emptying the trash takes “forever”: is using rm -r safe to use in Mac OS X 10.7 (Lion)?

Emptying my Trash in Mac OS X 10.7 (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 ...
191
votes
9answers
13k 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 ...
0
votes
0answers
36 views

Accidentally partially deleted home directory . . . Killed with ctl-c, which file is corrupted?

I was running some software in my home directory (last time I do that!). Stupid config file asks what directory I wanted to put my output files. I accidently used ~/ as my output directory. It ...
0
votes
0answers
53 views

Linux: Delete all but x files?

I have a series of files with different IDs: File_ID1_1 File_ID1_2 File_ID1_3 File_ID1_4 File_ID1_5 File_ID1_6 File_ID2_1 File_ID2_2 File_ID3_1 File_ID3_2 File_ID3_3 For every ID there is a defined ...
23
votes
2answers
2k views

Linux Mint doesn’t boot after running “rm” command that was supposed to setup a swap partition

When I was creating my Linux hard drive, I skipped creating a swap partition, thinking that 4GB would be enough RAM. Now, I think I do need a swap partition. I asked some people on IRC how to do this, ...
0
votes
2answers
88 views

override environment variables

I would like to override a particular environment variable on a one-shot basis. The system currently has a variable for the "rm" command, forcing verification for each file. In general I am fine ...
4
votes
1answer
944 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 ...
93
votes
11answers
69k 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 ...
3
votes
2answers
988 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
3answers
761 views

(Probably) trivial question about rmdir

I hope this isn't too trivial, but for some reason I can't get a simple command to execute. I'm writing a file manipulation script and I have several directories called test, test2, etc each ...
0
votes
1answer
54 views

rm -rf / on a virtual machine?

So, this is probably a stupid question, but I'm genuinely interested. Would it be safe to recursively delete everything on a virtual machine from a command line, just for fun? I'd assume so, given ...
0
votes
0answers
5 views

How to delete a file named `aux` [duplicate]

I have a file named aux in a directory ...> ls aux ...> dir Wolumin w stacji C nie ma etykiety. Numer seryjny woluminu: ... Katalog: C:\Users\...\config 2015-07-15 23:14 <DIR> ...
1
vote
2answers
37 views

Deleting specific folders recursively

The folder structure is as below A/B/C1/ A/B/C2/ X/B/C1/ X/B/C2/ I want to delete all C2 folders however keep C1 intact. What is the correct command for that?
6
votes
1answer
295 views

Explaining the -W flag for rm

What does the -W flag for rm do (on BSD or Mac OS X)? According to its man page, the flag attempts to "undelete the named files." And currently, "this option can only be used to recover files covered ...
1
vote
2answers
33 views

How to delete all files and directory except one named directory from a specific folder in centos [duplicate]

I want to delete all files and directories from a specific directory except for one directory. For the same operation I had run this command # rm -R -df !(dir_name_not_to_delete) It works in Ubuntu ...
119
votes
9answers
89k views

How do I make rm not give an error if a file doesn't exist?

I'm writing a makefile that will clean up some useless files at the end of the compilation. If a target has already been made, it will of course skip that target and the useless file may not be ...
0
votes
2answers
67 views

understanding the -R flag and * in rm commands

When using the rm command in OS X 10.9 I accidentally deleted an entire disk. As I understand the command I used: sudo rm -Rfv /Volumes/Disk/AppName\!\ Whatever\ X.app/Contents/Resources/* ...
0
votes
0answers
14 views

How to recover Files or get list of deleted files [duplicate]

I'm new to mac. Recently I deleted some of files using terminal. I run the command rm -rf sometext* on desktop but all files are deleted accidentally. Is there any command using which i can recover ...
1
vote
2answers
42 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 => ...
0
votes
2answers
236 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.
0
votes
1answer
71 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
2answers
343 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
1answer
518 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, ...
5
votes
2answers
3k views

Delete all files older than X days

So I have a cron setup to make backups of a folder into a tarball every hour. I would like to add into the shell script that I'm using the ability to have files deleted automagically after about three ...
2
votes
3answers
2k views

How can delete all files except one from a directory? [duplicate]

I need to delete all files, except one (its name is defined), from a given directory. How can I do this from the terminal in OS X? Can I do this with one single command?
30
votes
5answers
3k 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 ...
8
votes
2answers
4k views

Removing files matching a numeric range regular expression

I have a folder which has many files. Some of the data files are labelled 1, 2, 3, ..., 300 I want to remove these data files using the terminal. How do I do this? I want to do something like rm ...