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

learn more… | top users | synonyms

0
votes
2answers
221 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
20 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 ^^ )
36
votes
3answers
17k 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
25 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 ...
21
votes
3answers
109k 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
30 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 ...
8
votes
4answers
15k 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 ...
-1
votes
3answers
41 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
66 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
71 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
137k 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
112 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 ...
3
votes
3answers
9k 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 ...
188
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
29 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
52 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
84 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
847 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 ...
90
votes
11answers
65k 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
883 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
681 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
42 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
36 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
269 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
27 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 ...
102
votes
9answers
79k 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
59 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 => ...
15
votes
3answers
32k 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
2answers
206 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
69 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
245 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
420 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
2answers
3k 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 ...
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 ...
5
votes
2answers
3k 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 ...
1
vote
1answer
71 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 ...
2
votes
1answer
148 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 ...
1
vote
1answer
2k views

How do I remove someone else's subdirectory from under my directory?

I was sharing files with a coworker on a Linux server, and he added some new files. Now we've moved the files somewhere else, so I'd like to remove the old files. However, when my coworker added his ...
-4
votes
2answers
526 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?
31
votes
10answers
3k 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 ...
0
votes
2answers
284 views

How can I prevent bash from executing 'rm' when ' * ' is one of the arguments?

I wish to insure myself from accidentally using rm [argument_i] * [argument_j] i.e. it should always refuse to execute the command, when the asterisk character is separated by white space on both ...