Questions relating to the Linux remove command (rm)

learn more… | top users | synonyms

53
votes
6answers
7k views

How is 'rm -rf /' able to delete all files in the system?

I haven't tried this command on Ubuntu (for obvious reasons) so I am not sure if Ubuntu will allow its execution. But it's famous for deleting everything. Just out of curiosity, what happens when the ...
1
vote
0answers
21 views

all my previous configurations and settings are gone by using the following command in ubuntu 14.04LTS

I used the command rm -rf ~/.Trash/* to empty the trash but when the command is executed, all my files in Download folder are deleted and all my Ubuntu settings are changed. Can anyone please help, ...
17
votes
5answers
130k views

How do I remove a folder?

I'm a new user and Im trying to remove a specific folder. I am using sudo rm /path/ but its not working. What is the correct command to use? It is a file catolog I am attempting to remove but im ...
0
votes
2answers
23 views

I just want to remove the file from directory

I am trying to remove a file with: ubuntu64@ubuntu:/usr/local/mongodb$ rm /usr/local/mongodb/* But every time it just outputs: rm: cannot remove ‘/usr/local/mongodb/mongodb-linix-x86_64-2.6.4’: ...
0
votes
1answer
54 views

how to restore data after running rm?

I accidently run sudo rm * I thought I was in an unimportant subfolder. The result is that I deleted some very important files, unfortunately. Is there any hope to get my data back ?
2
votes
2answers
99 views

Find folders of size lesser than x and delete them

I want to find all folders (within a folder) which are less than 100mb large and delete them. I actually don't want to use a bash script. But probably there is some neat one-line-loop possibility to ...
1
vote
2answers
28 views

how to remove files that are smaller than certain dimensions

I have already found an answer that lists pretty much everything. Except I cannot get it to work. I use: find . -iname "*.jpg" -type f | xargs -I{} identify -format '%w %h %i' {} | awk ...
2
votes
1answer
90 views

Accidentally removed /var folder

I did something real dumb. I was creating tarballs of files in my /var/ folder. The tarball i created was put into /tmp/test.tar In the process of testing the extraction process, I meant to delete ...
0
votes
0answers
16 views

VLC cannot be installed , [duplicate]

I installed KDE desktop before and am not able to login to kde so , i removed it using sudo remove kde* Then there was audio not working, so i re installed drivers. it is working fine, but for some ...
78
votes
6answers
87k 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 ...
0
votes
1answer
53 views

Can't create files on desktop in Ubuntu 14.04

I accidentally created a desktop shortcut in my home directory. To remove it, I did sudo rm -rf Desktop Now I can't create files and folders on my desktop.
0
votes
4answers
489 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 ...
0
votes
0answers
151 views

Recover Deleted Folder With lsof

I accidentally removed /var folder with rm command. So all my datas (like mysql databases, apache hosts etc.) gone. According to this article, I can find deleted files with lsof . $ lsof | grep ...
25
votes
5answers
21k views

Can files/directories deleted with rm 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 ...
4
votes
1answer
109 views

Difference between commands for removing empty directories

What is the difference between rm --dir <directory> and rmdir <directory> with respect to removing empty directories? Also, if they are similar, is there any advantage of having an rmdir ...
1
vote
1answer
50 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 ...
0
votes
4answers
326 views

Undo sudo rm -R /*

I stupidly ran sudo rm /* followed by sudo rm -R /* My sites still run, although the vast majority of commands like ls are now broken. Is there a simple way to get data off the server or reverse ...
0
votes
1answer
68 views

Can a directory's mtime be older than that of file inside?

I have this very silly and very basic question but I thought better to ask before I start pruning my NAS. I want to delete all directories in which all files are older than 30 days. For files I ...
32
votes
9answers
167k views

How to remove all files from a directory?

The closest I've gotten is # rm /path/to/directory/*.* but that doesn't work for files that don't have an extension...
7
votes
4answers
2k views

How can I delete a file if it starts with <html> in bash?

I need a bash command to delete the entire file if the file itself begins with <html>. I'm not sure the best way to go about this... Context: I download a series of files via curl requests. ...
9
votes
2answers
3k views

Does Ubuntu Server have a Trash?

I'm using the server version of Ubuntu. I was wondering if files still go into the "trash" etc. with this version. I'm been deleting stuff and I just want to make sure the stuff is not being put into ...
2
votes
2answers
69 views

How to remove a directory without a name?

ls -l output: drwxr-xr-x 10 mnevile mnevile 4.0K Sep 9 15:45 ​​ drwxrwxr-x 18 mnevile mnevile 4.0K Jun 16 16:01 movies/ drwxrwxr-x 16 mnevile mnevile 4.0K Aug 19 10:52 music/ drwxrwxr-x 16 mnevile ...
7
votes
2answers
508 views

Is there a significant disadvantage to aliasing rm to do something else?

I've been bitten a few times recently with rming things I shouldn't have - for example, forgetting to ulink symlinks, not rm them. I'm thinking of writing a small bash script to simply move the ...
21
votes
2answers
1k views

Does using -v (verbose) slow commands down?

In this question: How to remove all files and subdirectories in a directory WITHOUT deleting the directory in bash? it is asked how to delete all file in a folder, and not the folder itself. Matts ...
4
votes
3answers
5k 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 ...
1
vote
2answers
92 views

Unable to delete file

I am unable to delete file: sudo rm /usr/local/bin/Katy Perry - Dark Horse (Official) ft. Juicy J-0KSOMA3QBU0.mp4.part It is showing an error: bash: syntax error near unexpected token `(' How to ...
3
votes
5answers
495 views

Cannot delete Directory, doesn't exist?

Somehow this folder got created when i was logged in via sftp. "Sep 19 18:50 " I tried to delete it via sftp. Tried to SSH in and delete with rm -rf as root Error: rm ...
5
votes
1answer
3k views

How to remove files modified between particular dates?

As in the topic: I would like to remove files in a directory that have been modified in a particular date range. How can I do this ?
0
votes
2answers
95 views

Understanding rm command

I've been using Ubuntu server at home for a while now, and I've noticed I've some holes in my knowledge of bash and in general several dangerous tools like rm. It is first time in my life I used rm ...
6
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 ...
3
votes
4answers
8k 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 ...
3
votes
2answers
368 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
55 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 ...
2
votes
3answers
292 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
285 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
1k 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
177 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
518 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'
0
votes
4answers
182 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
437 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
157 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 ...
4
votes
1answer
67 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 ...
6
votes
4answers
6k 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
56 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 ...
0
votes
5answers
5k 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
122 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
2k 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
39 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
13k 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 ...