Questions relating to the Linux remove command (rm)

learn more… | top users | synonyms

35
votes
5answers
66k 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 ...
177
votes
6answers
212k 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 ...
6
votes
1answer
7k 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 ?
1
vote
2answers
232 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 ...
67
votes
9answers
304k 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...
35
votes
5answers
274k 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 ...
8
votes
2answers
3k views

How is rm command different from the delete button?

I read from a book where it says, the command rm deletes the inode and not the file. Which means if I delete with the rm command, then it cannot be restored. I'm very new to Ubuntu environment. Now ...
3
votes
2answers
15k views

How to remove single file from /usr directory?

I am using Ubuntu 12.04 LTS, and I want "XnRetro.desktop" file to be removed from directory /usr/share/applications using terminal . How to do it ? I am new into Linux & I know something like "rm"...
2
votes
4answers
3k views

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

Assume that I have a directory structure as follows: application │ ├── config │ ├── c1.conf │ └── c2.conf │ ├── logs │ ├── l1.txt │ └── l2.txt │ └── src ├── static ├── s1.py └── ...
8
votes
1answer
2k views

How to prevent a file under user folder to be deleted?

How can I make some file impossible to be deleted by user even if it is under his/her home folder?
27
votes
5answers
5k views

Removing folder named ~

This is the output of ls -l ls -l total 53484 drwxr-xr-x 3 root root 4096 2011-02-10 05:59 ~ -rw-r--r-- 1 root root 54313810 2011-02-13 05:09 jobs.jar -rw-r--r-- 1 root root 384035 2011-02-15 ...
16
votes
6answers
11k 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)?
6
votes
7answers
4k 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
2answers
2k views

how to restore boot folder?

No laughing! I just did sudo rm -vr /boot/*. Is there a way to restore the content? Just to clarify why I would do this: I have a SD-card with a boot-partition mounted at /media/boot that I wanted ...
3
votes
3answers
16k 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 ...
9
votes
1answer
8k 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 ...
3
votes
1answer
931 views

File wont delete from trash even after sudo rm -rf ~/.local/share/Trash/

I've tried using sudo rm -rf ~/.local/share/Trash/files/ and even going myself as root doing the same, and recreating the folder its still there, it was from a pendrive at one point and I deleted it ...
1
vote
4answers
1k views

Unable to “rm” a file named “() - .” due to “No such file or directory”

A script I wrote named a file "() - ." according to Filezilla. Filezilla was unable to delete it from the server so I tried to "rm "() - ." from inside the containing folder and received "rm: cannot ...
1
vote
2answers
181 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 ??q:...
1
vote
1answer
485 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 ...