Questions relating to the Linux remove command (rm)

learn more… | top users | synonyms

23
votes
5answers
13k 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 ...
7
votes
1answer
1k 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?
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 ?
8
votes
2answers
637 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 ...
1
vote
2answers
67 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 ...
62
votes
6answers
52k 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 ...
26
votes
5answers
4k 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 ...
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
2answers
1k 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
12k 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 ...
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 ...
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 ...
6
votes
4answers
5k 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)?
5
votes
4answers
594 views

How can I prevent accidental execution of the rm -r *command?

Occasionally I use command to delete some files. For example, the name might start with 'a', so I'll delete with the command rm -r a*, but I don't want to remove some other directory by accident. How ...
3
votes
1answer
801 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
2answers
123 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 ...
1
vote
0answers
2k 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 ...
1
vote
4answers
800 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 ...
0
votes
1answer
34 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 ...