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

learn more… | top users | synonyms

1
vote
1answer
23 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 ...
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 ...
0
votes
1answer
31 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
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 ...
0
votes
0answers
67 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
74 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 ...
-3
votes
1answer
122 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 ...
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
2answers
85 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 ...
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 ...
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?
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 ...
0
votes
2answers
60 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
207 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
250 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
426 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
225 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
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
150 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 ...
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 ...
1
vote
1answer
93 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
1answer
353 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
0answers
293 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
105 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
201 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
50 views

How much dangerous rm -rf is?

Does rm -rf dir/ erase filesystems mounted below dir/ (say in dir/a)?
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 ...
1
vote
0answers
470 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
1answer
340 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
198 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
414 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
146 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
52 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
149 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
590 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
385 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 ...
5
votes
1answer
2k 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
3k 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
99 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
60 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
346 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
725 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
436 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
279 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 ...