Questions relating to the Linux remove command (rm)

learn more… | top users | synonyms

5
votes
7answers
2k views

Is the command `sudo rm /Desktop/filename` safe?

Is this safe to use? sudo rm /Desktop/FILENAME The reason for wanting to use sudo is I can't see the file. I accidentally typed in sudo rm /Desktop/index.html. It didn't find it but could ...
0
votes
3answers
35 views

How to delete all the files/folders from the folder except few folders?

Assume that I have a directory structure as follows: /application ----application/config --------application/config/c1.conf --------application/config/c2.conf ----application/logs ...
3
votes
4answers
6k views

Command to delete all files from folders matching name recursivly?

I have my base folder (let's call it base). I have a bunch of folders inside, scattered at various depths within these folders are cache folders. I want to delete all files from within the cache ...
19
votes
5answers
2k views

Unable to remove a file which has a name like a command argument [duplicate]

I inadvertently created a file called -r in my home directory. Now I cannot get rid of it: rm -rf rm: missing operand Try 'rm --help' for more information. Other attempts: rm /-/r rm: cannot ...
1
vote
2answers
67 views

How to prevent directory from being deleted by user?

Suppose a directory dir1 is created by sudo on Desktop. sudo mkdir dir1 Then I applied chown and chmod as following: sudo chown root:root dir1 sudo chmod go-rwx dir1 Now dir1 is only accessible ...
-1
votes
1answer
25 views

I cannot delete a folder from a driver (ubuntu 13.04) [closed]

When i try to delete a folder from a drive its saying through UI Error while deleting. Could not remove the folder New_Movie When i clicked show details , its showing Could not remove the folder ...
1
vote
3answers
36 views

how to remove files in a list of paths easily?

I have a list of lines like /usr/lib/i386-linux-gnu/libavfilter.so /usr/lib/i386-linux-gnu/libavfilter.so.3 /usr/lib/i386-linux-gnu/libavfilter.so.3.42.103 ...
-1
votes
2answers
46 views

Remove command not working

rm command not working.when i type command rm file name it giving me error No command 'trash' found, did you mean: Command 'crash' from package 'crash' (main) Command 'ktrash' from package ...
2
votes
2answers
164 views

Cannot delete .Trash-503 directory, returns a $RECYCLE.BIN.trashinfo: Input/output error

I cannot delete .Trash-503 folder via GUI or terminal, it returns a $RECYCLE.BIN.trashinfo: Input/output error Not even sudo rm -r or even a simple ls works in that trash directory. Check terminal ...
0
votes
2answers
82 views

cannot access/delete folder in Rubbish Bin containing hundred of thousand of corrupted files on 14.04

yesterday I discovered a folder in the Trash Bin named FdtN0bhKRX containing more than 700,000 corrupted files. I know the approximate number because I tried to move the folder to a USB key, and when ...
0
votes
2answers
54 views

Is it safe to alias rm to safe-rm?

We are happy to use safe-rm as a replacement to rm, but is it considered safe to alias it? e.g. alias rm='safe-rm'
20
votes
4answers
9k views

Can files/directories deleted from terminal be restored?

Is it possible to restore files/directories which are deleted from terminal using rm and rm -r?. If a file is deleted from graphical interface, it could be restored from trash, but how do you restore ...
0
votes
4answers
88 views

Home deleted by rm command, cannot login

I tried to use rm to format a pendrive but it also deleted everything inside my Home folder. Now I can't even login anymore. Also, pressing shift on boot wont enter in recovery mode. I have the ...
4
votes
2answers
142 views

Converting .rm to .flv using terminal?

Is there anyway to convert .rm to .flv using terminal? Because .rm file is not running in Mplayer in my Ubuntu 12.04. OS Detail: Linux HP-CQ40 3.8.0-39-generic #58~precise1-Ubuntu SMP Fri May 2 ...
2
votes
4answers
58 views

Protection For rm

I sometimes work with my server over ssh. I don't want to lose anything because of an accidental rm. Is there a way of creating a trashbin for my server? I know it sounds stupid, but I just want to ...
3
votes
1answer
54 views

what happens if i delete a file while tar is processing it?

I am attempting to backup my filesystem with the following command: tar -cvjf /fs.bz2 --exclude=/fs.bz2 --exclude=/proc --exclude=/lost+found --exclude=/mnt --exclude=/sys / This command has been ...
5
votes
4answers
4k views

Is there any faster way to remove a directory than “rm -rf”?

I have a folder that has many files and "rm -rf" takes a lot of time to complete. Is there any faster way to remove a directory and it's contents (subdirs, etc)?
0
votes
1answer
55 views

What are the important xml files? (Accidentally moved all xml files)

Very unfortunately I have moved all my xml files into one folder (I was at /home/desgua/ when I run find . -name '*.xml' -exec mv {} ./logs/ \;. Now I am very afraid of turning off my computer and not ...
39
votes
6answers
22k views

How can I recursively delete all files of a specific extension in the current directory?

How do I safely delete all files with a specific extension (e.g. .bak) from current directory and all subfolders using one command-line? Simply, I'm afraid to use rm since I used it wrong once and now ...
4
votes
2answers
2k views

I cannot delete files from root's Trash

I deleted some large files from nautilus launched as sudo. They still show in /home/.Trash-0/files/<foldername> when I type sudo sh -c "du -h /home | grep -P '[0-9]G\t'" but when I type sudo rm ...
0
votes
5answers
4k views

Pipe results of locate into rm

I tried running locate *.orig | xargs rm but it said No such file or directory I've seen ways to do it with find but locate returns the full path to the object so it should be possible
4
votes
2answers
102 views

How to prevent users from deleting files that are already in use?

Consider this scenario: User is executing a command on a file. This file becomes 'in-use' now. $ tail -f somefile.log In another shell, user deletes the file. $ rm somefile.log Now, this file ...
2
votes
2answers
1k views

“sudo rm” fails to delete files

My main account is called "u1204" and I have some files created with another account called "dad": $ find . -user dad -print ./Documents/Zim Notes/.zim/state.conf ./Documents/Zim Notes ...
0
votes
2answers
30 views

How can I change this script in order to delete directories as well?

find /folder/*.* -mtime +14 -exec rm {} \; I tried rm -r and with -R argument, but without any result.
3
votes
3answers
11k views

Can't delete/edit files on my pendrive

I'm trying to delete the .Trash-1000 from my pen drive, but with sudo rm -rf .Trash-1000/ I got rm: cannot remove `.Trash-1000/expunged/2660089871/apps.log': Read-only file system (one line of ...
1
vote
1answer
35 views

Receiving an Error when Trying to Delete a File?

I'm trying to remove some files from an installation I screwed up. I went to the directory in the terminal, and typed sudo rm PCSX but it tells me it doesn't exist even though I can quite clearly see ...
2
votes
1answer
60 views

Aliased rm, how do I also alias sudo rm

I aliased rm to a echo use del or full path to rm to save myself from accidental rm (just lost my $HOME to it). But sudo rm still uses /bin/rm. How can I alias it to also print same message? PS: del ...
1
vote
2answers
40 views

delete several files but leave the selected one

I have a folder contenting several folders and I hope to delete all of them but leave one selected, how could I do this with the command "rm "under Ubuntu12.04??
1
vote
0answers
49 views

How to recover user data missing after reset of computer

I was trying to figure out how watch 4oD (as like many people it just loads forever and never actually plays anything) so I used the help on this page: 4oD (UK) - Can't stream I started with ...
1
vote
2answers
72 views

Find packages which files got deleted or missing after installation

I just accidentally did rm -r /var but luckily managed to ^C it before more damages were done. Is there way to find out all packages which files got deleted in the location so I can reinstall them? % ...
1
vote
2answers
110 views

rm file '??q:q '

I accidently created a file named ??q:q and i can't remove it. rm '??q:q' or rm '\?\?q\:q' (To escape the ?) says No such file or directory Another interesting thing: in ls it shows the name as ...
5
votes
2answers
382 views

rm -I to prevent accidental rm

I just created alias rm="rm -I" to prevent from accidental rm command. -I prompt once before removing more than three files, or when removing recursively. Less intrusive than -i, while ...
2
votes
4answers
452 views

`rm -rf ` and `rm -r` have the same results

Bear in mind that I just learning bash so please explain in moderate terms. rm -rf and rm -r appear to do the same thing. The tutorial (https://help.ubuntu.com/community/Beginners/BashScripting) ...
1
vote
2answers
27 views

How to wipe all contents from my user account?

I'm on 12.04 desktop and was wondering if the following command would remove all the data from my user home directory as well as my trash can: rm -r /home/myUser/* If so, can someone confirm that ...
1
vote
2answers
688 views

Delete directory by referencing symbolic link

To set up the question, imagine this scenario: mkdir ~/temp cd ~/ ln -s temp temporary rm -rf temporary, rm -f temporary, and rm temporary each will remove the symbolic link but leave the directory ...
8
votes
3answers
5k views

How can I make rm stop asking me for permission?

On my server rm always asks me for permission (even though I'm root) when I run it, on my desktop it does not. Like so: $ rm mod_wsgi-3.3.tar.gz rm: remove regular file `mod_wsgi-3.3.tar.gz'? How ...
1
vote
2answers
4k views

Can't delete file even as root

I tried to delete a directory by running sudo rm -rf google-chrome. This gave no output message but the directory wasn't deleted. There is only one file remaining, google-chrome/default/User\ ...
2
votes
2answers
859 views

Remove files in a directory based on partial name

I wanted to know what is the best way to remove any files no matter what their extension is based on a partial name. Example: 13-05-12_foo_something.jpg 13-06-01_something.png ...
0
votes
1answer
25 views

How do I determine what is using the folder?

I just can't delete the folder under root (it says that resource/device is busy), but lsof and fuser tell me nothing. The folder is located in the depth of /var/www/... and I tried to delete it after ...
1
vote
0answers
1k views

How to fix error “rm: command-not-found” while processing install-info (apt-get cannot install any software)? [closed]

I am running my apt-get in a normal way but today I got some errors while using the apt-get command can anyone suggest any enhancement that I need to make in my configuration files to fix it. I have ...
2
votes
2answers
191 views

Terminal command to remove unknown file

What is the command to remove unknown file from terminal. Edit after following answer: Example: I have two files يا مهدي- Times-يا محمد Events.html مهدي Events.html how do i only first file?
14
votes
4answers
862 views

Exclude from * in command line

There are plenty of situations where the use of a * is virtually inevitable - e.g. rm -rf * in a folder that holds thousands of subfolders and files. But what if you want to exclude just one or two ...
0
votes
1answer
114 views

How to remove duplicated directory?

I have two directory with same name of "Unread". ls -l drwx------ 1 vg vg 200 Aug 4 21:57 Unread drwx------ 1 vg vg 200 Aug 4 21:57 Unread when I rm/mv the directory named "Unread", one ...
9
votes
1answer
6k views

rm: cannot remove `/run/user/root/gvfs': Is a directory

Whenever I type a command which is similar to sudo apt-get install or anything like this I get this kind of error: $ sudo su # exit exit rm: cannot remove `/run/user/root/gvfs': Is a directory How ...
0
votes
1answer
97 views

Mistakenly deleted files recursively from '/' on my still running server

I mistakenly deleted the bin folder, now most of the bin cmds do not exist. The server still works just fine but I know when I restart it, I will not like it. How can I fix this without losing system ...
1
vote
1answer
91 views

“Trash” equivalent for 12.04

I recently updated my Ubuntu version to 12.04. I have aliased rm to the command trash, and now that I have upgraded, there is no longer a command called trash. Is there an equivalent for 12.04? I ...
3
votes
2answers
272 views

rm if there's a file with same basename

Say I have the following files: foo.coffee foo.js bar.js Is there an easy way how to rm *.js if there's a corresponding .coffee file? In the example such a command would remove foo.js leaving: ...
0
votes
1answer
158 views

How can I remove this file?

I'm using an Apple Timecapsule mounted via gvfs-mount (I tried cifs too) which contains a file named Capitoli 3:5.odt I definitely want to remove that but I had no luck. From ubuntu the most i ...
2
votes
2answers
555 views

rm -i alias not working with sudo as root

I have noticed in all my Ubuntu servers the alias rm -i is ignored when you run sudo rm * as root. Is there something in sudo that is causing this behavior? I know you don't need to use sudo when you ...
1
vote
1answer
733 views

Why is “rm” so much slower than deleting files via the File Manager?

I witnessed that deleting directories (with the size of a couple of gigabytes) which contain many files is very slow when using rm. It takes up to several minutes! When deleting the same folder via ...